babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap 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 cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @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)
  7481. * @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)
  7482. * @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)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * 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.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7582. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7583. */
  7584. preserveParentRotationForBillboard: boolean;
  7585. /**
  7586. * 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
  7587. */
  7588. scalingDeterminant: number;
  7589. /**
  7590. * Sets the distance of the object to max, often used by skybox
  7591. */
  7592. infiniteDistance: boolean;
  7593. /**
  7594. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7595. * By default the system will update normals to compensate
  7596. */
  7597. ignoreNonUniformScaling: boolean;
  7598. /** @hidden */
  7599. _poseMatrix: Matrix;
  7600. /** @hidden */
  7601. _localMatrix: Matrix;
  7602. private _absolutePosition;
  7603. private _pivotMatrix;
  7604. private _pivotMatrixInverse;
  7605. protected _postMultiplyPivotMatrix: boolean;
  7606. private _tempMatrix;
  7607. private _tempMatrix2;
  7608. protected _isWorldMatrixFrozen: boolean;
  7609. /** @hidden */
  7610. _indexInSceneTransformNodesArray: number;
  7611. /**
  7612. * An event triggered after the world matrix is updated
  7613. */
  7614. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7615. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7616. /**
  7617. * Gets a string identifying the name of the class
  7618. * @returns "TransformNode" string
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7623. */
  7624. position: Vector3;
  7625. /**
  7626. * 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)).
  7627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7628. */
  7629. rotation: Vector3;
  7630. /**
  7631. * 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)).
  7632. */
  7633. scaling: Vector3;
  7634. /**
  7635. * 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).
  7636. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7637. */
  7638. rotationQuaternion: Nullable<Quaternion>;
  7639. /**
  7640. * The forward direction of that transform in world space.
  7641. */
  7642. readonly forward: Vector3;
  7643. /**
  7644. * The up direction of that transform in world space.
  7645. */
  7646. readonly up: Vector3;
  7647. /**
  7648. * The right direction of that transform in world space.
  7649. */
  7650. readonly right: Vector3;
  7651. /**
  7652. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7653. * @param matrix the matrix to copy the pose from
  7654. * @returns this TransformNode.
  7655. */
  7656. updatePoseMatrix(matrix: Matrix): TransformNode;
  7657. /**
  7658. * Returns the mesh Pose matrix.
  7659. * @returns the pose matrix
  7660. */
  7661. getPoseMatrix(): Matrix;
  7662. /** @hidden */
  7663. _isSynchronized(): boolean;
  7664. /** @hidden */
  7665. _initCache(): void;
  7666. /**
  7667. * Flag the transform node as dirty (Forcing it to update everything)
  7668. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7669. * @returns this transform node
  7670. */
  7671. markAsDirty(property: string): TransformNode;
  7672. /**
  7673. * Returns the current mesh absolute position.
  7674. * Returns a Vector3.
  7675. */
  7676. readonly absolutePosition: Vector3;
  7677. /**
  7678. * Sets a new matrix to apply before all other transformation
  7679. * @param matrix defines the transform matrix
  7680. * @returns the current TransformNode
  7681. */
  7682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7683. /**
  7684. * Sets a new pivot matrix to the current node
  7685. * @param matrix defines the new pivot matrix to use
  7686. * @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
  7687. * @returns the current TransformNode
  7688. */
  7689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7690. /**
  7691. * Returns the mesh pivot matrix.
  7692. * Default : Identity.
  7693. * @returns the matrix
  7694. */
  7695. getPivotMatrix(): Matrix;
  7696. /**
  7697. * Prevents the World matrix to be computed any longer.
  7698. * @returns the TransformNode.
  7699. */
  7700. freezeWorldMatrix(): TransformNode;
  7701. /**
  7702. * Allows back the World matrix computation.
  7703. * @returns the TransformNode.
  7704. */
  7705. unfreezeWorldMatrix(): this;
  7706. /**
  7707. * True if the World matrix has been frozen.
  7708. */
  7709. readonly isWorldMatrixFrozen: boolean;
  7710. /**
  7711. * Retuns the mesh absolute position in the World.
  7712. * @returns a Vector3.
  7713. */
  7714. getAbsolutePosition(): Vector3;
  7715. /**
  7716. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7717. * @param absolutePosition the absolute position to set
  7718. * @returns the TransformNode.
  7719. */
  7720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7721. /**
  7722. * Sets the mesh position in its local space.
  7723. * @param vector3 the position to set in localspace
  7724. * @returns the TransformNode.
  7725. */
  7726. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7727. /**
  7728. * Returns the mesh position in the local space from the current World matrix values.
  7729. * @returns a new Vector3.
  7730. */
  7731. getPositionExpressedInLocalSpace(): Vector3;
  7732. /**
  7733. * Translates the mesh along the passed Vector3 in its local space.
  7734. * @param vector3 the distance to translate in localspace
  7735. * @returns the TransformNode.
  7736. */
  7737. locallyTranslate(vector3: Vector3): TransformNode;
  7738. private static _lookAtVectorCache;
  7739. /**
  7740. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7741. * @param targetPoint the position (must be in same space as current mesh) to look at
  7742. * @param yawCor optional yaw (y-axis) correction in radians
  7743. * @param pitchCor optional pitch (x-axis) correction in radians
  7744. * @param rollCor optional roll (z-axis) correction in radians
  7745. * @param space the choosen space of the target
  7746. * @returns the TransformNode.
  7747. */
  7748. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7749. /**
  7750. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7751. * This Vector3 is expressed in the World space.
  7752. * @param localAxis axis to rotate
  7753. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7754. */
  7755. getDirection(localAxis: Vector3): Vector3;
  7756. /**
  7757. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7758. * localAxis is expressed in the mesh local space.
  7759. * result is computed in the Wordl space from the mesh World matrix.
  7760. * @param localAxis axis to rotate
  7761. * @param result the resulting transformnode
  7762. * @returns this TransformNode.
  7763. */
  7764. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7765. /**
  7766. * Sets this transform node rotation to the given local axis.
  7767. * @param localAxis the axis in local space
  7768. * @param yawCor optional yaw (y-axis) correction in radians
  7769. * @param pitchCor optional pitch (x-axis) correction in radians
  7770. * @param rollCor optional roll (z-axis) correction in radians
  7771. * @returns this TransformNode
  7772. */
  7773. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7774. /**
  7775. * Sets a new pivot point to the current node
  7776. * @param point defines the new pivot point to use
  7777. * @param space defines if the point is in world or local space (local by default)
  7778. * @returns the current TransformNode
  7779. */
  7780. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7781. /**
  7782. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7783. * @returns the pivot point
  7784. */
  7785. getPivotPoint(): Vector3;
  7786. /**
  7787. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7788. * @param result the vector3 to store the result
  7789. * @returns this TransformNode.
  7790. */
  7791. getPivotPointToRef(result: Vector3): TransformNode;
  7792. /**
  7793. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7794. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7795. */
  7796. getAbsolutePivotPoint(): Vector3;
  7797. /**
  7798. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7799. * @param result vector3 to store the result
  7800. * @returns this TransformNode.
  7801. */
  7802. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7803. /**
  7804. * Defines the passed node as the parent of the current node.
  7805. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7806. * @see https://doc.babylonjs.com/how_to/parenting
  7807. * @param node the node ot set as the parent
  7808. * @returns this TransformNode.
  7809. */
  7810. setParent(node: Nullable<Node>): TransformNode;
  7811. private _nonUniformScaling;
  7812. /**
  7813. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7814. */
  7815. readonly nonUniformScaling: boolean;
  7816. /** @hidden */
  7817. _updateNonUniformScalingState(value: boolean): boolean;
  7818. /**
  7819. * Attach the current TransformNode to another TransformNode associated with a bone
  7820. * @param bone Bone affecting the TransformNode
  7821. * @param affectedTransformNode TransformNode associated with the bone
  7822. * @returns this object
  7823. */
  7824. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7825. /**
  7826. * Detach the transform node if its associated with a bone
  7827. * @returns this object
  7828. */
  7829. detachFromBone(): TransformNode;
  7830. private static _rotationAxisCache;
  7831. /**
  7832. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7833. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7834. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7835. * The passed axis is also normalized.
  7836. * @param axis the axis to rotate around
  7837. * @param amount the amount to rotate in radians
  7838. * @param space Space to rotate in (Default: local)
  7839. * @returns the TransformNode.
  7840. */
  7841. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7842. /**
  7843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7844. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7845. * The passed axis is also normalized. .
  7846. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7847. * @param point the point to rotate around
  7848. * @param axis the axis to rotate around
  7849. * @param amount the amount to rotate in radians
  7850. * @returns the TransformNode
  7851. */
  7852. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7853. /**
  7854. * Translates the mesh along the axis vector for the passed distance in the given space.
  7855. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7856. * @param axis the axis to translate in
  7857. * @param distance the distance to translate
  7858. * @param space Space to rotate in (Default: local)
  7859. * @returns the TransformNode.
  7860. */
  7861. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7862. /**
  7863. * Adds a rotation step to the mesh current rotation.
  7864. * x, y, z are Euler angles expressed in radians.
  7865. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7866. * This means this rotation is made in the mesh local space only.
  7867. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7868. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7869. * ```javascript
  7870. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7871. * ```
  7872. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7873. * 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.
  7874. * @param x Rotation to add
  7875. * @param y Rotation to add
  7876. * @param z Rotation to add
  7877. * @returns the TransformNode.
  7878. */
  7879. addRotation(x: number, y: number, z: number): TransformNode;
  7880. /**
  7881. * Computes the world matrix of the node
  7882. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7883. * @returns the world matrix
  7884. */
  7885. computeWorldMatrix(force?: boolean): Matrix;
  7886. protected _afterComputeWorldMatrix(): void;
  7887. /**
  7888. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7889. * @param func callback function to add
  7890. *
  7891. * @returns the TransformNode.
  7892. */
  7893. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7894. /**
  7895. * Removes a registered callback function.
  7896. * @param func callback function to remove
  7897. * @returns the TransformNode.
  7898. */
  7899. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7900. /**
  7901. * Gets the position of the current mesh in camera space
  7902. * @param camera defines the camera to use
  7903. * @returns a position
  7904. */
  7905. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7906. /**
  7907. * Returns the distance from the mesh to the active camera
  7908. * @param camera defines the camera to use
  7909. * @returns the distance
  7910. */
  7911. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7912. /**
  7913. * Clone the current transform node
  7914. * @param name Name of the new clone
  7915. * @param newParent New parent for the clone
  7916. * @param doNotCloneChildren Do not clone children hierarchy
  7917. * @returns the new transform node
  7918. */
  7919. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7920. /**
  7921. * Serializes the objects information.
  7922. * @param currentSerializationObject defines the object to serialize in
  7923. * @returns the serialized object
  7924. */
  7925. serialize(currentSerializationObject?: any): any;
  7926. /**
  7927. * Returns a new TransformNode object parsed from the source provided.
  7928. * @param parsedTransformNode is the source.
  7929. * @param scene the scne the object belongs to
  7930. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7931. * @returns a new TransformNode object parsed from the source provided.
  7932. */
  7933. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7934. /**
  7935. * Get all child-transformNodes of this node
  7936. * @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
  7937. * @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
  7938. * @returns an array of TransformNode
  7939. */
  7940. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7941. /**
  7942. * Releases resources associated with this transform node.
  7943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7945. */
  7946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7947. }
  7948. }
  7949. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7950. /**
  7951. * Class used to override all child animations of a given target
  7952. */
  7953. export class AnimationPropertiesOverride {
  7954. /**
  7955. * Gets or sets a value indicating if animation blending must be used
  7956. */
  7957. enableBlending: boolean;
  7958. /**
  7959. * Gets or sets the blending speed to use when enableBlending is true
  7960. */
  7961. blendingSpeed: number;
  7962. /**
  7963. * Gets or sets the default loop mode to use
  7964. */
  7965. loopMode: number;
  7966. }
  7967. }
  7968. declare module "babylonjs/Bones/bone" {
  7969. import { Skeleton } from "babylonjs/Bones/skeleton";
  7970. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7971. import { Nullable } from "babylonjs/types";
  7972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7974. import { Node } from "babylonjs/node";
  7975. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7976. /**
  7977. * Class used to store bone information
  7978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7979. */
  7980. export class Bone extends Node {
  7981. /**
  7982. * defines the bone name
  7983. */
  7984. name: string;
  7985. private static _tmpVecs;
  7986. private static _tmpQuat;
  7987. private static _tmpMats;
  7988. /**
  7989. * Gets the list of child bones
  7990. */
  7991. children: Bone[];
  7992. /** Gets the animations associated with this bone */
  7993. animations: import("babylonjs/Animations/animation").Animation[];
  7994. /**
  7995. * Gets or sets bone length
  7996. */
  7997. length: number;
  7998. /**
  7999. * @hidden Internal only
  8000. * Set this value to map this bone to a different index in the transform matrices
  8001. * Set this value to -1 to exclude the bone from the transform matrices
  8002. */
  8003. _index: Nullable<number>;
  8004. private _skeleton;
  8005. private _localMatrix;
  8006. private _restPose;
  8007. private _baseMatrix;
  8008. private _absoluteTransform;
  8009. private _invertedAbsoluteTransform;
  8010. private _parent;
  8011. private _scalingDeterminant;
  8012. private _worldTransform;
  8013. private _localScaling;
  8014. private _localRotation;
  8015. private _localPosition;
  8016. private _needToDecompose;
  8017. private _needToCompose;
  8018. /** @hidden */
  8019. _linkedTransformNode: Nullable<TransformNode>;
  8020. /** @hidden */
  8021. /** @hidden */
  8022. _matrix: Matrix;
  8023. /**
  8024. * Create a new bone
  8025. * @param name defines the bone name
  8026. * @param skeleton defines the parent skeleton
  8027. * @param parentBone defines the parent (can be null if the bone is the root)
  8028. * @param localMatrix defines the local matrix
  8029. * @param restPose defines the rest pose matrix
  8030. * @param baseMatrix defines the base matrix
  8031. * @param index defines index of the bone in the hiearchy
  8032. */
  8033. constructor(
  8034. /**
  8035. * defines the bone name
  8036. */
  8037. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8038. /**
  8039. * Gets the current object class name.
  8040. * @return the class name
  8041. */
  8042. getClassName(): string;
  8043. /**
  8044. * Gets the parent skeleton
  8045. * @returns a skeleton
  8046. */
  8047. getSkeleton(): Skeleton;
  8048. /**
  8049. * Gets parent bone
  8050. * @returns a bone or null if the bone is the root of the bone hierarchy
  8051. */
  8052. getParent(): Nullable<Bone>;
  8053. /**
  8054. * Returns an array containing the root bones
  8055. * @returns an array containing the root bones
  8056. */
  8057. getChildren(): Array<Bone>;
  8058. /**
  8059. * Sets the parent bone
  8060. * @param parent defines the parent (can be null if the bone is the root)
  8061. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8062. */
  8063. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8064. /**
  8065. * Gets the local matrix
  8066. * @returns a matrix
  8067. */
  8068. getLocalMatrix(): Matrix;
  8069. /**
  8070. * Gets the base matrix (initial matrix which remains unchanged)
  8071. * @returns a matrix
  8072. */
  8073. getBaseMatrix(): Matrix;
  8074. /**
  8075. * Gets the rest pose matrix
  8076. * @returns a matrix
  8077. */
  8078. getRestPose(): Matrix;
  8079. /**
  8080. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8081. */
  8082. getWorldMatrix(): Matrix;
  8083. /**
  8084. * Sets the local matrix to rest pose matrix
  8085. */
  8086. returnToRest(): void;
  8087. /**
  8088. * Gets the inverse of the absolute transform matrix.
  8089. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8090. * @returns a matrix
  8091. */
  8092. getInvertedAbsoluteTransform(): Matrix;
  8093. /**
  8094. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8095. * @returns a matrix
  8096. */
  8097. getAbsoluteTransform(): Matrix;
  8098. /**
  8099. * Links with the given transform node.
  8100. * The local matrix of this bone is copied from the transform node every frame.
  8101. * @param transformNode defines the transform node to link to
  8102. */
  8103. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8104. /** Gets or sets current position (in local space) */
  8105. position: Vector3;
  8106. /** Gets or sets current rotation (in local space) */
  8107. rotation: Vector3;
  8108. /** Gets or sets current rotation quaternion (in local space) */
  8109. rotationQuaternion: Quaternion;
  8110. /** Gets or sets current scaling (in local space) */
  8111. scaling: Vector3;
  8112. /**
  8113. * Gets the animation properties override
  8114. */
  8115. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8116. private _decompose;
  8117. private _compose;
  8118. /**
  8119. * Update the base and local matrices
  8120. * @param matrix defines the new base or local matrix
  8121. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8122. * @param updateLocalMatrix defines if the local matrix should be updated
  8123. */
  8124. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8125. /** @hidden */
  8126. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8127. /**
  8128. * Flag the bone as dirty (Forcing it to update everything)
  8129. */
  8130. markAsDirty(): void;
  8131. private _markAsDirtyAndCompose;
  8132. private _markAsDirtyAndDecompose;
  8133. /**
  8134. * Translate the bone in local or world space
  8135. * @param vec The amount to translate the bone
  8136. * @param space The space that the translation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the postion of the bone in local or world space
  8142. * @param position The position to set the bone
  8143. * @param space The space that the position is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8147. /**
  8148. * Set the absolute position of the bone (world space)
  8149. * @param position The position to set the bone
  8150. * @param mesh The mesh that this bone is attached to
  8151. */
  8152. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8153. /**
  8154. * Scale the bone on the x, y and z axes (in local space)
  8155. * @param x The amount to scale the bone on the x axis
  8156. * @param y The amount to scale the bone on the y axis
  8157. * @param z The amount to scale the bone on the z axis
  8158. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8159. */
  8160. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8161. /**
  8162. * Set the bone scaling in local space
  8163. * @param scale defines the scaling vector
  8164. */
  8165. setScale(scale: Vector3): void;
  8166. /**
  8167. * Gets the current scaling in local space
  8168. * @returns the current scaling vector
  8169. */
  8170. getScale(): Vector3;
  8171. /**
  8172. * Gets the current scaling in local space and stores it in a target vector
  8173. * @param result defines the target vector
  8174. */
  8175. getScaleToRef(result: Vector3): void;
  8176. /**
  8177. * Set the yaw, pitch, and roll of the bone in local or world space
  8178. * @param yaw The rotation of the bone on the y axis
  8179. * @param pitch The rotation of the bone on the x axis
  8180. * @param roll The rotation of the bone on the z axis
  8181. * @param space The space that the axes of rotation are in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Add a rotation to the bone on an axis in local or world space
  8187. * @param axis The axis to rotate the bone on
  8188. * @param amount The amount to rotate the bone
  8189. * @param space The space that the axis is in
  8190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8191. */
  8192. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8193. /**
  8194. * Set the rotation of the bone to a particular axis angle in local or world space
  8195. * @param axis The axis to rotate the bone on
  8196. * @param angle The angle that the bone should be rotated to
  8197. * @param space The space that the axis is in
  8198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8199. */
  8200. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8201. /**
  8202. * Set the euler rotation of the bone in local of world space
  8203. * @param rotation The euler rotation that the bone should be set to
  8204. * @param space The space that the rotation is in
  8205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8206. */
  8207. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8208. /**
  8209. * Set the quaternion rotation of the bone in local of world space
  8210. * @param quat The quaternion rotation that the bone should be set to
  8211. * @param space The space that the rotation is in
  8212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8213. */
  8214. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8215. /**
  8216. * Set the rotation matrix of the bone in local of world space
  8217. * @param rotMat The rotation matrix that the bone should be set to
  8218. * @param space The space that the rotation is in
  8219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8220. */
  8221. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8222. private _rotateWithMatrix;
  8223. private _getNegativeRotationToRef;
  8224. /**
  8225. * Get the position of the bone in local or world space
  8226. * @param space The space that the returned position is in
  8227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8228. * @returns The position of the bone
  8229. */
  8230. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Copy the position of the bone to a vector3 in local or world space
  8233. * @param space The space that the returned position is in
  8234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8235. * @param result The vector3 to copy the position to
  8236. */
  8237. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8238. /**
  8239. * Get the absolute position of the bone (world space)
  8240. * @param mesh The mesh that this bone is attached to
  8241. * @returns The absolute position of the bone
  8242. */
  8243. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8244. /**
  8245. * Copy the absolute position of the bone (world space) to the result param
  8246. * @param mesh The mesh that this bone is attached to
  8247. * @param result The vector3 to copy the absolute position to
  8248. */
  8249. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8250. /**
  8251. * Compute the absolute transforms of this bone and its children
  8252. */
  8253. computeAbsoluteTransforms(): void;
  8254. /**
  8255. * Get the world direction from an axis that is in the local space of the bone
  8256. * @param localAxis The local direction that is used to compute the world direction
  8257. * @param mesh The mesh that this bone is attached to
  8258. * @returns The world direction
  8259. */
  8260. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8261. /**
  8262. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8263. * @param localAxis The local direction that is used to compute the world direction
  8264. * @param mesh The mesh that this bone is attached to
  8265. * @param result The vector3 that the world direction will be copied to
  8266. */
  8267. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8268. /**
  8269. * Get the euler rotation 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 euler rotation
  8273. */
  8274. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8275. /**
  8276. * Copy the euler rotation of the bone to a vector3. 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 vector3 that the rotation should be copied to
  8280. */
  8281. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8282. /**
  8283. * Get the quaternion rotation of the bone in either local or world space
  8284. * @param space The space that the rotation should be in
  8285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8286. * @returns The quaternion rotation
  8287. */
  8288. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8289. /**
  8290. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8291. * @param space The space that the rotation should be in
  8292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8293. * @param result The quaternion that the rotation should be copied to
  8294. */
  8295. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8296. /**
  8297. * Get the rotation matrix of the bone in local or world space
  8298. * @param space The space that the rotation should be in
  8299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8300. * @returns The rotation matrix
  8301. */
  8302. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8303. /**
  8304. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8305. * @param space The space that the rotation should be in
  8306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8307. * @param result The quaternion that the rotation should be copied to
  8308. */
  8309. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8310. /**
  8311. * Get the world position of a point that is in the local space of the bone
  8312. * @param position The local position
  8313. * @param mesh The mesh that this bone is attached to
  8314. * @returns The world position
  8315. */
  8316. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8317. /**
  8318. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8319. * @param position The local position
  8320. * @param mesh The mesh that this bone is attached to
  8321. * @param result The vector3 that the world position should be copied to
  8322. */
  8323. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8324. /**
  8325. * Get the local position of a point that is in world space
  8326. * @param position The world position
  8327. * @param mesh The mesh that this bone is attached to
  8328. * @returns The local position
  8329. */
  8330. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8331. /**
  8332. * Get the local position of a point that is in world space and copy it to the result param
  8333. * @param position The world position
  8334. * @param mesh The mesh that this bone is attached to
  8335. * @param result The vector3 that the local position should be copied to
  8336. */
  8337. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8338. }
  8339. }
  8340. declare module "babylonjs/Misc/iInspectable" {
  8341. /**
  8342. * Enum that determines the text-wrapping mode to use.
  8343. */
  8344. export enum InspectableType {
  8345. /**
  8346. * Checkbox for booleans
  8347. */
  8348. Checkbox = 0,
  8349. /**
  8350. * Sliders for numbers
  8351. */
  8352. Slider = 1,
  8353. /**
  8354. * Vector3
  8355. */
  8356. Vector3 = 2,
  8357. /**
  8358. * Quaternions
  8359. */
  8360. Quaternion = 3,
  8361. /**
  8362. * Color3
  8363. */
  8364. Color3 = 4
  8365. }
  8366. /**
  8367. * Interface used to define custom inspectable properties.
  8368. * This interface is used by the inspector to display custom property grids
  8369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8370. */
  8371. export interface IInspectable {
  8372. /**
  8373. * Gets the label to display
  8374. */
  8375. label: string;
  8376. /**
  8377. * Gets the name of the property to edit
  8378. */
  8379. propertyName: string;
  8380. /**
  8381. * Gets the type of the editor to use
  8382. */
  8383. type: InspectableType;
  8384. /**
  8385. * Gets the minimum value of the property when using in "slider" mode
  8386. */
  8387. min?: number;
  8388. /**
  8389. * Gets the maximum value of the property when using in "slider" mode
  8390. */
  8391. max?: number;
  8392. /**
  8393. * Gets the setp to use when using in "slider" mode
  8394. */
  8395. step?: number;
  8396. }
  8397. }
  8398. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8399. import { Nullable } from "babylonjs/types";
  8400. import { Scene } from "babylonjs/scene";
  8401. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8403. /**
  8404. * Class for creating a cube texture
  8405. */
  8406. export class CubeTexture extends BaseTexture {
  8407. private _delayedOnLoad;
  8408. /**
  8409. * The url of the texture
  8410. */
  8411. url: string;
  8412. /**
  8413. * Gets or sets the center of the bounding box associated with the cube texture.
  8414. * It must define where the camera used to render the texture was set
  8415. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8416. */
  8417. boundingBoxPosition: Vector3;
  8418. private _boundingBoxSize;
  8419. /**
  8420. * Gets or sets the size of the bounding box associated with the cube texture
  8421. * When defined, the cubemap will switch to local mode
  8422. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8423. * @example https://www.babylonjs-playground.com/#RNASML
  8424. */
  8425. /**
  8426. * Returns the bounding box size
  8427. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8428. */
  8429. boundingBoxSize: Vector3;
  8430. protected _rotationY: number;
  8431. /**
  8432. * Sets texture matrix rotation angle around Y axis in radians.
  8433. */
  8434. /**
  8435. * Gets texture matrix rotation angle around Y axis radians.
  8436. */
  8437. rotationY: number;
  8438. /**
  8439. * Are mip maps generated for this texture or not.
  8440. */
  8441. readonly noMipmap: boolean;
  8442. private _noMipmap;
  8443. private _files;
  8444. private _extensions;
  8445. private _textureMatrix;
  8446. private _format;
  8447. private _createPolynomials;
  8448. /** @hidden */
  8449. _prefiltered: boolean;
  8450. /**
  8451. * Creates a cube texture from an array of image urls
  8452. * @param files defines an array of image urls
  8453. * @param scene defines the hosting scene
  8454. * @param noMipmap specifies if mip maps are not used
  8455. * @returns a cube texture
  8456. */
  8457. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8458. /**
  8459. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8460. * @param url defines the url of the prefiltered texture
  8461. * @param scene defines the scene the texture is attached to
  8462. * @param forcedExtension defines the extension of the file if different from the url
  8463. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8464. * @return the prefiltered texture
  8465. */
  8466. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8467. /**
  8468. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8469. * as prefiltered data.
  8470. * @param rootUrl defines the url of the texture or the root name of the six images
  8471. * @param scene defines the scene the texture is attached to
  8472. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8473. * @param noMipmap defines if mipmaps should be created or not
  8474. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8475. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8476. * @param onError defines a callback triggered in case of error during load
  8477. * @param format defines the internal format to use for the texture once loaded
  8478. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8479. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8480. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8481. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8482. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8483. * @return the cube texture
  8484. */
  8485. 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);
  8486. /**
  8487. * Get the current class name of the texture useful for serialization or dynamic coding.
  8488. * @returns "CubeTexture"
  8489. */
  8490. getClassName(): string;
  8491. /**
  8492. * Update the url (and optional buffer) of this texture if url was null during construction.
  8493. * @param url the url of the texture
  8494. * @param forcedExtension defines the extension to use
  8495. * @param onLoad callback called when the texture is loaded (defaults to null)
  8496. */
  8497. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8498. /**
  8499. * Delays loading of the cube texture
  8500. * @param forcedExtension defines the extension to use
  8501. */
  8502. delayLoad(forcedExtension?: string): void;
  8503. /**
  8504. * Returns the reflection texture matrix
  8505. * @returns the reflection texture matrix
  8506. */
  8507. getReflectionTextureMatrix(): Matrix;
  8508. /**
  8509. * Sets the reflection texture matrix
  8510. * @param value Reflection texture matrix
  8511. */
  8512. setReflectionTextureMatrix(value: Matrix): void;
  8513. /**
  8514. * Parses text to create a cube texture
  8515. * @param parsedTexture define the serialized text to read from
  8516. * @param scene defines the hosting scene
  8517. * @param rootUrl defines the root url of the cube texture
  8518. * @returns a cube texture
  8519. */
  8520. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8521. /**
  8522. * Makes a clone, or deep copy, of the cube texture
  8523. * @returns a new cube texture
  8524. */
  8525. clone(): CubeTexture;
  8526. }
  8527. }
  8528. declare module "babylonjs/Shaders/postprocess.vertex" {
  8529. /** @hidden */
  8530. export var postprocessVertexShader: {
  8531. name: string;
  8532. shader: string;
  8533. };
  8534. }
  8535. declare module "babylonjs/Cameras/targetCamera" {
  8536. import { Nullable } from "babylonjs/types";
  8537. import { Camera } from "babylonjs/Cameras/camera";
  8538. import { Scene } from "babylonjs/scene";
  8539. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8540. /**
  8541. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8542. * This is the base of the follow, arc rotate cameras and Free camera
  8543. * @see http://doc.babylonjs.com/features/cameras
  8544. */
  8545. export class TargetCamera extends Camera {
  8546. private static _RigCamTransformMatrix;
  8547. private static _TargetTransformMatrix;
  8548. private static _TargetFocalPoint;
  8549. /**
  8550. * Define the current direction the camera is moving to
  8551. */
  8552. cameraDirection: Vector3;
  8553. /**
  8554. * Define the current rotation the camera is rotating to
  8555. */
  8556. cameraRotation: Vector2;
  8557. /**
  8558. * When set, the up vector of the camera will be updated by the rotation of the camera
  8559. */
  8560. updateUpVectorFromRotation: boolean;
  8561. private _tmpQuaternion;
  8562. /**
  8563. * Define the current rotation of the camera
  8564. */
  8565. rotation: Vector3;
  8566. /**
  8567. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8568. */
  8569. rotationQuaternion: Quaternion;
  8570. /**
  8571. * Define the current speed of the camera
  8572. */
  8573. speed: number;
  8574. /**
  8575. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8576. * around all axis.
  8577. */
  8578. noRotationConstraint: boolean;
  8579. /**
  8580. * Define the current target of the camera as an object or a position.
  8581. */
  8582. lockedTarget: any;
  8583. /** @hidden */
  8584. _currentTarget: Vector3;
  8585. /** @hidden */
  8586. _initialFocalDistance: number;
  8587. /** @hidden */
  8588. _viewMatrix: Matrix;
  8589. /** @hidden */
  8590. _camMatrix: Matrix;
  8591. /** @hidden */
  8592. _cameraTransformMatrix: Matrix;
  8593. /** @hidden */
  8594. _cameraRotationMatrix: Matrix;
  8595. /** @hidden */
  8596. _referencePoint: Vector3;
  8597. /** @hidden */
  8598. _transformedReferencePoint: Vector3;
  8599. protected _globalCurrentTarget: Vector3;
  8600. protected _globalCurrentUpVector: Vector3;
  8601. /** @hidden */
  8602. _reset: () => void;
  8603. private _defaultUp;
  8604. /**
  8605. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8606. * This is the base of the follow, arc rotate cameras and Free camera
  8607. * @see http://doc.babylonjs.com/features/cameras
  8608. * @param name Defines the name of the camera in the scene
  8609. * @param position Defines the start position of the camera in the scene
  8610. * @param scene Defines the scene the camera belongs to
  8611. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8612. */
  8613. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8614. /**
  8615. * Gets the position in front of the camera at a given distance.
  8616. * @param distance The distance from the camera we want the position to be
  8617. * @returns the position
  8618. */
  8619. getFrontPosition(distance: number): Vector3;
  8620. /** @hidden */
  8621. _getLockedTargetPosition(): Nullable<Vector3>;
  8622. private _storedPosition;
  8623. private _storedRotation;
  8624. private _storedRotationQuaternion;
  8625. /**
  8626. * Store current camera state of the camera (fov, position, rotation, etc..)
  8627. * @returns the camera
  8628. */
  8629. storeState(): Camera;
  8630. /**
  8631. * Restored camera state. You must call storeState() first
  8632. * @returns whether it was successful or not
  8633. * @hidden
  8634. */
  8635. _restoreStateValues(): boolean;
  8636. /** @hidden */
  8637. _initCache(): void;
  8638. /** @hidden */
  8639. _updateCache(ignoreParentClass?: boolean): void;
  8640. /** @hidden */
  8641. _isSynchronizedViewMatrix(): boolean;
  8642. /** @hidden */
  8643. _computeLocalCameraSpeed(): number;
  8644. /**
  8645. * Defines the target the camera should look at.
  8646. * This will automatically adapt alpha beta and radius to fit within the new target.
  8647. * @param target Defines the new target as a Vector or a mesh
  8648. */
  8649. setTarget(target: Vector3): void;
  8650. /**
  8651. * Return the current target position of the camera. This value is expressed in local space.
  8652. * @returns the target position
  8653. */
  8654. getTarget(): Vector3;
  8655. /** @hidden */
  8656. _decideIfNeedsToMove(): boolean;
  8657. /** @hidden */
  8658. _updatePosition(): void;
  8659. /** @hidden */
  8660. _checkInputs(): void;
  8661. protected _updateCameraRotationMatrix(): void;
  8662. /**
  8663. * 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)
  8664. * @returns the current camera
  8665. */
  8666. private _rotateUpVectorWithCameraRotationMatrix;
  8667. private _cachedRotationZ;
  8668. private _cachedQuaternionRotationZ;
  8669. /** @hidden */
  8670. _getViewMatrix(): Matrix;
  8671. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8672. /**
  8673. * @hidden
  8674. */
  8675. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8676. /**
  8677. * @hidden
  8678. */
  8679. _updateRigCameras(): void;
  8680. private _getRigCamPositionAndTarget;
  8681. /**
  8682. * Gets the current object class name.
  8683. * @return the class name
  8684. */
  8685. getClassName(): string;
  8686. }
  8687. }
  8688. declare module "babylonjs/Cameras/cameraInputsManager" {
  8689. import { Nullable } from "babylonjs/types";
  8690. import { Camera } from "babylonjs/Cameras/camera";
  8691. /**
  8692. * @ignore
  8693. * This is a list of all the different input types that are available in the application.
  8694. * Fo instance: ArcRotateCameraGamepadInput...
  8695. */
  8696. export var CameraInputTypes: {};
  8697. /**
  8698. * This is the contract to implement in order to create a new input class.
  8699. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8700. */
  8701. export interface ICameraInput<TCamera extends Camera> {
  8702. /**
  8703. * Defines the camera the input is attached to.
  8704. */
  8705. camera: Nullable<TCamera>;
  8706. /**
  8707. * Gets the class name of the current intput.
  8708. * @returns the class name
  8709. */
  8710. getClassName(): string;
  8711. /**
  8712. * Get the friendly name associated with the input class.
  8713. * @returns the input friendly name
  8714. */
  8715. getSimpleName(): string;
  8716. /**
  8717. * Attach the input controls to a specific dom element to get the input from.
  8718. * @param element Defines the element the controls should be listened from
  8719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8720. */
  8721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8722. /**
  8723. * Detach the current controls from the specified dom element.
  8724. * @param element Defines the element to stop listening the inputs from
  8725. */
  8726. detachControl(element: Nullable<HTMLElement>): void;
  8727. /**
  8728. * Update the current camera state depending on the inputs that have been used this frame.
  8729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8730. */
  8731. checkInputs?: () => void;
  8732. }
  8733. /**
  8734. * Represents a map of input types to input instance or input index to input instance.
  8735. */
  8736. export interface CameraInputsMap<TCamera extends Camera> {
  8737. /**
  8738. * Accessor to the input by input type.
  8739. */
  8740. [name: string]: ICameraInput<TCamera>;
  8741. /**
  8742. * Accessor to the input by input index.
  8743. */
  8744. [idx: number]: ICameraInput<TCamera>;
  8745. }
  8746. /**
  8747. * This represents the input manager used within a camera.
  8748. * It helps dealing with all the different kind of input attached to a camera.
  8749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8750. */
  8751. export class CameraInputsManager<TCamera extends Camera> {
  8752. /**
  8753. * Defines the list of inputs attahed to the camera.
  8754. */
  8755. attached: CameraInputsMap<TCamera>;
  8756. /**
  8757. * Defines the dom element the camera is collecting inputs from.
  8758. * This is null if the controls have not been attached.
  8759. */
  8760. attachedElement: Nullable<HTMLElement>;
  8761. /**
  8762. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. noPreventDefault: boolean;
  8765. /**
  8766. * Defined the camera the input manager belongs to.
  8767. */
  8768. camera: TCamera;
  8769. /**
  8770. * Update the current camera state depending on the inputs that have been used this frame.
  8771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8772. */
  8773. checkInputs: () => void;
  8774. /**
  8775. * Instantiate a new Camera Input Manager.
  8776. * @param camera Defines the camera the input manager blongs to
  8777. */
  8778. constructor(camera: TCamera);
  8779. /**
  8780. * Add an input method to a camera
  8781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8782. * @param input camera input method
  8783. */
  8784. add(input: ICameraInput<TCamera>): void;
  8785. /**
  8786. * Remove a specific input method from a camera
  8787. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8788. * @param inputToRemove camera input method
  8789. */
  8790. remove(inputToRemove: ICameraInput<TCamera>): void;
  8791. /**
  8792. * Remove a specific input type from a camera
  8793. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8794. * @param inputType the type of the input to remove
  8795. */
  8796. removeByType(inputType: string): void;
  8797. private _addCheckInputs;
  8798. /**
  8799. * Attach the input controls to the currently attached dom element to listen the events from.
  8800. * @param input Defines the input to attach
  8801. */
  8802. attachInput(input: ICameraInput<TCamera>): void;
  8803. /**
  8804. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8805. * @param element Defines the dom element to collect the events from
  8806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8807. */
  8808. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8809. /**
  8810. * Detach the current manager inputs controls from a specific dom element.
  8811. * @param element Defines the dom element to collect the events from
  8812. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8813. */
  8814. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8815. /**
  8816. * Rebuild the dynamic inputCheck function from the current list of
  8817. * defined inputs in the manager.
  8818. */
  8819. rebuildInputCheck(): void;
  8820. /**
  8821. * Remove all attached input methods from a camera
  8822. */
  8823. clear(): void;
  8824. /**
  8825. * Serialize the current input manager attached to a camera.
  8826. * This ensures than once parsed,
  8827. * the input associated to the camera will be identical to the current ones
  8828. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8829. */
  8830. serialize(serializedCamera: any): void;
  8831. /**
  8832. * Parses an input manager serialized JSON to restore the previous list of inputs
  8833. * and states associated to a camera.
  8834. * @param parsedCamera Defines the JSON to parse
  8835. */
  8836. parse(parsedCamera: any): void;
  8837. }
  8838. }
  8839. declare module "babylonjs/Events/keyboardEvents" {
  8840. /**
  8841. * Gather the list of keyboard event types as constants.
  8842. */
  8843. export class KeyboardEventTypes {
  8844. /**
  8845. * The keydown event is fired when a key becomes active (pressed).
  8846. */
  8847. static readonly KEYDOWN: number;
  8848. /**
  8849. * The keyup event is fired when a key has been released.
  8850. */
  8851. static readonly KEYUP: number;
  8852. }
  8853. /**
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. */
  8856. export class KeyboardInfo {
  8857. /**
  8858. * Defines the type of event (KeyboardEventTypes)
  8859. */
  8860. type: number;
  8861. /**
  8862. * Defines the related dom event
  8863. */
  8864. event: KeyboardEvent;
  8865. /**
  8866. * Instantiates a new keyboard info.
  8867. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8868. * @param type Defines the type of event (KeyboardEventTypes)
  8869. * @param event Defines the related dom event
  8870. */
  8871. constructor(
  8872. /**
  8873. * Defines the type of event (KeyboardEventTypes)
  8874. */
  8875. type: number,
  8876. /**
  8877. * Defines the related dom event
  8878. */
  8879. event: KeyboardEvent);
  8880. }
  8881. /**
  8882. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8883. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8884. */
  8885. export class KeyboardInfoPre extends KeyboardInfo {
  8886. /**
  8887. * Defines the type of event (KeyboardEventTypes)
  8888. */
  8889. type: number;
  8890. /**
  8891. * Defines the related dom event
  8892. */
  8893. event: KeyboardEvent;
  8894. /**
  8895. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8896. */
  8897. skipOnPointerObservable: boolean;
  8898. /**
  8899. * Instantiates a new keyboard pre info.
  8900. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8901. * @param type Defines the type of event (KeyboardEventTypes)
  8902. * @param event Defines the related dom event
  8903. */
  8904. constructor(
  8905. /**
  8906. * Defines the type of event (KeyboardEventTypes)
  8907. */
  8908. type: number,
  8909. /**
  8910. * Defines the related dom event
  8911. */
  8912. event: KeyboardEvent);
  8913. }
  8914. }
  8915. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8916. import { Nullable } from "babylonjs/types";
  8917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8919. /**
  8920. * Manage the keyboard inputs to control the movement of a free camera.
  8921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8922. */
  8923. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8924. /**
  8925. * Defines the camera the input is attached to.
  8926. */
  8927. camera: FreeCamera;
  8928. /**
  8929. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8930. */
  8931. keysUp: number[];
  8932. /**
  8933. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8934. */
  8935. keysDown: number[];
  8936. /**
  8937. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8938. */
  8939. keysLeft: number[];
  8940. /**
  8941. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8942. */
  8943. keysRight: number[];
  8944. private _keys;
  8945. private _onCanvasBlurObserver;
  8946. private _onKeyboardObserver;
  8947. private _engine;
  8948. private _scene;
  8949. /**
  8950. * Attach the input controls to a specific dom element to get the input from.
  8951. * @param element Defines the element the controls should be listened from
  8952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8953. */
  8954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8955. /**
  8956. * Detach the current controls from the specified dom element.
  8957. * @param element Defines the element to stop listening the inputs from
  8958. */
  8959. detachControl(element: Nullable<HTMLElement>): void;
  8960. /**
  8961. * Update the current camera state depending on the inputs that have been used this frame.
  8962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8963. */
  8964. checkInputs(): void;
  8965. /**
  8966. * Gets the class name of the current intput.
  8967. * @returns the class name
  8968. */
  8969. getClassName(): string;
  8970. /** @hidden */
  8971. _onLostFocus(): void;
  8972. /**
  8973. * Get the friendly name associated with the input class.
  8974. * @returns the input friendly name
  8975. */
  8976. getSimpleName(): string;
  8977. }
  8978. }
  8979. declare module "babylonjs/Lights/shadowLight" {
  8980. import { Camera } from "babylonjs/Cameras/camera";
  8981. import { Scene } from "babylonjs/scene";
  8982. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8984. import { Light } from "babylonjs/Lights/light";
  8985. /**
  8986. * Interface describing all the common properties and methods a shadow light needs to implement.
  8987. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8988. * as well as binding the different shadow properties to the effects.
  8989. */
  8990. export interface IShadowLight extends Light {
  8991. /**
  8992. * The light id in the scene (used in scene.findLighById for instance)
  8993. */
  8994. id: string;
  8995. /**
  8996. * The position the shdow will be casted from.
  8997. */
  8998. position: Vector3;
  8999. /**
  9000. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9001. */
  9002. direction: Vector3;
  9003. /**
  9004. * The transformed position. Position of the light in world space taking parenting in account.
  9005. */
  9006. transformedPosition: Vector3;
  9007. /**
  9008. * The transformed direction. Direction of the light in world space taking parenting in account.
  9009. */
  9010. transformedDirection: Vector3;
  9011. /**
  9012. * The friendly name of the light in the scene.
  9013. */
  9014. name: string;
  9015. /**
  9016. * Defines the shadow projection clipping minimum z value.
  9017. */
  9018. shadowMinZ: number;
  9019. /**
  9020. * Defines the shadow projection clipping maximum z value.
  9021. */
  9022. shadowMaxZ: number;
  9023. /**
  9024. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9025. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9026. */
  9027. computeTransformedInformation(): boolean;
  9028. /**
  9029. * Gets the scene the light belongs to.
  9030. * @returns The scene
  9031. */
  9032. getScene(): Scene;
  9033. /**
  9034. * Callback defining a custom Projection Matrix Builder.
  9035. * This can be used to override the default projection matrix computation.
  9036. */
  9037. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9038. /**
  9039. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9040. * @param matrix The materix to updated with the projection information
  9041. * @param viewMatrix The transform matrix of the light
  9042. * @param renderList The list of mesh to render in the map
  9043. * @returns The current light
  9044. */
  9045. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9046. /**
  9047. * Gets the current depth scale used in ESM.
  9048. * @returns The scale
  9049. */
  9050. getDepthScale(): number;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Gets the minZ used for shadow according to both the scene and the light.
  9073. * @param activeCamera The camera we are returning the min for
  9074. * @returns the depth min z
  9075. */
  9076. getDepthMinZ(activeCamera: Camera): number;
  9077. /**
  9078. * Gets the maxZ used for shadow according to both the scene and the light.
  9079. * @param activeCamera The camera we are returning the max for
  9080. * @returns the depth max z
  9081. */
  9082. getDepthMaxZ(activeCamera: Camera): number;
  9083. }
  9084. /**
  9085. * Base implementation IShadowLight
  9086. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9087. */
  9088. export abstract class ShadowLight extends Light implements IShadowLight {
  9089. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9090. protected _position: Vector3;
  9091. protected _setPosition(value: Vector3): void;
  9092. /**
  9093. * Sets the position the shadow will be casted from. Also use as the light position for both
  9094. * point and spot lights.
  9095. */
  9096. /**
  9097. * Sets the position the shadow will be casted from. Also use as the light position for both
  9098. * point and spot lights.
  9099. */
  9100. position: Vector3;
  9101. protected _direction: Vector3;
  9102. protected _setDirection(value: Vector3): void;
  9103. /**
  9104. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9105. * Also use as the light direction on spot and directional lights.
  9106. */
  9107. /**
  9108. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9109. * Also use as the light direction on spot and directional lights.
  9110. */
  9111. direction: Vector3;
  9112. private _shadowMinZ;
  9113. /**
  9114. * Gets the shadow projection clipping minimum z value.
  9115. */
  9116. /**
  9117. * Sets the shadow projection clipping minimum z value.
  9118. */
  9119. shadowMinZ: number;
  9120. private _shadowMaxZ;
  9121. /**
  9122. * Sets the shadow projection clipping maximum z value.
  9123. */
  9124. /**
  9125. * Gets the shadow projection clipping maximum z value.
  9126. */
  9127. shadowMaxZ: number;
  9128. /**
  9129. * Callback defining a custom Projection Matrix Builder.
  9130. * This can be used to override the default projection matrix computation.
  9131. */
  9132. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9133. /**
  9134. * The transformed position. Position of the light in world space taking parenting in account.
  9135. */
  9136. transformedPosition: Vector3;
  9137. /**
  9138. * The transformed direction. Direction of the light in world space taking parenting in account.
  9139. */
  9140. transformedDirection: Vector3;
  9141. private _needProjectionMatrixCompute;
  9142. /**
  9143. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9144. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9145. */
  9146. computeTransformedInformation(): boolean;
  9147. /**
  9148. * Return the depth scale used for the shadow map.
  9149. * @returns the depth scale.
  9150. */
  9151. getDepthScale(): number;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Returns the ShadowLight absolute position in the World.
  9160. * @returns the position vector in world space
  9161. */
  9162. getAbsolutePosition(): Vector3;
  9163. /**
  9164. * Sets the ShadowLight direction toward the passed target.
  9165. * @param target The point to target in local space
  9166. * @returns the updated ShadowLight direction
  9167. */
  9168. setDirectionToTarget(target: Vector3): Vector3;
  9169. /**
  9170. * Returns the light rotation in euler definition.
  9171. * @returns the x y z rotation in local space.
  9172. */
  9173. getRotation(): Vector3;
  9174. /**
  9175. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9176. * @returns true if a cube texture needs to be use
  9177. */
  9178. needCube(): boolean;
  9179. /**
  9180. * Detects if the projection matrix requires to be recomputed this frame.
  9181. * @returns true if it requires to be recomputed otherwise, false.
  9182. */
  9183. needProjectionMatrixCompute(): boolean;
  9184. /**
  9185. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9186. */
  9187. forceProjectionMatrixCompute(): void;
  9188. /** @hidden */
  9189. _initCache(): void;
  9190. /** @hidden */
  9191. _isSynchronized(): boolean;
  9192. /**
  9193. * Computes the world matrix of the node
  9194. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9195. * @returns the world matrix
  9196. */
  9197. computeWorldMatrix(force?: boolean): Matrix;
  9198. /**
  9199. * Gets the minZ used for shadow according to both the scene and the light.
  9200. * @param activeCamera The camera we are returning the min for
  9201. * @returns the depth min z
  9202. */
  9203. getDepthMinZ(activeCamera: Camera): number;
  9204. /**
  9205. * Gets the maxZ used for shadow according to both the scene and the light.
  9206. * @param activeCamera The camera we are returning the max for
  9207. * @returns the depth max z
  9208. */
  9209. getDepthMaxZ(activeCamera: Camera): number;
  9210. /**
  9211. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9212. * @param matrix The materix to updated with the projection information
  9213. * @param viewMatrix The transform matrix of the light
  9214. * @param renderList The list of mesh to render in the map
  9215. * @returns The current light
  9216. */
  9217. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9218. }
  9219. }
  9220. declare module "babylonjs/Materials/materialHelper" {
  9221. import { Nullable } from "babylonjs/types";
  9222. import { Scene } from "babylonjs/scene";
  9223. import { Engine } from "babylonjs/Engines/engine";
  9224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9225. import { Light } from "babylonjs/Lights/light";
  9226. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9227. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9229. /**
  9230. * "Static Class" containing the most commonly used helper while dealing with material for
  9231. * rendering purpose.
  9232. *
  9233. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9234. *
  9235. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9236. */
  9237. export class MaterialHelper {
  9238. /**
  9239. * Bind the current view position to an effect.
  9240. * @param effect The effect to be bound
  9241. * @param scene The scene the eyes position is used from
  9242. */
  9243. static BindEyePosition(effect: Effect, scene: Scene): void;
  9244. /**
  9245. * Helps preparing the defines values about the UVs in used in the effect.
  9246. * UVs are shared as much as we can accross channels in the shaders.
  9247. * @param texture The texture we are preparing the UVs for
  9248. * @param defines The defines to update
  9249. * @param key The channel key "diffuse", "specular"... used in the shader
  9250. */
  9251. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9252. /**
  9253. * Binds a texture matrix value to its corrsponding uniform
  9254. * @param texture The texture to bind the matrix for
  9255. * @param uniformBuffer The uniform buffer receivin the data
  9256. * @param key The channel key "diffuse", "specular"... used in the shader
  9257. */
  9258. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9259. /**
  9260. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9261. * @param mesh defines the current mesh
  9262. * @param scene defines the current scene
  9263. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9264. * @param pointsCloud defines if point cloud rendering has to be turned on
  9265. * @param fogEnabled defines if fog has to be turned on
  9266. * @param alphaTest defines if alpha testing has to be turned on
  9267. * @param defines defines the current list of defines
  9268. */
  9269. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9270. /**
  9271. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9272. * @param scene defines the current scene
  9273. * @param engine defines the current engine
  9274. * @param defines specifies the list of active defines
  9275. * @param useInstances defines if instances have to be turned on
  9276. * @param useClipPlane defines if clip plane have to be turned on
  9277. */
  9278. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9279. /**
  9280. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9281. * @param mesh The mesh containing the geometry data we will draw
  9282. * @param defines The defines to update
  9283. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9284. * @param useBones Precise whether bones should be used or not (override mesh info)
  9285. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9286. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9287. * @returns false if defines are considered not dirty and have not been checked
  9288. */
  9289. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9290. /**
  9291. * Prepares the defines related to multiview
  9292. * @param scene The scene we are intending to draw
  9293. * @param defines The defines to update
  9294. */
  9295. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9296. /**
  9297. * Prepares the defines related to the light information passed in parameter
  9298. * @param scene The scene we are intending to draw
  9299. * @param mesh The mesh the effect is compiling for
  9300. * @param defines The defines to update
  9301. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9302. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9303. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9304. * @returns true if normals will be required for the rest of the effect
  9305. */
  9306. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9307. /**
  9308. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9309. * that won t be acctive due to defines being turned off.
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The samplers list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. /**
  9326. * Prepares the list of attributes required for morph targets according to the effect defines.
  9327. * @param attribs The current list of supported attribs
  9328. * @param mesh The mesh to prepare the morph targets attributes for
  9329. * @param defines The current Defines of the effect
  9330. */
  9331. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9332. /**
  9333. * Prepares the list of attributes required for bones according to the effect defines.
  9334. * @param attribs The current list of supported attribs
  9335. * @param mesh The mesh to prepare the bones attributes for
  9336. * @param defines The current Defines of the effect
  9337. * @param fallbacks The current efffect fallback strategy
  9338. */
  9339. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9340. /**
  9341. * Prepares the list of attributes required for instances according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param defines The current Defines of the effect
  9344. */
  9345. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9346. /**
  9347. * Binds the light shadow information to the effect for the given mesh.
  9348. * @param light The light containing the generator
  9349. * @param scene The scene the lights belongs to
  9350. * @param mesh The mesh we are binding the information to render
  9351. * @param lightIndex The light index in the effect used to render the mesh
  9352. * @param effect The effect we are binding the data to
  9353. */
  9354. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9355. /**
  9356. * Binds the light information to the effect.
  9357. * @param light The light containing the generator
  9358. * @param effect The effect we are binding the data to
  9359. * @param lightIndex The light index in the effect used to render
  9360. */
  9361. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9362. /**
  9363. * Binds the lights information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param defines The generated defines for the effect
  9368. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9369. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9370. */
  9371. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9372. private static _tempFogColor;
  9373. /**
  9374. * Binds the fog information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param linearSpace Defines if the fog effect is applied in linear space
  9379. */
  9380. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9381. /**
  9382. * Binds the bones information from the mesh to the effect.
  9383. * @param mesh The mesh we are binding the information to render
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9387. /**
  9388. * Binds the morph targets information from the mesh to the effect.
  9389. * @param abstractMesh The mesh we are binding the information to render
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9393. /**
  9394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9395. * @param defines The generated defines used in the effect
  9396. * @param effect The effect we are binding the data to
  9397. * @param scene The scene we are willing to render with logarithmic scale for
  9398. */
  9399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9400. /**
  9401. * Binds the clip plane information from the scene to the effect.
  9402. * @param scene The scene the clip plane information are extracted from
  9403. * @param effect The effect we are binding the data to
  9404. */
  9405. static BindClipPlane(effect: Effect, scene: Scene): void;
  9406. }
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9409. /** @hidden */
  9410. export var kernelBlurVaryingDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9416. /** @hidden */
  9417. export var kernelBlurFragment: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9423. /** @hidden */
  9424. export var kernelBlurFragment2: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9430. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9431. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9432. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9433. /** @hidden */
  9434. export var kernelBlurPixelShader: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9440. /** @hidden */
  9441. export var kernelBlurVertex: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9447. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9449. /** @hidden */
  9450. export var kernelBlurVertexShader: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9456. import { Vector2 } from "babylonjs/Maths/math";
  9457. import { Nullable } from "babylonjs/types";
  9458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9459. import { Camera } from "babylonjs/Cameras/camera";
  9460. import { Effect } from "babylonjs/Materials/effect";
  9461. import { Engine } from "babylonjs/Engines/engine";
  9462. import "babylonjs/Shaders/kernelBlur.fragment";
  9463. import "babylonjs/Shaders/kernelBlur.vertex";
  9464. /**
  9465. * The Blur Post Process which blurs an image based on a kernel and direction.
  9466. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9467. */
  9468. export class BlurPostProcess extends PostProcess {
  9469. /** The direction in which to blur the image. */
  9470. direction: Vector2;
  9471. private blockCompilation;
  9472. protected _kernel: number;
  9473. protected _idealKernel: number;
  9474. protected _packedFloat: boolean;
  9475. private _staticDefines;
  9476. /**
  9477. * Sets the length in pixels of the blur sample region
  9478. */
  9479. /**
  9480. * Gets the length in pixels of the blur sample region
  9481. */
  9482. kernel: number;
  9483. /**
  9484. * Sets wether or not the blur needs to unpack/repack floats
  9485. */
  9486. /**
  9487. * Gets wether or not the blur is unpacking/repacking floats
  9488. */
  9489. packedFloat: boolean;
  9490. /**
  9491. * Creates a new instance BlurPostProcess
  9492. * @param name The name of the effect.
  9493. * @param direction The direction in which to blur the image.
  9494. * @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.
  9495. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9496. * @param camera The camera to apply the render pass to.
  9497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9498. * @param engine The engine which the post process will be applied. (default: current engine)
  9499. * @param reusable If the post process can be reused on the same frame. (default: false)
  9500. * @param textureType Type of textures used when performing the post process. (default: 0)
  9501. * @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)
  9502. */
  9503. constructor(name: string,
  9504. /** The direction in which to blur the image. */
  9505. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9506. /**
  9507. * Updates the effect with the current post process compile time values and recompiles the shader.
  9508. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9509. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9510. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9511. * @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
  9512. * @param onCompiled Called when the shader has been compiled.
  9513. * @param onError Called if there is an error when compiling a shader.
  9514. */
  9515. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9516. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9517. /**
  9518. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9519. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9520. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9521. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9522. * The gaps between physical kernels are compensated for in the weighting of the samples
  9523. * @param idealKernel Ideal blur kernel.
  9524. * @return Nearest best kernel.
  9525. */
  9526. protected _nearestBestKernel(idealKernel: number): number;
  9527. /**
  9528. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9529. * @param x The point on the Gaussian distribution to sample.
  9530. * @return the value of the Gaussian function at x.
  9531. */
  9532. protected _gaussianWeight(x: number): number;
  9533. /**
  9534. * Generates a string that can be used as a floating point number in GLSL.
  9535. * @param x Value to print.
  9536. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9537. * @return GLSL float string.
  9538. */
  9539. protected _glslFloat(x: number, decimalFigures?: number): string;
  9540. }
  9541. }
  9542. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9543. /** @hidden */
  9544. export var shadowMapPixelShader: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9550. /** @hidden */
  9551. export var bonesDeclaration: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9557. /** @hidden */
  9558. export var morphTargetsVertexGlobalDeclaration: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9564. /** @hidden */
  9565. export var morphTargetsVertexDeclaration: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9571. /** @hidden */
  9572. export var instancesDeclaration: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9578. /** @hidden */
  9579. export var helperFunctions: {
  9580. name: string;
  9581. shader: string;
  9582. };
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9585. /** @hidden */
  9586. export var morphTargetsVertex: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9592. /** @hidden */
  9593. export var instancesVertex: {
  9594. name: string;
  9595. shader: string;
  9596. };
  9597. }
  9598. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9599. /** @hidden */
  9600. export var bonesVertex: {
  9601. name: string;
  9602. shader: string;
  9603. };
  9604. }
  9605. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9608. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9609. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9612. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9613. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9614. /** @hidden */
  9615. export var shadowMapVertexShader: {
  9616. name: string;
  9617. shader: string;
  9618. };
  9619. }
  9620. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9621. /** @hidden */
  9622. export var depthBoxBlurPixelShader: {
  9623. name: string;
  9624. shader: string;
  9625. };
  9626. }
  9627. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9628. import { Nullable } from "babylonjs/types";
  9629. import { Scene } from "babylonjs/scene";
  9630. import { Matrix } from "babylonjs/Maths/math";
  9631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9633. import { Mesh } from "babylonjs/Meshes/mesh";
  9634. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9635. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9636. import { Effect } from "babylonjs/Materials/effect";
  9637. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9638. import "babylonjs/Shaders/shadowMap.fragment";
  9639. import "babylonjs/Shaders/shadowMap.vertex";
  9640. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9641. import { Observable } from "babylonjs/Misc/observable";
  9642. /**
  9643. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9644. */
  9645. export interface ICustomShaderOptions {
  9646. /**
  9647. * Gets or sets the custom shader name to use
  9648. */
  9649. shaderName: string;
  9650. /**
  9651. * The list of attribute names used in the shader
  9652. */
  9653. attributes?: string[];
  9654. /**
  9655. * The list of unifrom names used in the shader
  9656. */
  9657. uniforms?: string[];
  9658. /**
  9659. * The list of sampler names used in the shader
  9660. */
  9661. samplers?: string[];
  9662. /**
  9663. * The list of defines used in the shader
  9664. */
  9665. defines?: string[];
  9666. }
  9667. /**
  9668. * Interface to implement to create a shadow generator compatible with BJS.
  9669. */
  9670. export interface IShadowGenerator {
  9671. /**
  9672. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9673. * @returns The render target texture if present otherwise, null
  9674. */
  9675. getShadowMap(): Nullable<RenderTargetTexture>;
  9676. /**
  9677. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9678. * @returns The render target texture if the shadow map is present otherwise, null
  9679. */
  9680. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9681. /**
  9682. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9683. * @param subMesh The submesh we want to render in the shadow map
  9684. * @param useInstances Defines wether will draw in the map using instances
  9685. * @returns true if ready otherwise, false
  9686. */
  9687. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9688. /**
  9689. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9690. * @param defines Defines of the material we want to update
  9691. * @param lightIndex Index of the light in the enabled light list of the material
  9692. */
  9693. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9694. /**
  9695. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9696. * defined in the generator but impacting the effect).
  9697. * It implies the unifroms available on the materials are the standard BJS ones.
  9698. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9699. * @param effect The effect we are binfing the information for
  9700. */
  9701. bindShadowLight(lightIndex: string, effect: Effect): void;
  9702. /**
  9703. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9704. * (eq to shadow prjection matrix * light transform matrix)
  9705. * @returns The transform matrix used to create the shadow map
  9706. */
  9707. getTransformMatrix(): Matrix;
  9708. /**
  9709. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9710. * Cube and 2D textures for instance.
  9711. */
  9712. recreateShadowMap(): void;
  9713. /**
  9714. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9715. * @param onCompiled Callback triggered at the and of the effects compilation
  9716. * @param options Sets of optional options forcing the compilation with different modes
  9717. */
  9718. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9719. useInstances: boolean;
  9720. }>): void;
  9721. /**
  9722. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9723. * @param options Sets of optional options forcing the compilation with different modes
  9724. * @returns A promise that resolves when the compilation completes
  9725. */
  9726. forceCompilationAsync(options?: Partial<{
  9727. useInstances: boolean;
  9728. }>): Promise<void>;
  9729. /**
  9730. * Serializes the shadow generator setup to a json object.
  9731. * @returns The serialized JSON object
  9732. */
  9733. serialize(): any;
  9734. /**
  9735. * Disposes the Shadow map and related Textures and effects.
  9736. */
  9737. dispose(): void;
  9738. }
  9739. /**
  9740. * Default implementation IShadowGenerator.
  9741. * This is the main object responsible of generating shadows in the framework.
  9742. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9743. */
  9744. export class ShadowGenerator implements IShadowGenerator {
  9745. /**
  9746. * Shadow generator mode None: no filtering applied.
  9747. */
  9748. static readonly FILTER_NONE: number;
  9749. /**
  9750. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9751. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9752. */
  9753. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9754. /**
  9755. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9756. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9757. */
  9758. static readonly FILTER_POISSONSAMPLING: number;
  9759. /**
  9760. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9762. */
  9763. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9764. /**
  9765. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9766. * edge artifacts on steep falloff.
  9767. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9768. */
  9769. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9770. /**
  9771. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9772. * edge artifacts on steep falloff.
  9773. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9774. */
  9775. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9776. /**
  9777. * Shadow generator mode PCF: Percentage Closer Filtering
  9778. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9779. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9780. */
  9781. static readonly FILTER_PCF: number;
  9782. /**
  9783. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9784. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9785. * Contact Hardening
  9786. */
  9787. static readonly FILTER_PCSS: number;
  9788. /**
  9789. * Reserved for PCF and PCSS
  9790. * Highest Quality.
  9791. *
  9792. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9793. *
  9794. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9795. */
  9796. static readonly QUALITY_HIGH: number;
  9797. /**
  9798. * Reserved for PCF and PCSS
  9799. * Good tradeoff for quality/perf cross devices
  9800. *
  9801. * Execute PCF on a 3*3 kernel.
  9802. *
  9803. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9804. */
  9805. static readonly QUALITY_MEDIUM: number;
  9806. /**
  9807. * Reserved for PCF and PCSS
  9808. * The lowest quality but the fastest.
  9809. *
  9810. * Execute PCF on a 1*1 kernel.
  9811. *
  9812. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9813. */
  9814. static readonly QUALITY_LOW: number;
  9815. /** Gets or sets the custom shader name to use */
  9816. customShaderOptions: ICustomShaderOptions;
  9817. /**
  9818. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9819. */
  9820. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9821. /**
  9822. * Observable triggered before a mesh is rendered in the shadow map.
  9823. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9824. */
  9825. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9826. private _bias;
  9827. /**
  9828. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9829. */
  9830. /**
  9831. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9832. */
  9833. bias: number;
  9834. private _normalBias;
  9835. /**
  9836. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9837. */
  9838. /**
  9839. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9840. */
  9841. normalBias: number;
  9842. private _blurBoxOffset;
  9843. /**
  9844. * Gets the blur box offset: offset applied during the blur pass.
  9845. * Only useful if useKernelBlur = false
  9846. */
  9847. /**
  9848. * Sets the blur box offset: offset applied during the blur pass.
  9849. * Only useful if useKernelBlur = false
  9850. */
  9851. blurBoxOffset: number;
  9852. private _blurScale;
  9853. /**
  9854. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9855. * 2 means half of the size.
  9856. */
  9857. /**
  9858. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9859. * 2 means half of the size.
  9860. */
  9861. blurScale: number;
  9862. private _blurKernel;
  9863. /**
  9864. * Gets the blur kernel: kernel size of the blur pass.
  9865. * Only useful if useKernelBlur = true
  9866. */
  9867. /**
  9868. * Sets the blur kernel: kernel size of the blur pass.
  9869. * Only useful if useKernelBlur = true
  9870. */
  9871. blurKernel: number;
  9872. private _useKernelBlur;
  9873. /**
  9874. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9875. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9876. */
  9877. /**
  9878. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9879. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9880. */
  9881. useKernelBlur: boolean;
  9882. private _depthScale;
  9883. /**
  9884. * Gets the depth scale used in ESM mode.
  9885. */
  9886. /**
  9887. * Sets the depth scale used in ESM mode.
  9888. * This can override the scale stored on the light.
  9889. */
  9890. depthScale: number;
  9891. private _filter;
  9892. /**
  9893. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9894. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9895. */
  9896. /**
  9897. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9898. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9899. */
  9900. filter: number;
  9901. /**
  9902. * Gets if the current filter is set to Poisson Sampling.
  9903. */
  9904. /**
  9905. * Sets the current filter to Poisson Sampling.
  9906. */
  9907. usePoissonSampling: boolean;
  9908. /**
  9909. * Gets if the current filter is set to ESM.
  9910. */
  9911. /**
  9912. * Sets the current filter is to ESM.
  9913. */
  9914. useExponentialShadowMap: boolean;
  9915. /**
  9916. * Gets if the current filter is set to filtered ESM.
  9917. */
  9918. /**
  9919. * Gets if the current filter is set to filtered ESM.
  9920. */
  9921. useBlurExponentialShadowMap: boolean;
  9922. /**
  9923. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9924. * exponential to prevent steep falloff artifacts).
  9925. */
  9926. /**
  9927. * Sets the current filter to "close ESM" (using the inverse of the
  9928. * exponential to prevent steep falloff artifacts).
  9929. */
  9930. useCloseExponentialShadowMap: boolean;
  9931. /**
  9932. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9933. * exponential to prevent steep falloff artifacts).
  9934. */
  9935. /**
  9936. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9937. * exponential to prevent steep falloff artifacts).
  9938. */
  9939. useBlurCloseExponentialShadowMap: boolean;
  9940. /**
  9941. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9942. */
  9943. /**
  9944. * Sets the current filter to "PCF" (percentage closer filtering).
  9945. */
  9946. usePercentageCloserFiltering: boolean;
  9947. private _filteringQuality;
  9948. /**
  9949. * Gets the PCF or PCSS Quality.
  9950. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9951. */
  9952. /**
  9953. * Sets the PCF or PCSS Quality.
  9954. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9955. */
  9956. filteringQuality: number;
  9957. /**
  9958. * Gets if the current filter is set to "PCSS" (contact hardening).
  9959. */
  9960. /**
  9961. * Sets the current filter to "PCSS" (contact hardening).
  9962. */
  9963. useContactHardeningShadow: boolean;
  9964. private _contactHardeningLightSizeUVRatio;
  9965. /**
  9966. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9967. * Using a ratio helps keeping shape stability independently of the map size.
  9968. *
  9969. * It does not account for the light projection as it was having too much
  9970. * instability during the light setup or during light position changes.
  9971. *
  9972. * Only valid if useContactHardeningShadow is true.
  9973. */
  9974. /**
  9975. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9976. * Using a ratio helps keeping shape stability independently of the map size.
  9977. *
  9978. * It does not account for the light projection as it was having too much
  9979. * instability during the light setup or during light position changes.
  9980. *
  9981. * Only valid if useContactHardeningShadow is true.
  9982. */
  9983. contactHardeningLightSizeUVRatio: number;
  9984. private _darkness;
  9985. /**
  9986. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9987. * 0 means strongest and 1 would means no shadow.
  9988. * @returns the darkness.
  9989. */
  9990. getDarkness(): number;
  9991. /**
  9992. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9993. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9994. * @returns the shadow generator allowing fluent coding.
  9995. */
  9996. setDarkness(darkness: number): ShadowGenerator;
  9997. private _transparencyShadow;
  9998. /**
  9999. * Sets the ability to have transparent shadow (boolean).
  10000. * @param transparent True if transparent else False
  10001. * @returns the shadow generator allowing fluent coding
  10002. */
  10003. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10004. private _shadowMap;
  10005. private _shadowMap2;
  10006. /**
  10007. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10008. * @returns The render target texture if present otherwise, null
  10009. */
  10010. getShadowMap(): Nullable<RenderTargetTexture>;
  10011. /**
  10012. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10013. * @returns The render target texture if the shadow map is present otherwise, null
  10014. */
  10015. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10016. /**
  10017. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10018. * @param mesh Mesh to add
  10019. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10020. * @returns the Shadow Generator itself
  10021. */
  10022. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10023. /**
  10024. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10025. * @param mesh Mesh to remove
  10026. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10027. * @returns the Shadow Generator itself
  10028. */
  10029. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10030. /**
  10031. * Controls the extent to which the shadows fade out at the edge of the frustum
  10032. * Used only by directionals and spots
  10033. */
  10034. frustumEdgeFalloff: number;
  10035. private _light;
  10036. /**
  10037. * Returns the associated light object.
  10038. * @returns the light generating the shadow
  10039. */
  10040. getLight(): IShadowLight;
  10041. /**
  10042. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10043. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10044. * It might on the other hand introduce peter panning.
  10045. */
  10046. forceBackFacesOnly: boolean;
  10047. private _scene;
  10048. private _lightDirection;
  10049. private _effect;
  10050. private _viewMatrix;
  10051. private _projectionMatrix;
  10052. private _transformMatrix;
  10053. private _cachedPosition;
  10054. private _cachedDirection;
  10055. private _cachedDefines;
  10056. private _currentRenderID;
  10057. private _boxBlurPostprocess;
  10058. private _kernelBlurXPostprocess;
  10059. private _kernelBlurYPostprocess;
  10060. private _blurPostProcesses;
  10061. private _mapSize;
  10062. private _currentFaceIndex;
  10063. private _currentFaceIndexCache;
  10064. private _textureType;
  10065. private _defaultTextureMatrix;
  10066. /** @hidden */
  10067. static _SceneComponentInitialization: (scene: Scene) => void;
  10068. /**
  10069. * Creates a ShadowGenerator object.
  10070. * A ShadowGenerator is the required tool to use the shadows.
  10071. * Each light casting shadows needs to use its own ShadowGenerator.
  10072. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10073. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10074. * @param light The light object generating the shadows.
  10075. * @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.
  10076. */
  10077. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10078. private _initializeGenerator;
  10079. private _initializeShadowMap;
  10080. private _initializeBlurRTTAndPostProcesses;
  10081. private _renderForShadowMap;
  10082. private _renderSubMeshForShadowMap;
  10083. private _applyFilterValues;
  10084. /**
  10085. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10086. * @param onCompiled Callback triggered at the and of the effects compilation
  10087. * @param options Sets of optional options forcing the compilation with different modes
  10088. */
  10089. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10090. useInstances: boolean;
  10091. }>): void;
  10092. /**
  10093. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10094. * @param options Sets of optional options forcing the compilation with different modes
  10095. * @returns A promise that resolves when the compilation completes
  10096. */
  10097. forceCompilationAsync(options?: Partial<{
  10098. useInstances: boolean;
  10099. }>): Promise<void>;
  10100. /**
  10101. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10102. * @param subMesh The submesh we want to render in the shadow map
  10103. * @param useInstances Defines wether will draw in the map using instances
  10104. * @returns true if ready otherwise, false
  10105. */
  10106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10107. /**
  10108. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10109. * @param defines Defines of the material we want to update
  10110. * @param lightIndex Index of the light in the enabled light list of the material
  10111. */
  10112. prepareDefines(defines: any, lightIndex: number): void;
  10113. /**
  10114. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10115. * defined in the generator but impacting the effect).
  10116. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10117. * @param effect The effect we are binfing the information for
  10118. */
  10119. bindShadowLight(lightIndex: string, effect: Effect): void;
  10120. /**
  10121. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10122. * (eq to shadow prjection matrix * light transform matrix)
  10123. * @returns The transform matrix used to create the shadow map
  10124. */
  10125. getTransformMatrix(): Matrix;
  10126. /**
  10127. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10128. * Cube and 2D textures for instance.
  10129. */
  10130. recreateShadowMap(): void;
  10131. private _disposeBlurPostProcesses;
  10132. private _disposeRTTandPostProcesses;
  10133. /**
  10134. * Disposes the ShadowGenerator.
  10135. * Returns nothing.
  10136. */
  10137. dispose(): void;
  10138. /**
  10139. * Serializes the shadow generator setup to a json object.
  10140. * @returns The serialized JSON object
  10141. */
  10142. serialize(): any;
  10143. /**
  10144. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10145. * @param parsedShadowGenerator The JSON object to parse
  10146. * @param scene The scene to create the shadow map for
  10147. * @returns The parsed shadow generator
  10148. */
  10149. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10150. }
  10151. }
  10152. declare module "babylonjs/Lights/light" {
  10153. import { Nullable } from "babylonjs/types";
  10154. import { Scene } from "babylonjs/scene";
  10155. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10156. import { Node } from "babylonjs/node";
  10157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10158. import { Effect } from "babylonjs/Materials/effect";
  10159. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10160. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10161. /**
  10162. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10163. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10164. * 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.
  10165. */
  10166. export abstract class Light extends Node {
  10167. /**
  10168. * Falloff Default: light is falling off following the material specification:
  10169. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10170. */
  10171. static readonly FALLOFF_DEFAULT: number;
  10172. /**
  10173. * Falloff Physical: light is falling off following the inverse squared distance law.
  10174. */
  10175. static readonly FALLOFF_PHYSICAL: number;
  10176. /**
  10177. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10178. * to enhance interoperability with other engines.
  10179. */
  10180. static readonly FALLOFF_GLTF: number;
  10181. /**
  10182. * Falloff Standard: light is falling off like in the standard material
  10183. * to enhance interoperability with other materials.
  10184. */
  10185. static readonly FALLOFF_STANDARD: number;
  10186. /**
  10187. * If every light affecting the material is in this lightmapMode,
  10188. * material.lightmapTexture adds or multiplies
  10189. * (depends on material.useLightmapAsShadowmap)
  10190. * after every other light calculations.
  10191. */
  10192. static readonly LIGHTMAP_DEFAULT: number;
  10193. /**
  10194. * material.lightmapTexture as only diffuse lighting from this light
  10195. * adds only specular lighting from this light
  10196. * adds dynamic shadows
  10197. */
  10198. static readonly LIGHTMAP_SPECULAR: number;
  10199. /**
  10200. * material.lightmapTexture as only lighting
  10201. * no light calculation from this light
  10202. * only adds dynamic shadows from this light
  10203. */
  10204. static readonly LIGHTMAP_SHADOWSONLY: number;
  10205. /**
  10206. * Each light type uses the default quantity according to its type:
  10207. * point/spot lights use luminous intensity
  10208. * directional lights use illuminance
  10209. */
  10210. static readonly INTENSITYMODE_AUTOMATIC: number;
  10211. /**
  10212. * lumen (lm)
  10213. */
  10214. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10215. /**
  10216. * candela (lm/sr)
  10217. */
  10218. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10219. /**
  10220. * lux (lm/m^2)
  10221. */
  10222. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10223. /**
  10224. * nit (cd/m^2)
  10225. */
  10226. static readonly INTENSITYMODE_LUMINANCE: number;
  10227. /**
  10228. * Light type const id of the point light.
  10229. */
  10230. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10231. /**
  10232. * Light type const id of the directional light.
  10233. */
  10234. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10235. /**
  10236. * Light type const id of the spot light.
  10237. */
  10238. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10239. /**
  10240. * Light type const id of the hemispheric light.
  10241. */
  10242. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10243. /**
  10244. * Diffuse gives the basic color to an object.
  10245. */
  10246. diffuse: Color3;
  10247. /**
  10248. * Specular produces a highlight color on an object.
  10249. * Note: This is note affecting PBR materials.
  10250. */
  10251. specular: Color3;
  10252. /**
  10253. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10254. * falling off base on range or angle.
  10255. * This can be set to any values in Light.FALLOFF_x.
  10256. *
  10257. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10258. * other types of materials.
  10259. */
  10260. falloffType: number;
  10261. /**
  10262. * Strength of the light.
  10263. * Note: By default it is define in the framework own unit.
  10264. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10265. */
  10266. intensity: number;
  10267. private _range;
  10268. protected _inverseSquaredRange: number;
  10269. /**
  10270. * Defines how far from the source the light is impacting in scene units.
  10271. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10272. */
  10273. /**
  10274. * Defines how far from the source the light is impacting in scene units.
  10275. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10276. */
  10277. range: number;
  10278. /**
  10279. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10280. * of light.
  10281. */
  10282. private _photometricScale;
  10283. private _intensityMode;
  10284. /**
  10285. * Gets the photometric scale used to interpret the intensity.
  10286. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10287. */
  10288. /**
  10289. * Sets the photometric scale used to interpret the intensity.
  10290. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10291. */
  10292. intensityMode: number;
  10293. private _radius;
  10294. /**
  10295. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10296. */
  10297. /**
  10298. * sets the light radius used by PBR Materials to simulate soft area lights.
  10299. */
  10300. radius: number;
  10301. private _renderPriority;
  10302. /**
  10303. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10304. * exceeding the number allowed of the materials.
  10305. */
  10306. renderPriority: number;
  10307. private _shadowEnabled;
  10308. /**
  10309. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10310. * the current shadow generator.
  10311. */
  10312. /**
  10313. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10314. * the current shadow generator.
  10315. */
  10316. shadowEnabled: boolean;
  10317. private _includedOnlyMeshes;
  10318. /**
  10319. * Gets the only meshes impacted by this light.
  10320. */
  10321. /**
  10322. * Sets the only meshes impacted by this light.
  10323. */
  10324. includedOnlyMeshes: AbstractMesh[];
  10325. private _excludedMeshes;
  10326. /**
  10327. * Gets the meshes not impacted by this light.
  10328. */
  10329. /**
  10330. * Sets the meshes not impacted by this light.
  10331. */
  10332. excludedMeshes: AbstractMesh[];
  10333. private _excludeWithLayerMask;
  10334. /**
  10335. * Gets the layer id use to find what meshes are not impacted by the light.
  10336. * Inactive if 0
  10337. */
  10338. /**
  10339. * Sets the layer id use to find what meshes are not impacted by the light.
  10340. * Inactive if 0
  10341. */
  10342. excludeWithLayerMask: number;
  10343. private _includeOnlyWithLayerMask;
  10344. /**
  10345. * Gets the layer id use to find what meshes are impacted by the light.
  10346. * Inactive if 0
  10347. */
  10348. /**
  10349. * Sets the layer id use to find what meshes are impacted by the light.
  10350. * Inactive if 0
  10351. */
  10352. includeOnlyWithLayerMask: number;
  10353. private _lightmapMode;
  10354. /**
  10355. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10356. */
  10357. /**
  10358. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10359. */
  10360. lightmapMode: number;
  10361. /**
  10362. * Shadow generator associted to the light.
  10363. * @hidden Internal use only.
  10364. */
  10365. _shadowGenerator: Nullable<IShadowGenerator>;
  10366. /**
  10367. * @hidden Internal use only.
  10368. */
  10369. _excludedMeshesIds: string[];
  10370. /**
  10371. * @hidden Internal use only.
  10372. */
  10373. _includedOnlyMeshesIds: string[];
  10374. /**
  10375. * The current light unifom buffer.
  10376. * @hidden Internal use only.
  10377. */
  10378. _uniformBuffer: UniformBuffer;
  10379. /**
  10380. * Creates a Light object in the scene.
  10381. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10382. * @param name The firendly name of the light
  10383. * @param scene The scene the light belongs too
  10384. */
  10385. constructor(name: string, scene: Scene);
  10386. protected abstract _buildUniformLayout(): void;
  10387. /**
  10388. * Sets the passed Effect "effect" with the Light information.
  10389. * @param effect The effect to update
  10390. * @param lightIndex The index of the light in the effect to update
  10391. * @returns The light
  10392. */
  10393. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10394. /**
  10395. * Returns the string "Light".
  10396. * @returns the class name
  10397. */
  10398. getClassName(): string;
  10399. /** @hidden */
  10400. readonly _isLight: boolean;
  10401. /**
  10402. * Converts the light information to a readable string for debug purpose.
  10403. * @param fullDetails Supports for multiple levels of logging within scene loading
  10404. * @returns the human readable light info
  10405. */
  10406. toString(fullDetails?: boolean): string;
  10407. /** @hidden */
  10408. protected _syncParentEnabledState(): void;
  10409. /**
  10410. * Set the enabled state of this node.
  10411. * @param value - the new enabled state
  10412. */
  10413. setEnabled(value: boolean): void;
  10414. /**
  10415. * Returns the Light associated shadow generator if any.
  10416. * @return the associated shadow generator.
  10417. */
  10418. getShadowGenerator(): Nullable<IShadowGenerator>;
  10419. /**
  10420. * Returns a Vector3, the absolute light position in the World.
  10421. * @returns the world space position of the light
  10422. */
  10423. getAbsolutePosition(): Vector3;
  10424. /**
  10425. * Specifies if the light will affect the passed mesh.
  10426. * @param mesh The mesh to test against the light
  10427. * @return true the mesh is affected otherwise, false.
  10428. */
  10429. canAffectMesh(mesh: AbstractMesh): boolean;
  10430. /**
  10431. * Sort function to order lights for rendering.
  10432. * @param a First Light object to compare to second.
  10433. * @param b Second Light object to compare first.
  10434. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10435. */
  10436. static CompareLightsPriority(a: Light, b: Light): number;
  10437. /**
  10438. * Releases resources associated with this node.
  10439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10441. */
  10442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10443. /**
  10444. * Returns the light type ID (integer).
  10445. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10446. */
  10447. getTypeID(): number;
  10448. /**
  10449. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10450. * @returns the scaled intensity in intensity mode unit
  10451. */
  10452. getScaledIntensity(): number;
  10453. /**
  10454. * Returns a new Light object, named "name", from the current one.
  10455. * @param name The name of the cloned light
  10456. * @returns the new created light
  10457. */
  10458. clone(name: string): Nullable<Light>;
  10459. /**
  10460. * Serializes the current light into a Serialization object.
  10461. * @returns the serialized object.
  10462. */
  10463. serialize(): any;
  10464. /**
  10465. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10466. * This new light is named "name" and added to the passed scene.
  10467. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10468. * @param name The friendly name of the light
  10469. * @param scene The scene the new light will belong to
  10470. * @returns the constructor function
  10471. */
  10472. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10473. /**
  10474. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10475. * @param parsedLight The JSON representation of the light
  10476. * @param scene The scene to create the parsed light in
  10477. * @returns the created light after parsing
  10478. */
  10479. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10480. private _hookArrayForExcluded;
  10481. private _hookArrayForIncludedOnly;
  10482. private _resyncMeshes;
  10483. /**
  10484. * Forces the meshes to update their light related information in their rendering used effects
  10485. * @hidden Internal Use Only
  10486. */
  10487. _markMeshesAsLightDirty(): void;
  10488. /**
  10489. * Recomputes the cached photometric scale if needed.
  10490. */
  10491. private _computePhotometricScale;
  10492. /**
  10493. * Returns the Photometric Scale according to the light type and intensity mode.
  10494. */
  10495. private _getPhotometricScale;
  10496. /**
  10497. * Reorder the light in the scene according to their defined priority.
  10498. * @hidden Internal Use Only
  10499. */
  10500. _reorderLightsInScene(): void;
  10501. /**
  10502. * Prepares the list of defines specific to the light type.
  10503. * @param defines the list of defines
  10504. * @param lightIndex defines the index of the light for the effect
  10505. */
  10506. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10507. }
  10508. }
  10509. declare module "babylonjs/Actions/action" {
  10510. import { Observable } from "babylonjs/Misc/observable";
  10511. import { Condition } from "babylonjs/Actions/condition";
  10512. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10513. import { ActionManager } from "babylonjs/Actions/actionManager";
  10514. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10515. /**
  10516. * Interface used to define Action
  10517. */
  10518. export interface IAction {
  10519. /**
  10520. * Trigger for the action
  10521. */
  10522. trigger: number;
  10523. /** Options of the trigger */
  10524. triggerOptions: any;
  10525. /**
  10526. * Gets the trigger parameters
  10527. * @returns the trigger parameters
  10528. */
  10529. getTriggerParameter(): any;
  10530. /**
  10531. * Internal only - executes current action event
  10532. * @hidden
  10533. */
  10534. _executeCurrent(evt?: ActionEvent): void;
  10535. /**
  10536. * Serialize placeholder for child classes
  10537. * @param parent of child
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. /**
  10542. * Internal only
  10543. * @hidden
  10544. */
  10545. _prepare(): void;
  10546. /**
  10547. * Internal only - manager for action
  10548. * @hidden
  10549. */
  10550. _actionManager: AbstractActionManager;
  10551. }
  10552. /**
  10553. * The action to be carried out following a trigger
  10554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10555. */
  10556. export class Action implements IAction {
  10557. /** the trigger, with or without parameters, for the action */
  10558. triggerOptions: any;
  10559. /**
  10560. * Trigger for the action
  10561. */
  10562. trigger: number;
  10563. /**
  10564. * Internal only - manager for action
  10565. * @hidden
  10566. */
  10567. _actionManager: ActionManager;
  10568. private _nextActiveAction;
  10569. private _child;
  10570. private _condition?;
  10571. private _triggerParameter;
  10572. /**
  10573. * An event triggered prior to action being executed.
  10574. */
  10575. onBeforeExecuteObservable: Observable<Action>;
  10576. /**
  10577. * Creates a new Action
  10578. * @param triggerOptions the trigger, with or without parameters, for the action
  10579. * @param condition an optional determinant of action
  10580. */
  10581. constructor(
  10582. /** the trigger, with or without parameters, for the action */
  10583. triggerOptions: any, condition?: Condition);
  10584. /**
  10585. * Internal only
  10586. * @hidden
  10587. */
  10588. _prepare(): void;
  10589. /**
  10590. * Gets the trigger parameters
  10591. * @returns the trigger parameters
  10592. */
  10593. getTriggerParameter(): any;
  10594. /**
  10595. * Internal only - executes current action event
  10596. * @hidden
  10597. */
  10598. _executeCurrent(evt?: ActionEvent): void;
  10599. /**
  10600. * Execute placeholder for child classes
  10601. * @param evt optional action event
  10602. */
  10603. execute(evt?: ActionEvent): void;
  10604. /**
  10605. * Skips to next active action
  10606. */
  10607. skipToNextActiveAction(): void;
  10608. /**
  10609. * Adds action to chain of actions, may be a DoNothingAction
  10610. * @param action defines the next action to execute
  10611. * @returns The action passed in
  10612. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10613. */
  10614. then(action: Action): Action;
  10615. /**
  10616. * Internal only
  10617. * @hidden
  10618. */
  10619. _getProperty(propertyPath: string): string;
  10620. /**
  10621. * Internal only
  10622. * @hidden
  10623. */
  10624. _getEffectiveTarget(target: any, propertyPath: string): any;
  10625. /**
  10626. * Serialize placeholder for child classes
  10627. * @param parent of child
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. /**
  10632. * Internal only called by serialize
  10633. * @hidden
  10634. */
  10635. protected _serialize(serializedAction: any, parent?: any): any;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. static _SerializeValueAsString: (value: any) => string;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10646. name: string;
  10647. targetType: string;
  10648. value: string;
  10649. };
  10650. }
  10651. }
  10652. declare module "babylonjs/Actions/condition" {
  10653. import { ActionManager } from "babylonjs/Actions/actionManager";
  10654. /**
  10655. * A Condition applied to an Action
  10656. */
  10657. export class Condition {
  10658. /**
  10659. * Internal only - manager for action
  10660. * @hidden
  10661. */
  10662. _actionManager: ActionManager;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. _evaluationId: number;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. _currentResult: boolean;
  10673. /**
  10674. * Creates a new Condition
  10675. * @param actionManager the manager of the action the condition is applied to
  10676. */
  10677. constructor(actionManager: ActionManager);
  10678. /**
  10679. * Check if the current condition is valid
  10680. * @returns a boolean
  10681. */
  10682. isValid(): boolean;
  10683. /**
  10684. * Internal only
  10685. * @hidden
  10686. */
  10687. _getProperty(propertyPath: string): string;
  10688. /**
  10689. * Internal only
  10690. * @hidden
  10691. */
  10692. _getEffectiveTarget(target: any, propertyPath: string): any;
  10693. /**
  10694. * Serialize placeholder for child classes
  10695. * @returns the serialized object
  10696. */
  10697. serialize(): any;
  10698. /**
  10699. * Internal only
  10700. * @hidden
  10701. */
  10702. protected _serialize(serializedCondition: any): any;
  10703. }
  10704. /**
  10705. * Defines specific conditional operators as extensions of Condition
  10706. */
  10707. export class ValueCondition extends Condition {
  10708. /** path to specify the property of the target the conditional operator uses */
  10709. propertyPath: string;
  10710. /** the value compared by the conditional operator against the current value of the property */
  10711. value: any;
  10712. /** the conditional operator, default ValueCondition.IsEqual */
  10713. operator: number;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. private static _IsEqual;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. private static _IsDifferent;
  10724. /**
  10725. * Internal only
  10726. * @hidden
  10727. */
  10728. private static _IsGreater;
  10729. /**
  10730. * Internal only
  10731. * @hidden
  10732. */
  10733. private static _IsLesser;
  10734. /**
  10735. * returns the number for IsEqual
  10736. */
  10737. static readonly IsEqual: number;
  10738. /**
  10739. * Returns the number for IsDifferent
  10740. */
  10741. static readonly IsDifferent: number;
  10742. /**
  10743. * Returns the number for IsGreater
  10744. */
  10745. static readonly IsGreater: number;
  10746. /**
  10747. * Returns the number for IsLesser
  10748. */
  10749. static readonly IsLesser: number;
  10750. /**
  10751. * Internal only The action manager for the condition
  10752. * @hidden
  10753. */
  10754. _actionManager: ActionManager;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private _target;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private _effectiveTarget;
  10765. /**
  10766. * Internal only
  10767. * @hidden
  10768. */
  10769. private _property;
  10770. /**
  10771. * Creates a new ValueCondition
  10772. * @param actionManager manager for the action the condition applies to
  10773. * @param target for the action
  10774. * @param propertyPath path to specify the property of the target the conditional operator uses
  10775. * @param value the value compared by the conditional operator against the current value of the property
  10776. * @param operator the conditional operator, default ValueCondition.IsEqual
  10777. */
  10778. constructor(actionManager: ActionManager, target: any,
  10779. /** path to specify the property of the target the conditional operator uses */
  10780. propertyPath: string,
  10781. /** the value compared by the conditional operator against the current value of the property */
  10782. value: any,
  10783. /** the conditional operator, default ValueCondition.IsEqual */
  10784. operator?: number);
  10785. /**
  10786. * Compares the given value with the property value for the specified conditional operator
  10787. * @returns the result of the comparison
  10788. */
  10789. isValid(): boolean;
  10790. /**
  10791. * Serialize the ValueCondition into a JSON compatible object
  10792. * @returns serialization object
  10793. */
  10794. serialize(): any;
  10795. /**
  10796. * Gets the name of the conditional operator for the ValueCondition
  10797. * @param operator the conditional operator
  10798. * @returns the name
  10799. */
  10800. static GetOperatorName(operator: number): string;
  10801. }
  10802. /**
  10803. * Defines a predicate condition as an extension of Condition
  10804. */
  10805. export class PredicateCondition extends Condition {
  10806. /** defines the predicate function used to validate the condition */
  10807. predicate: () => boolean;
  10808. /**
  10809. * Internal only - manager for action
  10810. * @hidden
  10811. */
  10812. _actionManager: ActionManager;
  10813. /**
  10814. * Creates a new PredicateCondition
  10815. * @param actionManager manager for the action the condition applies to
  10816. * @param predicate defines the predicate function used to validate the condition
  10817. */
  10818. constructor(actionManager: ActionManager,
  10819. /** defines the predicate function used to validate the condition */
  10820. predicate: () => boolean);
  10821. /**
  10822. * @returns the validity of the predicate condition
  10823. */
  10824. isValid(): boolean;
  10825. }
  10826. /**
  10827. * Defines a state condition as an extension of Condition
  10828. */
  10829. export class StateCondition extends Condition {
  10830. /** Value to compare with target state */
  10831. value: string;
  10832. /**
  10833. * Internal only - manager for action
  10834. * @hidden
  10835. */
  10836. _actionManager: ActionManager;
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. private _target;
  10842. /**
  10843. * Creates a new StateCondition
  10844. * @param actionManager manager for the action the condition applies to
  10845. * @param target of the condition
  10846. * @param value to compare with target state
  10847. */
  10848. constructor(actionManager: ActionManager, target: any,
  10849. /** Value to compare with target state */
  10850. value: string);
  10851. /**
  10852. * Gets a boolean indicating if the current condition is met
  10853. * @returns the validity of the state
  10854. */
  10855. isValid(): boolean;
  10856. /**
  10857. * Serialize the StateCondition into a JSON compatible object
  10858. * @returns serialization object
  10859. */
  10860. serialize(): any;
  10861. }
  10862. }
  10863. declare module "babylonjs/Actions/directActions" {
  10864. import { Action } from "babylonjs/Actions/action";
  10865. import { Condition } from "babylonjs/Actions/condition";
  10866. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10867. /**
  10868. * This defines an action responsible to toggle a boolean once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class SwitchBooleanAction extends Action {
  10872. /**
  10873. * The path to the boolean property in the target object
  10874. */
  10875. propertyPath: string;
  10876. private _target;
  10877. private _effectiveTarget;
  10878. private _property;
  10879. /**
  10880. * Instantiate the action
  10881. * @param triggerOptions defines the trigger options
  10882. * @param target defines the object containing the boolean
  10883. * @param propertyPath defines the path to the boolean property in the target object
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action toggle the boolean value.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible to set a the state field of the target
  10902. * to a desired value once triggered.
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10904. */
  10905. export class SetStateAction extends Action {
  10906. /**
  10907. * The value to store in the state field.
  10908. */
  10909. value: string;
  10910. private _target;
  10911. /**
  10912. * Instantiate the action
  10913. * @param triggerOptions defines the trigger options
  10914. * @param target defines the object containing the state property
  10915. * @param value defines the value to store in the state field
  10916. * @param condition defines the trigger related conditions
  10917. */
  10918. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10919. /**
  10920. * Execute the action and store the value on the target state property.
  10921. */
  10922. execute(): void;
  10923. /**
  10924. * Serializes the actions and its related information.
  10925. * @param parent defines the object to serialize in
  10926. * @returns the serialized object
  10927. */
  10928. serialize(parent: any): any;
  10929. }
  10930. /**
  10931. * This defines an action responsible to set a property of the target
  10932. * to a desired value once triggered.
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10934. */
  10935. export class SetValueAction extends Action {
  10936. /**
  10937. * The path of the property to set in the target.
  10938. */
  10939. propertyPath: string;
  10940. /**
  10941. * The value to set in the property
  10942. */
  10943. value: any;
  10944. private _target;
  10945. private _effectiveTarget;
  10946. private _property;
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param target defines the object containing the property
  10951. * @param propertyPath defines the path of the property to set in the target
  10952. * @param value defines the value to set in the property
  10953. * @param condition defines the trigger related conditions
  10954. */
  10955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10956. /** @hidden */
  10957. _prepare(): void;
  10958. /**
  10959. * Execute the action and set the targetted property to the desired value.
  10960. */
  10961. execute(): void;
  10962. /**
  10963. * Serializes the actions and its related information.
  10964. * @param parent defines the object to serialize in
  10965. * @returns the serialized object
  10966. */
  10967. serialize(parent: any): any;
  10968. }
  10969. /**
  10970. * This defines an action responsible to increment the target value
  10971. * to a desired value once triggered.
  10972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10973. */
  10974. export class IncrementValueAction extends Action {
  10975. /**
  10976. * The path of the property to increment in the target.
  10977. */
  10978. propertyPath: string;
  10979. /**
  10980. * The value we should increment the property by.
  10981. */
  10982. value: any;
  10983. private _target;
  10984. private _effectiveTarget;
  10985. private _property;
  10986. /**
  10987. * Instantiate the action
  10988. * @param triggerOptions defines the trigger options
  10989. * @param target defines the object containing the property
  10990. * @param propertyPath defines the path of the property to increment in the target
  10991. * @param value defines the value value we should increment the property by
  10992. * @param condition defines the trigger related conditions
  10993. */
  10994. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10995. /** @hidden */
  10996. _prepare(): void;
  10997. /**
  10998. * Execute the action and increment the target of the value amount.
  10999. */
  11000. execute(): void;
  11001. /**
  11002. * Serializes the actions and its related information.
  11003. * @param parent defines the object to serialize in
  11004. * @returns the serialized object
  11005. */
  11006. serialize(parent: any): any;
  11007. }
  11008. /**
  11009. * This defines an action responsible to start an animation once triggered.
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11011. */
  11012. export class PlayAnimationAction extends Action {
  11013. /**
  11014. * Where the animation should start (animation frame)
  11015. */
  11016. from: number;
  11017. /**
  11018. * Where the animation should stop (animation frame)
  11019. */
  11020. to: number;
  11021. /**
  11022. * Define if the animation should loop or stop after the first play.
  11023. */
  11024. loop?: boolean;
  11025. private _target;
  11026. /**
  11027. * Instantiate the action
  11028. * @param triggerOptions defines the trigger options
  11029. * @param target defines the target animation or animation name
  11030. * @param from defines from where the animation should start (animation frame)
  11031. * @param end defines where the animation should stop (animation frame)
  11032. * @param loop defines if the animation should loop or stop after the first play
  11033. * @param condition defines the trigger related conditions
  11034. */
  11035. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11036. /** @hidden */
  11037. _prepare(): void;
  11038. /**
  11039. * Execute the action and play the animation.
  11040. */
  11041. execute(): void;
  11042. /**
  11043. * Serializes the actions and its related information.
  11044. * @param parent defines the object to serialize in
  11045. * @returns the serialized object
  11046. */
  11047. serialize(parent: any): any;
  11048. }
  11049. /**
  11050. * This defines an action responsible to stop an animation once triggered.
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11052. */
  11053. export class StopAnimationAction extends Action {
  11054. private _target;
  11055. /**
  11056. * Instantiate the action
  11057. * @param triggerOptions defines the trigger options
  11058. * @param target defines the target animation or animation name
  11059. * @param condition defines the trigger related conditions
  11060. */
  11061. constructor(triggerOptions: any, target: any, condition?: Condition);
  11062. /** @hidden */
  11063. _prepare(): void;
  11064. /**
  11065. * Execute the action and stop the animation.
  11066. */
  11067. execute(): void;
  11068. /**
  11069. * Serializes the actions and its related information.
  11070. * @param parent defines the object to serialize in
  11071. * @returns the serialized object
  11072. */
  11073. serialize(parent: any): any;
  11074. }
  11075. /**
  11076. * This defines an action responsible that does nothing once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class DoNothingAction extends Action {
  11080. /**
  11081. * Instantiate the action
  11082. * @param triggerOptions defines the trigger options
  11083. * @param condition defines the trigger related conditions
  11084. */
  11085. constructor(triggerOptions?: any, condition?: Condition);
  11086. /**
  11087. * Execute the action and do nothing.
  11088. */
  11089. execute(): void;
  11090. /**
  11091. * Serializes the actions and its related information.
  11092. * @param parent defines the object to serialize in
  11093. * @returns the serialized object
  11094. */
  11095. serialize(parent: any): any;
  11096. }
  11097. /**
  11098. * This defines an action responsible to trigger several actions once triggered.
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11100. */
  11101. export class CombineAction extends Action {
  11102. /**
  11103. * The list of aggregated animations to run.
  11104. */
  11105. children: Action[];
  11106. /**
  11107. * Instantiate the action
  11108. * @param triggerOptions defines the trigger options
  11109. * @param children defines the list of aggregated animations to run
  11110. * @param condition defines the trigger related conditions
  11111. */
  11112. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11113. /** @hidden */
  11114. _prepare(): void;
  11115. /**
  11116. * Execute the action and executes all the aggregated actions.
  11117. */
  11118. execute(evt: ActionEvent): void;
  11119. /**
  11120. * Serializes the actions and its related information.
  11121. * @param parent defines the object to serialize in
  11122. * @returns the serialized object
  11123. */
  11124. serialize(parent: any): any;
  11125. }
  11126. /**
  11127. * This defines an action responsible to run code (external event) once triggered.
  11128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11129. */
  11130. export class ExecuteCodeAction extends Action {
  11131. /**
  11132. * The callback function to run.
  11133. */
  11134. func: (evt: ActionEvent) => void;
  11135. /**
  11136. * Instantiate the action
  11137. * @param triggerOptions defines the trigger options
  11138. * @param func defines the callback function to run
  11139. * @param condition defines the trigger related conditions
  11140. */
  11141. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11142. /**
  11143. * Execute the action and run the attached code.
  11144. */
  11145. execute(evt: ActionEvent): void;
  11146. }
  11147. /**
  11148. * This defines an action responsible to set the parent property of the target once triggered.
  11149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11150. */
  11151. export class SetParentAction extends Action {
  11152. private _parent;
  11153. private _target;
  11154. /**
  11155. * Instantiate the action
  11156. * @param triggerOptions defines the trigger options
  11157. * @param target defines the target containing the parent property
  11158. * @param parent defines from where the animation should start (animation frame)
  11159. * @param condition defines the trigger related conditions
  11160. */
  11161. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11162. /** @hidden */
  11163. _prepare(): void;
  11164. /**
  11165. * Execute the action and set the parent property.
  11166. */
  11167. execute(): void;
  11168. /**
  11169. * Serializes the actions and its related information.
  11170. * @param parent defines the object to serialize in
  11171. * @returns the serialized object
  11172. */
  11173. serialize(parent: any): any;
  11174. }
  11175. }
  11176. declare module "babylonjs/Actions/actionManager" {
  11177. import { Nullable } from "babylonjs/types";
  11178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11179. import { Scene } from "babylonjs/scene";
  11180. import { IAction } from "babylonjs/Actions/action";
  11181. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11183. /**
  11184. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11185. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11187. */
  11188. export class ActionManager extends AbstractActionManager {
  11189. /**
  11190. * Nothing
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly NothingTrigger: number;
  11194. /**
  11195. * On pick
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnPickTrigger: number;
  11199. /**
  11200. * On left pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnLeftPickTrigger: number;
  11204. /**
  11205. * On right pick
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnRightPickTrigger: number;
  11209. /**
  11210. * On center pick
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnCenterPickTrigger: number;
  11214. /**
  11215. * On pick down
  11216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11217. */
  11218. static readonly OnPickDownTrigger: number;
  11219. /**
  11220. * On double pick
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnDoublePickTrigger: number;
  11224. /**
  11225. * On pick up
  11226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11227. */
  11228. static readonly OnPickUpTrigger: number;
  11229. /**
  11230. * On pick out.
  11231. * This trigger will only be raised if you also declared a OnPickDown
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnPickOutTrigger: number;
  11235. /**
  11236. * On long press
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnLongPressTrigger: number;
  11240. /**
  11241. * On pointer over
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnPointerOverTrigger: number;
  11245. /**
  11246. * On pointer out
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnPointerOutTrigger: number;
  11250. /**
  11251. * On every frame
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnEveryFrameTrigger: number;
  11255. /**
  11256. * On intersection enter
  11257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11258. */
  11259. static readonly OnIntersectionEnterTrigger: number;
  11260. /**
  11261. * On intersection exit
  11262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11263. */
  11264. static readonly OnIntersectionExitTrigger: number;
  11265. /**
  11266. * On key down
  11267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11268. */
  11269. static readonly OnKeyDownTrigger: number;
  11270. /**
  11271. * On key up
  11272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11273. */
  11274. static readonly OnKeyUpTrigger: number;
  11275. private _scene;
  11276. /**
  11277. * Creates a new action manager
  11278. * @param scene defines the hosting scene
  11279. */
  11280. constructor(scene: Scene);
  11281. /**
  11282. * Releases all associated resources
  11283. */
  11284. dispose(): void;
  11285. /**
  11286. * Gets hosting scene
  11287. * @returns the hosting scene
  11288. */
  11289. getScene(): Scene;
  11290. /**
  11291. * Does this action manager handles actions of any of the given triggers
  11292. * @param triggers defines the triggers to be tested
  11293. * @return a boolean indicating whether one (or more) of the triggers is handled
  11294. */
  11295. hasSpecificTriggers(triggers: number[]): boolean;
  11296. /**
  11297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11298. * speed.
  11299. * @param triggerA defines the trigger to be tested
  11300. * @param triggerB defines the trigger to be tested
  11301. * @return a boolean indicating whether one (or more) of the triggers is handled
  11302. */
  11303. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11304. /**
  11305. * Does this action manager handles actions of a given trigger
  11306. * @param trigger defines the trigger to be tested
  11307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11308. * @return whether the trigger is handled
  11309. */
  11310. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11311. /**
  11312. * Does this action manager has pointer triggers
  11313. */
  11314. readonly hasPointerTriggers: boolean;
  11315. /**
  11316. * Does this action manager has pick triggers
  11317. */
  11318. readonly hasPickTriggers: boolean;
  11319. /**
  11320. * Registers an action to this action manager
  11321. * @param action defines the action to be registered
  11322. * @return the action amended (prepared) after registration
  11323. */
  11324. registerAction(action: IAction): Nullable<IAction>;
  11325. /**
  11326. * Unregisters an action to this action manager
  11327. * @param action defines the action to be unregistered
  11328. * @return a boolean indicating whether the action has been unregistered
  11329. */
  11330. unregisterAction(action: IAction): Boolean;
  11331. /**
  11332. * Process a specific trigger
  11333. * @param trigger defines the trigger to process
  11334. * @param evt defines the event details to be processed
  11335. */
  11336. processTrigger(trigger: number, evt?: IActionEvent): void;
  11337. /** @hidden */
  11338. _getEffectiveTarget(target: any, propertyPath: string): any;
  11339. /** @hidden */
  11340. _getProperty(propertyPath: string): string;
  11341. /**
  11342. * Serialize this manager to a JSON object
  11343. * @param name defines the property name to store this manager
  11344. * @returns a JSON representation of this manager
  11345. */
  11346. serialize(name: string): any;
  11347. /**
  11348. * Creates a new ActionManager from a JSON data
  11349. * @param parsedActions defines the JSON data to read from
  11350. * @param object defines the hosting mesh
  11351. * @param scene defines the hosting scene
  11352. */
  11353. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11354. /**
  11355. * Get a trigger name by index
  11356. * @param trigger defines the trigger index
  11357. * @returns a trigger name
  11358. */
  11359. static GetTriggerName(trigger: number): string;
  11360. }
  11361. }
  11362. declare module "babylonjs/Culling/ray" {
  11363. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11364. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11366. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11367. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11368. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11369. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11370. /**
  11371. * Class representing a ray with position and direction
  11372. */
  11373. export class Ray {
  11374. /** origin point */
  11375. origin: Vector3;
  11376. /** direction */
  11377. direction: Vector3;
  11378. /** length of the ray */
  11379. length: number;
  11380. private static readonly TmpVector3;
  11381. private _tmpRay;
  11382. /**
  11383. * Creates a new ray
  11384. * @param origin origin point
  11385. * @param direction direction
  11386. * @param length length of the ray
  11387. */
  11388. constructor(
  11389. /** origin point */
  11390. origin: Vector3,
  11391. /** direction */
  11392. direction: Vector3,
  11393. /** length of the ray */
  11394. length?: number);
  11395. /**
  11396. * Checks if the ray intersects a box
  11397. * @param minimum bound of the box
  11398. * @param maximum bound of the box
  11399. * @param intersectionTreshold extra extend to be added to the box in all direction
  11400. * @returns if the box was hit
  11401. */
  11402. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11403. /**
  11404. * Checks if the ray intersects a box
  11405. * @param box the bounding box to check
  11406. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11407. * @returns if the box was hit
  11408. */
  11409. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11410. /**
  11411. * If the ray hits a sphere
  11412. * @param sphere the bounding sphere to check
  11413. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11414. * @returns true if it hits the sphere
  11415. */
  11416. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11417. /**
  11418. * If the ray hits a triange
  11419. * @param vertex0 triangle vertex
  11420. * @param vertex1 triangle vertex
  11421. * @param vertex2 triangle vertex
  11422. * @returns intersection information if hit
  11423. */
  11424. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11425. /**
  11426. * Checks if ray intersects a plane
  11427. * @param plane the plane to check
  11428. * @returns the distance away it was hit
  11429. */
  11430. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11431. /**
  11432. * Checks if ray intersects a mesh
  11433. * @param mesh the mesh to check
  11434. * @param fastCheck if only the bounding box should checked
  11435. * @returns picking info of the intersecton
  11436. */
  11437. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11438. /**
  11439. * Checks if ray intersects a mesh
  11440. * @param meshes the meshes to check
  11441. * @param fastCheck if only the bounding box should checked
  11442. * @param results array to store result in
  11443. * @returns Array of picking infos
  11444. */
  11445. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11446. private _comparePickingInfo;
  11447. private static smallnum;
  11448. private static rayl;
  11449. /**
  11450. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11451. * @param sega the first point of the segment to test the intersection against
  11452. * @param segb the second point of the segment to test the intersection against
  11453. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11454. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11455. */
  11456. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11457. /**
  11458. * Update the ray from viewport position
  11459. * @param x position
  11460. * @param y y position
  11461. * @param viewportWidth viewport width
  11462. * @param viewportHeight viewport height
  11463. * @param world world matrix
  11464. * @param view view matrix
  11465. * @param projection projection matrix
  11466. * @returns this ray updated
  11467. */
  11468. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11469. /**
  11470. * Creates a ray with origin and direction of 0,0,0
  11471. * @returns the new ray
  11472. */
  11473. static Zero(): Ray;
  11474. /**
  11475. * Creates a new ray from screen space and viewport
  11476. * @param x position
  11477. * @param y y position
  11478. * @param viewportWidth viewport width
  11479. * @param viewportHeight viewport height
  11480. * @param world world matrix
  11481. * @param view view matrix
  11482. * @param projection projection matrix
  11483. * @returns new ray
  11484. */
  11485. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11486. /**
  11487. * 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
  11488. * transformed to the given world matrix.
  11489. * @param origin The origin point
  11490. * @param end The end point
  11491. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11492. * @returns the new ray
  11493. */
  11494. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11495. /**
  11496. * Transforms a ray by a matrix
  11497. * @param ray ray to transform
  11498. * @param matrix matrix to apply
  11499. * @returns the resulting new ray
  11500. */
  11501. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11502. /**
  11503. * Transforms a ray by a matrix
  11504. * @param ray ray to transform
  11505. * @param matrix matrix to apply
  11506. * @param result ray to store result in
  11507. */
  11508. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11509. /**
  11510. * Unproject a ray from screen space to object space
  11511. * @param sourceX defines the screen space x coordinate to use
  11512. * @param sourceY defines the screen space y coordinate to use
  11513. * @param viewportWidth defines the current width of the viewport
  11514. * @param viewportHeight defines the current height of the viewport
  11515. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11516. * @param view defines the view matrix to use
  11517. * @param projection defines the projection matrix to use
  11518. */
  11519. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11520. }
  11521. /**
  11522. * Type used to define predicate used to select faces when a mesh intersection is detected
  11523. */
  11524. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11525. module "babylonjs/scene" {
  11526. interface Scene {
  11527. /** @hidden */
  11528. _tempPickingRay: Nullable<Ray>;
  11529. /** @hidden */
  11530. _cachedRayForTransform: Ray;
  11531. /** @hidden */
  11532. _pickWithRayInverseMatrix: Matrix;
  11533. /** @hidden */
  11534. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11535. /** @hidden */
  11536. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11537. }
  11538. }
  11539. }
  11540. declare module "babylonjs/sceneComponent" {
  11541. import { Scene } from "babylonjs/scene";
  11542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11544. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11545. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11546. import { Nullable } from "babylonjs/types";
  11547. import { Camera } from "babylonjs/Cameras/camera";
  11548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11550. import { AbstractScene } from "babylonjs/abstractScene";
  11551. /**
  11552. * Groups all the scene component constants in one place to ease maintenance.
  11553. * @hidden
  11554. */
  11555. export class SceneComponentConstants {
  11556. static readonly NAME_EFFECTLAYER: string;
  11557. static readonly NAME_LAYER: string;
  11558. static readonly NAME_LENSFLARESYSTEM: string;
  11559. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11560. static readonly NAME_PARTICLESYSTEM: string;
  11561. static readonly NAME_GAMEPAD: string;
  11562. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11563. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11564. static readonly NAME_DEPTHRENDERER: string;
  11565. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11566. static readonly NAME_SPRITE: string;
  11567. static readonly NAME_OUTLINERENDERER: string;
  11568. static readonly NAME_PROCEDURALTEXTURE: string;
  11569. static readonly NAME_SHADOWGENERATOR: string;
  11570. static readonly NAME_OCTREE: string;
  11571. static readonly NAME_PHYSICSENGINE: string;
  11572. static readonly NAME_AUDIO: string;
  11573. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11574. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11575. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11576. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11577. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11578. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11579. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11580. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11581. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11582. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11583. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11584. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11585. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11586. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11587. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11588. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11590. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11591. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11592. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11593. static readonly STEP_AFTERRENDER_AUDIO: number;
  11594. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11596. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11599. static readonly STEP_POINTERMOVE_SPRITE: number;
  11600. static readonly STEP_POINTERDOWN_SPRITE: number;
  11601. static readonly STEP_POINTERUP_SPRITE: number;
  11602. }
  11603. /**
  11604. * This represents a scene component.
  11605. *
  11606. * This is used to decouple the dependency the scene is having on the different workloads like
  11607. * layers, post processes...
  11608. */
  11609. export interface ISceneComponent {
  11610. /**
  11611. * The name of the component. Each component must have a unique name.
  11612. */
  11613. name: string;
  11614. /**
  11615. * The scene the component belongs to.
  11616. */
  11617. scene: Scene;
  11618. /**
  11619. * Register the component to one instance of a scene.
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. }
  11632. /**
  11633. * This represents a SERIALIZABLE scene component.
  11634. *
  11635. * This extends Scene Component to add Serialization methods on top.
  11636. */
  11637. export interface ISceneSerializableComponent extends ISceneComponent {
  11638. /**
  11639. * Adds all the element from the container to the scene
  11640. * @param container the container holding the elements
  11641. */
  11642. addFromContainer(container: AbstractScene): void;
  11643. /**
  11644. * Removes all the elements in the container from the scene
  11645. * @param container contains the elements to remove
  11646. * @param dispose if the removed element should be disposed (default: false)
  11647. */
  11648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11649. /**
  11650. * Serializes the component data to the specified json object
  11651. * @param serializationObject The object to serialize to
  11652. */
  11653. serialize(serializationObject: any): void;
  11654. }
  11655. /**
  11656. * Strong typing of a Mesh related stage step action
  11657. */
  11658. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11659. /**
  11660. * Strong typing of a Evaluate Sub Mesh related stage step action
  11661. */
  11662. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11663. /**
  11664. * Strong typing of a Active Mesh related stage step action
  11665. */
  11666. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11667. /**
  11668. * Strong typing of a Camera related stage step action
  11669. */
  11670. export type CameraStageAction = (camera: Camera) => void;
  11671. /**
  11672. * Strong typing of a Render Target related stage step action
  11673. */
  11674. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11675. /**
  11676. * Strong typing of a RenderingGroup related stage step action
  11677. */
  11678. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11679. /**
  11680. * Strong typing of a Mesh Render related stage step action
  11681. */
  11682. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11683. /**
  11684. * Strong typing of a simple stage step action
  11685. */
  11686. export type SimpleStageAction = () => void;
  11687. /**
  11688. * Strong typing of a render target action.
  11689. */
  11690. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11691. /**
  11692. * Strong typing of a pointer move action.
  11693. */
  11694. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11695. /**
  11696. * Strong typing of a pointer up/down action.
  11697. */
  11698. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11699. /**
  11700. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11701. * @hidden
  11702. */
  11703. export class Stage<T extends Function> extends Array<{
  11704. index: number;
  11705. component: ISceneComponent;
  11706. action: T;
  11707. }> {
  11708. /**
  11709. * Hide ctor from the rest of the world.
  11710. * @param items The items to add.
  11711. */
  11712. private constructor();
  11713. /**
  11714. * Creates a new Stage.
  11715. * @returns A new instance of a Stage
  11716. */
  11717. static Create<T extends Function>(): Stage<T>;
  11718. /**
  11719. * Registers a step in an ordered way in the targeted stage.
  11720. * @param index Defines the position to register the step in
  11721. * @param component Defines the component attached to the step
  11722. * @param action Defines the action to launch during the step
  11723. */
  11724. registerStep(index: number, component: ISceneComponent, action: T): void;
  11725. /**
  11726. * Clears all the steps from the stage.
  11727. */
  11728. clear(): void;
  11729. }
  11730. }
  11731. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11732. import { Nullable } from "babylonjs/types";
  11733. import { Observable } from "babylonjs/Misc/observable";
  11734. import { Scene } from "babylonjs/scene";
  11735. import { Sprite } from "babylonjs/Sprites/sprite";
  11736. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11737. import { Ray } from "babylonjs/Culling/ray";
  11738. import { Camera } from "babylonjs/Cameras/camera";
  11739. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11740. import { ISceneComponent } from "babylonjs/sceneComponent";
  11741. module "babylonjs/scene" {
  11742. interface Scene {
  11743. /** @hidden */
  11744. _pointerOverSprite: Nullable<Sprite>;
  11745. /** @hidden */
  11746. _pickedDownSprite: Nullable<Sprite>;
  11747. /** @hidden */
  11748. _tempSpritePickingRay: Nullable<Ray>;
  11749. /**
  11750. * All of the sprite managers added to this scene
  11751. * @see http://doc.babylonjs.com/babylon101/sprites
  11752. */
  11753. spriteManagers: Array<ISpriteManager>;
  11754. /**
  11755. * An event triggered when sprites rendering is about to start
  11756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11757. */
  11758. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11759. /**
  11760. * An event triggered when sprites rendering is done
  11761. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11762. */
  11763. onAfterSpritesRenderingObservable: Observable<Scene>;
  11764. /** @hidden */
  11765. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11766. /** Launch a ray to try to pick a sprite in the scene
  11767. * @param x position on screen
  11768. * @param y position on screen
  11769. * @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
  11770. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11771. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11772. * @returns a PickingInfo
  11773. */
  11774. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11775. /** Use the given ray to pick a sprite in the scene
  11776. * @param ray The ray (in world space) to use to pick meshes
  11777. * @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
  11778. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11779. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11780. * @returns a PickingInfo
  11781. */
  11782. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11783. /**
  11784. * Force the sprite under the pointer
  11785. * @param sprite defines the sprite to use
  11786. */
  11787. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11788. /**
  11789. * Gets the sprite under the pointer
  11790. * @returns a Sprite or null if no sprite is under the pointer
  11791. */
  11792. getPointerOverSprite(): Nullable<Sprite>;
  11793. }
  11794. }
  11795. /**
  11796. * Defines the sprite scene component responsible to manage sprites
  11797. * in a given scene.
  11798. */
  11799. export class SpriteSceneComponent implements ISceneComponent {
  11800. /**
  11801. * The component name helpfull to identify the component in the list of scene components.
  11802. */
  11803. readonly name: string;
  11804. /**
  11805. * The scene the component belongs to.
  11806. */
  11807. scene: Scene;
  11808. /** @hidden */
  11809. private _spritePredicate;
  11810. /**
  11811. * Creates a new instance of the component for the given scene
  11812. * @param scene Defines the scene to register the component in
  11813. */
  11814. constructor(scene: Scene);
  11815. /**
  11816. * Registers the component in a given scene
  11817. */
  11818. register(): void;
  11819. /**
  11820. * Rebuilds the elements related to this component in case of
  11821. * context lost for instance.
  11822. */
  11823. rebuild(): void;
  11824. /**
  11825. * Disposes the component and the associated ressources.
  11826. */
  11827. dispose(): void;
  11828. private _pickSpriteButKeepRay;
  11829. private _pointerMove;
  11830. private _pointerDown;
  11831. private _pointerUp;
  11832. }
  11833. }
  11834. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11835. /** @hidden */
  11836. export var fogFragmentDeclaration: {
  11837. name: string;
  11838. shader: string;
  11839. };
  11840. }
  11841. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11842. /** @hidden */
  11843. export var fogFragment: {
  11844. name: string;
  11845. shader: string;
  11846. };
  11847. }
  11848. declare module "babylonjs/Shaders/sprites.fragment" {
  11849. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11850. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11851. /** @hidden */
  11852. export var spritesPixelShader: {
  11853. name: string;
  11854. shader: string;
  11855. };
  11856. }
  11857. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11858. /** @hidden */
  11859. export var fogVertexDeclaration: {
  11860. name: string;
  11861. shader: string;
  11862. };
  11863. }
  11864. declare module "babylonjs/Shaders/sprites.vertex" {
  11865. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11866. /** @hidden */
  11867. export var spritesVertexShader: {
  11868. name: string;
  11869. shader: string;
  11870. };
  11871. }
  11872. declare module "babylonjs/Sprites/spriteManager" {
  11873. import { IDisposable, Scene } from "babylonjs/scene";
  11874. import { Nullable } from "babylonjs/types";
  11875. import { Observable } from "babylonjs/Misc/observable";
  11876. import { Sprite } from "babylonjs/Sprites/sprite";
  11877. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11878. import { Camera } from "babylonjs/Cameras/camera";
  11879. import { Texture } from "babylonjs/Materials/Textures/texture";
  11880. import "babylonjs/Shaders/sprites.fragment";
  11881. import "babylonjs/Shaders/sprites.vertex";
  11882. import { Ray } from "babylonjs/Culling/ray";
  11883. /**
  11884. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11885. */
  11886. export interface ISpriteManager extends IDisposable {
  11887. /**
  11888. * Restricts the camera to viewing objects with the same layerMask.
  11889. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11890. */
  11891. layerMask: number;
  11892. /**
  11893. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11894. */
  11895. isPickable: boolean;
  11896. /**
  11897. * Specifies the rendering group id for this mesh (0 by default)
  11898. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11899. */
  11900. renderingGroupId: number;
  11901. /**
  11902. * Defines the list of sprites managed by the manager.
  11903. */
  11904. sprites: Array<Sprite>;
  11905. /**
  11906. * Tests the intersection of a sprite with a specific ray.
  11907. * @param ray The ray we are sending to test the collision
  11908. * @param camera The camera space we are sending rays in
  11909. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11910. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11911. * @returns picking info or null.
  11912. */
  11913. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11914. /**
  11915. * Renders the list of sprites on screen.
  11916. */
  11917. render(): void;
  11918. }
  11919. /**
  11920. * Class used to manage multiple sprites on the same spritesheet
  11921. * @see http://doc.babylonjs.com/babylon101/sprites
  11922. */
  11923. export class SpriteManager implements ISpriteManager {
  11924. /** defines the manager's name */
  11925. name: string;
  11926. /** Gets the list of sprites */
  11927. sprites: Sprite[];
  11928. /** Gets or sets the rendering group id (0 by default) */
  11929. renderingGroupId: number;
  11930. /** Gets or sets camera layer mask */
  11931. layerMask: number;
  11932. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11933. fogEnabled: boolean;
  11934. /** Gets or sets a boolean indicating if the sprites are pickable */
  11935. isPickable: boolean;
  11936. /** Defines the default width of a cell in the spritesheet */
  11937. cellWidth: number;
  11938. /** Defines the default height of a cell in the spritesheet */
  11939. cellHeight: number;
  11940. /**
  11941. * An event triggered when the manager is disposed.
  11942. */
  11943. onDisposeObservable: Observable<SpriteManager>;
  11944. private _onDisposeObserver;
  11945. /**
  11946. * Callback called when the manager is disposed
  11947. */
  11948. onDispose: () => void;
  11949. private _capacity;
  11950. private _spriteTexture;
  11951. private _epsilon;
  11952. private _scene;
  11953. private _vertexData;
  11954. private _buffer;
  11955. private _vertexBuffers;
  11956. private _indexBuffer;
  11957. private _effectBase;
  11958. private _effectFog;
  11959. /**
  11960. * Gets or sets the spritesheet texture
  11961. */
  11962. texture: Texture;
  11963. /**
  11964. * Creates a new sprite manager
  11965. * @param name defines the manager's name
  11966. * @param imgUrl defines the sprite sheet url
  11967. * @param capacity defines the maximum allowed number of sprites
  11968. * @param cellSize defines the size of a sprite cell
  11969. * @param scene defines the hosting scene
  11970. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11971. * @param samplingMode defines the smapling mode to use with spritesheet
  11972. */
  11973. constructor(
  11974. /** defines the manager's name */
  11975. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11976. private _appendSpriteVertex;
  11977. /**
  11978. * Intersects the sprites with a ray
  11979. * @param ray defines the ray to intersect with
  11980. * @param camera defines the current active camera
  11981. * @param predicate defines a predicate used to select candidate sprites
  11982. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11983. * @returns null if no hit or a PickingInfo
  11984. */
  11985. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11986. /**
  11987. * Render all child sprites
  11988. */
  11989. render(): void;
  11990. /**
  11991. * Release associated resources
  11992. */
  11993. dispose(): void;
  11994. }
  11995. }
  11996. declare module "babylonjs/Sprites/sprite" {
  11997. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11998. import { Nullable } from "babylonjs/types";
  11999. import { ActionManager } from "babylonjs/Actions/actionManager";
  12000. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12001. /**
  12002. * Class used to represent a sprite
  12003. * @see http://doc.babylonjs.com/babylon101/sprites
  12004. */
  12005. export class Sprite {
  12006. /** defines the name */
  12007. name: string;
  12008. /** Gets or sets the current world position */
  12009. position: Vector3;
  12010. /** Gets or sets the main color */
  12011. color: Color4;
  12012. /** Gets or sets the width */
  12013. width: number;
  12014. /** Gets or sets the height */
  12015. height: number;
  12016. /** Gets or sets rotation angle */
  12017. angle: number;
  12018. /** Gets or sets the cell index in the sprite sheet */
  12019. cellIndex: number;
  12020. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12021. invertU: number;
  12022. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12023. invertV: number;
  12024. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12025. disposeWhenFinishedAnimating: boolean;
  12026. /** Gets the list of attached animations */
  12027. animations: Animation[];
  12028. /** Gets or sets a boolean indicating if the sprite can be picked */
  12029. isPickable: boolean;
  12030. /**
  12031. * Gets or sets the associated action manager
  12032. */
  12033. actionManager: Nullable<ActionManager>;
  12034. private _animationStarted;
  12035. private _loopAnimation;
  12036. private _fromIndex;
  12037. private _toIndex;
  12038. private _delay;
  12039. private _direction;
  12040. private _manager;
  12041. private _time;
  12042. private _onAnimationEnd;
  12043. /**
  12044. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12045. */
  12046. isVisible: boolean;
  12047. /**
  12048. * Gets or sets the sprite size
  12049. */
  12050. size: number;
  12051. /**
  12052. * Creates a new Sprite
  12053. * @param name defines the name
  12054. * @param manager defines the manager
  12055. */
  12056. constructor(
  12057. /** defines the name */
  12058. name: string, manager: ISpriteManager);
  12059. /**
  12060. * Starts an animation
  12061. * @param from defines the initial key
  12062. * @param to defines the end key
  12063. * @param loop defines if the animation must loop
  12064. * @param delay defines the start delay (in ms)
  12065. * @param onAnimationEnd defines a callback to call when animation ends
  12066. */
  12067. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12068. /** Stops current animation (if any) */
  12069. stopAnimation(): void;
  12070. /** @hidden */
  12071. _animate(deltaTime: number): void;
  12072. /** Release associated resources */
  12073. dispose(): void;
  12074. }
  12075. }
  12076. declare module "babylonjs/Collisions/pickingInfo" {
  12077. import { Nullable } from "babylonjs/types";
  12078. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12080. import { Sprite } from "babylonjs/Sprites/sprite";
  12081. import { Ray } from "babylonjs/Culling/ray";
  12082. /**
  12083. * Information about the result of picking within a scene
  12084. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12085. */
  12086. export class PickingInfo {
  12087. /** @hidden */
  12088. _pickingUnavailable: boolean;
  12089. /**
  12090. * If the pick collided with an object
  12091. */
  12092. hit: boolean;
  12093. /**
  12094. * Distance away where the pick collided
  12095. */
  12096. distance: number;
  12097. /**
  12098. * The location of pick collision
  12099. */
  12100. pickedPoint: Nullable<Vector3>;
  12101. /**
  12102. * The mesh corresponding the the pick collision
  12103. */
  12104. pickedMesh: Nullable<AbstractMesh>;
  12105. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12106. bu: number;
  12107. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12108. bv: number;
  12109. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12110. faceId: number;
  12111. /** Id of the the submesh that was picked */
  12112. subMeshId: number;
  12113. /** If a sprite was picked, this will be the sprite the pick collided with */
  12114. pickedSprite: Nullable<Sprite>;
  12115. /**
  12116. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12117. */
  12118. originMesh: Nullable<AbstractMesh>;
  12119. /**
  12120. * The ray that was used to perform the picking.
  12121. */
  12122. ray: Nullable<Ray>;
  12123. /**
  12124. * Gets the normal correspodning to the face the pick collided with
  12125. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12126. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12127. * @returns The normal correspodning to the face the pick collided with
  12128. */
  12129. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12130. /**
  12131. * Gets the texture coordinates of where the pick occured
  12132. * @returns the vector containing the coordnates of the texture
  12133. */
  12134. getTextureCoordinates(): Nullable<Vector2>;
  12135. }
  12136. }
  12137. declare module "babylonjs/Events/pointerEvents" {
  12138. import { Nullable } from "babylonjs/types";
  12139. import { Vector2 } from "babylonjs/Maths/math";
  12140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12141. import { Ray } from "babylonjs/Culling/ray";
  12142. /**
  12143. * Gather the list of pointer event types as constants.
  12144. */
  12145. export class PointerEventTypes {
  12146. /**
  12147. * 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.
  12148. */
  12149. static readonly POINTERDOWN: number;
  12150. /**
  12151. * The pointerup event is fired when a pointer is no longer active.
  12152. */
  12153. static readonly POINTERUP: number;
  12154. /**
  12155. * The pointermove event is fired when a pointer changes coordinates.
  12156. */
  12157. static readonly POINTERMOVE: number;
  12158. /**
  12159. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12160. */
  12161. static readonly POINTERWHEEL: number;
  12162. /**
  12163. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12164. */
  12165. static readonly POINTERPICK: number;
  12166. /**
  12167. * The pointertap event is fired when a the object has been touched and released without drag.
  12168. */
  12169. static readonly POINTERTAP: number;
  12170. /**
  12171. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12172. */
  12173. static readonly POINTERDOUBLETAP: number;
  12174. }
  12175. /**
  12176. * Base class of pointer info types.
  12177. */
  12178. export class PointerInfoBase {
  12179. /**
  12180. * Defines the type of event (PointerEventTypes)
  12181. */
  12182. type: number;
  12183. /**
  12184. * Defines the related dom event
  12185. */
  12186. event: PointerEvent | MouseWheelEvent;
  12187. /**
  12188. * Instantiates the base class of pointers info.
  12189. * @param type Defines the type of event (PointerEventTypes)
  12190. * @param event Defines the related dom event
  12191. */
  12192. constructor(
  12193. /**
  12194. * Defines the type of event (PointerEventTypes)
  12195. */
  12196. type: number,
  12197. /**
  12198. * Defines the related dom event
  12199. */
  12200. event: PointerEvent | MouseWheelEvent);
  12201. }
  12202. /**
  12203. * This class is used to store pointer related info for the onPrePointerObservable event.
  12204. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12205. */
  12206. export class PointerInfoPre extends PointerInfoBase {
  12207. /**
  12208. * Ray from a pointer if availible (eg. 6dof controller)
  12209. */
  12210. ray: Nullable<Ray>;
  12211. /**
  12212. * Defines the local position of the pointer on the canvas.
  12213. */
  12214. localPosition: Vector2;
  12215. /**
  12216. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12217. */
  12218. skipOnPointerObservable: boolean;
  12219. /**
  12220. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12221. * @param type Defines the type of event (PointerEventTypes)
  12222. * @param event Defines the related dom event
  12223. * @param localX Defines the local x coordinates of the pointer when the event occured
  12224. * @param localY Defines the local y coordinates of the pointer when the event occured
  12225. */
  12226. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12227. }
  12228. /**
  12229. * This type contains all the data related to a pointer event in Babylon.js.
  12230. * 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.
  12231. */
  12232. export class PointerInfo extends PointerInfoBase {
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>;
  12237. /**
  12238. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12239. * @param type Defines the type of event (PointerEventTypes)
  12240. * @param event Defines the related dom event
  12241. * @param pickInfo Defines the picking info associated to the info (if any)\
  12242. */
  12243. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12244. /**
  12245. * Defines the picking info associated to the info (if any)\
  12246. */
  12247. pickInfo: Nullable<PickingInfo>);
  12248. }
  12249. /**
  12250. * Data relating to a touch event on the screen.
  12251. */
  12252. export interface PointerTouch {
  12253. /**
  12254. * X coordinate of touch.
  12255. */
  12256. x: number;
  12257. /**
  12258. * Y coordinate of touch.
  12259. */
  12260. y: number;
  12261. /**
  12262. * Id of touch. Unique for each finger.
  12263. */
  12264. pointerId: number;
  12265. /**
  12266. * Event type passed from DOM.
  12267. */
  12268. type: any;
  12269. }
  12270. }
  12271. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12272. import { Observable } from "babylonjs/Misc/observable";
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the mouse inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Define if touch is enabled in the mouse input
  12283. */
  12284. touchEnabled: boolean;
  12285. /**
  12286. * Defines the camera the input is attached to.
  12287. */
  12288. camera: FreeCamera;
  12289. /**
  12290. * Defines the buttons associated with the input to handle camera move.
  12291. */
  12292. buttons: number[];
  12293. /**
  12294. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12295. */
  12296. angularSensibility: number;
  12297. private _pointerInput;
  12298. private _onMouseMove;
  12299. private _observer;
  12300. private previousPosition;
  12301. /**
  12302. * Observable for when a pointer move event occurs containing the move offset
  12303. */
  12304. onPointerMovedObservable: Observable<{
  12305. offsetX: number;
  12306. offsetY: number;
  12307. }>;
  12308. /**
  12309. * @hidden
  12310. * If the camera should be rotated automatically based on pointer movement
  12311. */
  12312. _allowCameraRotation: boolean;
  12313. /**
  12314. * Manage the mouse inputs to control the movement of a free camera.
  12315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12316. * @param touchEnabled Defines if touch is enabled or not
  12317. */
  12318. constructor(
  12319. /**
  12320. * Define if touch is enabled in the mouse input
  12321. */
  12322. touchEnabled?: boolean);
  12323. /**
  12324. * Attach the input controls to a specific dom element to get the input from.
  12325. * @param element Defines the element the controls should be listened from
  12326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12327. */
  12328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12329. /**
  12330. * Called on JS contextmenu event.
  12331. * Override this method to provide functionality.
  12332. */
  12333. protected onContextMenu(evt: PointerEvent): void;
  12334. /**
  12335. * Detach the current controls from the specified dom element.
  12336. * @param element Defines the element to stop listening the inputs from
  12337. */
  12338. detachControl(element: Nullable<HTMLElement>): void;
  12339. /**
  12340. * Gets the class name of the current intput.
  12341. * @returns the class name
  12342. */
  12343. getClassName(): string;
  12344. /**
  12345. * Get the friendly name associated with the input class.
  12346. * @returns the input friendly name
  12347. */
  12348. getSimpleName(): string;
  12349. }
  12350. }
  12351. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12352. import { Nullable } from "babylonjs/types";
  12353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12354. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12355. /**
  12356. * Manage the touch inputs to control the movement of a free camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12360. /**
  12361. * Defines the camera the input is attached to.
  12362. */
  12363. camera: FreeCamera;
  12364. /**
  12365. * Defines the touch sensibility for rotation.
  12366. * The higher the faster.
  12367. */
  12368. touchAngularSensibility: number;
  12369. /**
  12370. * Defines the touch sensibility for move.
  12371. * The higher the faster.
  12372. */
  12373. touchMoveSensibility: number;
  12374. private _offsetX;
  12375. private _offsetY;
  12376. private _pointerPressed;
  12377. private _pointerInput;
  12378. private _observer;
  12379. private _onLostFocus;
  12380. /**
  12381. * Attach the input controls to a specific dom element to get the input from.
  12382. * @param element Defines the element the controls should be listened from
  12383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12384. */
  12385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12386. /**
  12387. * Detach the current controls from the specified dom element.
  12388. * @param element Defines the element to stop listening the inputs from
  12389. */
  12390. detachControl(element: Nullable<HTMLElement>): void;
  12391. /**
  12392. * Update the current camera state depending on the inputs that have been used this frame.
  12393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12394. */
  12395. checkInputs(): void;
  12396. /**
  12397. * Gets the class name of the current intput.
  12398. * @returns the class name
  12399. */
  12400. getClassName(): string;
  12401. /**
  12402. * Get the friendly name associated with the input class.
  12403. * @returns the input friendly name
  12404. */
  12405. getSimpleName(): string;
  12406. }
  12407. }
  12408. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12411. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12412. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12413. import { Nullable } from "babylonjs/types";
  12414. /**
  12415. * Default Inputs manager for the FreeCamera.
  12416. * It groups all the default supported inputs for ease of use.
  12417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12418. */
  12419. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12420. /**
  12421. * @hidden
  12422. */
  12423. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12424. /**
  12425. * @hidden
  12426. */
  12427. _mouseInput: Nullable<FreeCameraMouseInput>;
  12428. /**
  12429. * Instantiates a new FreeCameraInputsManager.
  12430. * @param camera Defines the camera the inputs belong to
  12431. */
  12432. constructor(camera: FreeCamera);
  12433. /**
  12434. * Add keyboard input support to the input manager.
  12435. * @returns the current input manager
  12436. */
  12437. addKeyboard(): FreeCameraInputsManager;
  12438. /**
  12439. * Add mouse input support to the input manager.
  12440. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12441. * @returns the current input manager
  12442. */
  12443. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12444. /**
  12445. * Removes the mouse input support from the manager
  12446. * @returns the current input manager
  12447. */
  12448. removeMouse(): FreeCameraInputsManager;
  12449. /**
  12450. * Add touch input support to the input manager.
  12451. * @returns the current input manager
  12452. */
  12453. addTouch(): FreeCameraInputsManager;
  12454. }
  12455. }
  12456. declare module "babylonjs/Cameras/freeCamera" {
  12457. import { Vector3 } from "babylonjs/Maths/math";
  12458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12459. import { Scene } from "babylonjs/scene";
  12460. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12461. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12462. /**
  12463. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12464. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12466. */
  12467. export class FreeCamera extends TargetCamera {
  12468. /**
  12469. * Define the collision ellipsoid of the camera.
  12470. * This is helpful to simulate a camera body like the player body around the camera
  12471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12472. */
  12473. ellipsoid: Vector3;
  12474. /**
  12475. * Define an offset for the position of the ellipsoid around the camera.
  12476. * This can be helpful to determine the center of the body near the gravity center of the body
  12477. * instead of its head.
  12478. */
  12479. ellipsoidOffset: Vector3;
  12480. /**
  12481. * Enable or disable collisions of the camera with the rest of the scene objects.
  12482. */
  12483. checkCollisions: boolean;
  12484. /**
  12485. * Enable or disable gravity on the camera.
  12486. */
  12487. applyGravity: boolean;
  12488. /**
  12489. * Define the input manager associated to the camera.
  12490. */
  12491. inputs: FreeCameraInputsManager;
  12492. /**
  12493. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12494. * Higher values reduce sensitivity.
  12495. */
  12496. /**
  12497. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12498. * Higher values reduce sensitivity.
  12499. */
  12500. angularSensibility: number;
  12501. /**
  12502. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12503. */
  12504. keysUp: number[];
  12505. /**
  12506. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12507. */
  12508. keysDown: number[];
  12509. /**
  12510. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12511. */
  12512. keysLeft: number[];
  12513. /**
  12514. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12515. */
  12516. keysRight: number[];
  12517. /**
  12518. * Event raised when the camera collide with a mesh in the scene.
  12519. */
  12520. onCollide: (collidedMesh: AbstractMesh) => void;
  12521. private _collider;
  12522. private _needMoveForGravity;
  12523. private _oldPosition;
  12524. private _diffPosition;
  12525. private _newPosition;
  12526. /** @hidden */
  12527. _localDirection: Vector3;
  12528. /** @hidden */
  12529. _transformedDirection: Vector3;
  12530. /**
  12531. * Instantiates a Free Camera.
  12532. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12533. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12534. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12535. * @param name Define the name of the camera in the scene
  12536. * @param position Define the start position of the camera in the scene
  12537. * @param scene Define the scene the camera belongs to
  12538. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12539. */
  12540. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12541. /**
  12542. * Attached controls to the current camera.
  12543. * @param element Defines the element the controls should be listened from
  12544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12545. */
  12546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12547. /**
  12548. * Detach the current controls from the camera.
  12549. * The camera will stop reacting to inputs.
  12550. * @param element Defines the element to stop listening the inputs from
  12551. */
  12552. detachControl(element: HTMLElement): void;
  12553. private _collisionMask;
  12554. /**
  12555. * Define a collision mask to limit the list of object the camera can collide with
  12556. */
  12557. collisionMask: number;
  12558. /** @hidden */
  12559. _collideWithWorld(displacement: Vector3): void;
  12560. private _onCollisionPositionChange;
  12561. /** @hidden */
  12562. _checkInputs(): void;
  12563. /** @hidden */
  12564. _decideIfNeedsToMove(): boolean;
  12565. /** @hidden */
  12566. _updatePosition(): void;
  12567. /**
  12568. * Destroy the camera and release the current resources hold by it.
  12569. */
  12570. dispose(): void;
  12571. /**
  12572. * Gets the current object class name.
  12573. * @return the class name
  12574. */
  12575. getClassName(): string;
  12576. }
  12577. }
  12578. declare module "babylonjs/Gamepads/gamepad" {
  12579. import { Observable } from "babylonjs/Misc/observable";
  12580. /**
  12581. * Represents a gamepad control stick position
  12582. */
  12583. export class StickValues {
  12584. /**
  12585. * The x component of the control stick
  12586. */
  12587. x: number;
  12588. /**
  12589. * The y component of the control stick
  12590. */
  12591. y: number;
  12592. /**
  12593. * Initializes the gamepad x and y control stick values
  12594. * @param x The x component of the gamepad control stick value
  12595. * @param y The y component of the gamepad control stick value
  12596. */
  12597. constructor(
  12598. /**
  12599. * The x component of the control stick
  12600. */
  12601. x: number,
  12602. /**
  12603. * The y component of the control stick
  12604. */
  12605. y: number);
  12606. }
  12607. /**
  12608. * An interface which manages callbacks for gamepad button changes
  12609. */
  12610. export interface GamepadButtonChanges {
  12611. /**
  12612. * Called when a gamepad has been changed
  12613. */
  12614. changed: boolean;
  12615. /**
  12616. * Called when a gamepad press event has been triggered
  12617. */
  12618. pressChanged: boolean;
  12619. /**
  12620. * Called when a touch event has been triggered
  12621. */
  12622. touchChanged: boolean;
  12623. /**
  12624. * Called when a value has changed
  12625. */
  12626. valueChanged: boolean;
  12627. }
  12628. /**
  12629. * Represents a gamepad
  12630. */
  12631. export class Gamepad {
  12632. /**
  12633. * The id of the gamepad
  12634. */
  12635. id: string;
  12636. /**
  12637. * The index of the gamepad
  12638. */
  12639. index: number;
  12640. /**
  12641. * The browser gamepad
  12642. */
  12643. browserGamepad: any;
  12644. /**
  12645. * Specifies what type of gamepad this represents
  12646. */
  12647. type: number;
  12648. private _leftStick;
  12649. private _rightStick;
  12650. /** @hidden */
  12651. _isConnected: boolean;
  12652. private _leftStickAxisX;
  12653. private _leftStickAxisY;
  12654. private _rightStickAxisX;
  12655. private _rightStickAxisY;
  12656. /**
  12657. * Triggered when the left control stick has been changed
  12658. */
  12659. private _onleftstickchanged;
  12660. /**
  12661. * Triggered when the right control stick has been changed
  12662. */
  12663. private _onrightstickchanged;
  12664. /**
  12665. * Represents a gamepad controller
  12666. */
  12667. static GAMEPAD: number;
  12668. /**
  12669. * Represents a generic controller
  12670. */
  12671. static GENERIC: number;
  12672. /**
  12673. * Represents an XBox controller
  12674. */
  12675. static XBOX: number;
  12676. /**
  12677. * Represents a pose-enabled controller
  12678. */
  12679. static POSE_ENABLED: number;
  12680. /**
  12681. * Specifies whether the left control stick should be Y-inverted
  12682. */
  12683. protected _invertLeftStickY: boolean;
  12684. /**
  12685. * Specifies if the gamepad has been connected
  12686. */
  12687. readonly isConnected: boolean;
  12688. /**
  12689. * Initializes the gamepad
  12690. * @param id The id of the gamepad
  12691. * @param index The index of the gamepad
  12692. * @param browserGamepad The browser gamepad
  12693. * @param leftStickX The x component of the left joystick
  12694. * @param leftStickY The y component of the left joystick
  12695. * @param rightStickX The x component of the right joystick
  12696. * @param rightStickY The y component of the right joystick
  12697. */
  12698. constructor(
  12699. /**
  12700. * The id of the gamepad
  12701. */
  12702. id: string,
  12703. /**
  12704. * The index of the gamepad
  12705. */
  12706. index: number,
  12707. /**
  12708. * The browser gamepad
  12709. */
  12710. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12711. /**
  12712. * Callback triggered when the left joystick has changed
  12713. * @param callback
  12714. */
  12715. onleftstickchanged(callback: (values: StickValues) => void): void;
  12716. /**
  12717. * Callback triggered when the right joystick has changed
  12718. * @param callback
  12719. */
  12720. onrightstickchanged(callback: (values: StickValues) => void): void;
  12721. /**
  12722. * Gets the left joystick
  12723. */
  12724. /**
  12725. * Sets the left joystick values
  12726. */
  12727. leftStick: StickValues;
  12728. /**
  12729. * Gets the right joystick
  12730. */
  12731. /**
  12732. * Sets the right joystick value
  12733. */
  12734. rightStick: StickValues;
  12735. /**
  12736. * Updates the gamepad joystick positions
  12737. */
  12738. update(): void;
  12739. /**
  12740. * Disposes the gamepad
  12741. */
  12742. dispose(): void;
  12743. }
  12744. /**
  12745. * Represents a generic gamepad
  12746. */
  12747. export class GenericPad extends Gamepad {
  12748. private _buttons;
  12749. private _onbuttondown;
  12750. private _onbuttonup;
  12751. /**
  12752. * Observable triggered when a button has been pressed
  12753. */
  12754. onButtonDownObservable: Observable<number>;
  12755. /**
  12756. * Observable triggered when a button has been released
  12757. */
  12758. onButtonUpObservable: Observable<number>;
  12759. /**
  12760. * Callback triggered when a button has been pressed
  12761. * @param callback Called when a button has been pressed
  12762. */
  12763. onbuttondown(callback: (buttonPressed: number) => void): void;
  12764. /**
  12765. * Callback triggered when a button has been released
  12766. * @param callback Called when a button has been released
  12767. */
  12768. onbuttonup(callback: (buttonReleased: number) => void): void;
  12769. /**
  12770. * Initializes the generic gamepad
  12771. * @param id The id of the generic gamepad
  12772. * @param index The index of the generic gamepad
  12773. * @param browserGamepad The browser gamepad
  12774. */
  12775. constructor(id: string, index: number, browserGamepad: any);
  12776. private _setButtonValue;
  12777. /**
  12778. * Updates the generic gamepad
  12779. */
  12780. update(): void;
  12781. /**
  12782. * Disposes the generic gamepad
  12783. */
  12784. dispose(): void;
  12785. }
  12786. }
  12787. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12788. import { Observable } from "babylonjs/Misc/observable";
  12789. import { Nullable } from "babylonjs/types";
  12790. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12793. import { Ray } from "babylonjs/Culling/ray";
  12794. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12795. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12796. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12797. /**
  12798. * Defines the types of pose enabled controllers that are supported
  12799. */
  12800. export enum PoseEnabledControllerType {
  12801. /**
  12802. * HTC Vive
  12803. */
  12804. VIVE = 0,
  12805. /**
  12806. * Oculus Rift
  12807. */
  12808. OCULUS = 1,
  12809. /**
  12810. * Windows mixed reality
  12811. */
  12812. WINDOWS = 2,
  12813. /**
  12814. * Samsung gear VR
  12815. */
  12816. GEAR_VR = 3,
  12817. /**
  12818. * Google Daydream
  12819. */
  12820. DAYDREAM = 4,
  12821. /**
  12822. * Generic
  12823. */
  12824. GENERIC = 5
  12825. }
  12826. /**
  12827. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12828. */
  12829. export interface MutableGamepadButton {
  12830. /**
  12831. * Value of the button/trigger
  12832. */
  12833. value: number;
  12834. /**
  12835. * If the button/trigger is currently touched
  12836. */
  12837. touched: boolean;
  12838. /**
  12839. * If the button/trigger is currently pressed
  12840. */
  12841. pressed: boolean;
  12842. }
  12843. /**
  12844. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12845. * @hidden
  12846. */
  12847. export interface ExtendedGamepadButton extends GamepadButton {
  12848. /**
  12849. * If the button/trigger is currently pressed
  12850. */
  12851. readonly pressed: boolean;
  12852. /**
  12853. * If the button/trigger is currently touched
  12854. */
  12855. readonly touched: boolean;
  12856. /**
  12857. * Value of the button/trigger
  12858. */
  12859. readonly value: number;
  12860. }
  12861. /** @hidden */
  12862. export interface _GamePadFactory {
  12863. /**
  12864. * Returns wether or not the current gamepad can be created for this type of controller.
  12865. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12866. * @returns true if it can be created, otherwise false
  12867. */
  12868. canCreate(gamepadInfo: any): boolean;
  12869. /**
  12870. * Creates a new instance of the Gamepad.
  12871. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12872. * @returns the new gamepad instance
  12873. */
  12874. create(gamepadInfo: any): Gamepad;
  12875. }
  12876. /**
  12877. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12878. */
  12879. export class PoseEnabledControllerHelper {
  12880. /** @hidden */
  12881. static _ControllerFactories: _GamePadFactory[];
  12882. /** @hidden */
  12883. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12884. /**
  12885. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12886. * @param vrGamepad the gamepad to initialized
  12887. * @returns a vr controller of the type the gamepad identified as
  12888. */
  12889. static InitiateController(vrGamepad: any): Gamepad;
  12890. }
  12891. /**
  12892. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12893. */
  12894. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12895. private _deviceRoomPosition;
  12896. private _deviceRoomRotationQuaternion;
  12897. /**
  12898. * The device position in babylon space
  12899. */
  12900. devicePosition: Vector3;
  12901. /**
  12902. * The device rotation in babylon space
  12903. */
  12904. deviceRotationQuaternion: Quaternion;
  12905. /**
  12906. * The scale factor of the device in babylon space
  12907. */
  12908. deviceScaleFactor: number;
  12909. /**
  12910. * (Likely devicePosition should be used instead) The device position in its room space
  12911. */
  12912. position: Vector3;
  12913. /**
  12914. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12915. */
  12916. rotationQuaternion: Quaternion;
  12917. /**
  12918. * The type of controller (Eg. Windows mixed reality)
  12919. */
  12920. controllerType: PoseEnabledControllerType;
  12921. protected _calculatedPosition: Vector3;
  12922. private _calculatedRotation;
  12923. /**
  12924. * The raw pose from the device
  12925. */
  12926. rawPose: DevicePose;
  12927. private _trackPosition;
  12928. private _maxRotationDistFromHeadset;
  12929. private _draggedRoomRotation;
  12930. /**
  12931. * @hidden
  12932. */
  12933. _disableTrackPosition(fixedPosition: Vector3): void;
  12934. /**
  12935. * Internal, the mesh attached to the controller
  12936. * @hidden
  12937. */
  12938. _mesh: Nullable<AbstractMesh>;
  12939. private _poseControlledCamera;
  12940. private _leftHandSystemQuaternion;
  12941. /**
  12942. * Internal, matrix used to convert room space to babylon space
  12943. * @hidden
  12944. */
  12945. _deviceToWorld: Matrix;
  12946. /**
  12947. * Node to be used when casting a ray from the controller
  12948. * @hidden
  12949. */
  12950. _pointingPoseNode: Nullable<TransformNode>;
  12951. /**
  12952. * Name of the child mesh that can be used to cast a ray from the controller
  12953. */
  12954. static readonly POINTING_POSE: string;
  12955. /**
  12956. * Creates a new PoseEnabledController from a gamepad
  12957. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12958. */
  12959. constructor(browserGamepad: any);
  12960. private _workingMatrix;
  12961. /**
  12962. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12963. */
  12964. update(): void;
  12965. /**
  12966. * Updates only the pose device and mesh without doing any button event checking
  12967. */
  12968. protected _updatePoseAndMesh(): void;
  12969. /**
  12970. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12971. * @param poseData raw pose fromthe device
  12972. */
  12973. updateFromDevice(poseData: DevicePose): void;
  12974. /**
  12975. * @hidden
  12976. */
  12977. _meshAttachedObservable: Observable<AbstractMesh>;
  12978. /**
  12979. * Attaches a mesh to the controller
  12980. * @param mesh the mesh to be attached
  12981. */
  12982. attachToMesh(mesh: AbstractMesh): void;
  12983. /**
  12984. * Attaches the controllers mesh to a camera
  12985. * @param camera the camera the mesh should be attached to
  12986. */
  12987. attachToPoseControlledCamera(camera: TargetCamera): void;
  12988. /**
  12989. * Disposes of the controller
  12990. */
  12991. dispose(): void;
  12992. /**
  12993. * The mesh that is attached to the controller
  12994. */
  12995. readonly mesh: Nullable<AbstractMesh>;
  12996. /**
  12997. * Gets the ray of the controller in the direction the controller is pointing
  12998. * @param length the length the resulting ray should be
  12999. * @returns a ray in the direction the controller is pointing
  13000. */
  13001. getForwardRay(length?: number): Ray;
  13002. }
  13003. }
  13004. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13005. import { Observable } from "babylonjs/Misc/observable";
  13006. import { Scene } from "babylonjs/scene";
  13007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13008. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13009. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13010. /**
  13011. * Defines the WebVRController object that represents controllers tracked in 3D space
  13012. */
  13013. export abstract class WebVRController extends PoseEnabledController {
  13014. /**
  13015. * Internal, the default controller model for the controller
  13016. */
  13017. protected _defaultModel: AbstractMesh;
  13018. /**
  13019. * Fired when the trigger state has changed
  13020. */
  13021. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13022. /**
  13023. * Fired when the main button state has changed
  13024. */
  13025. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13026. /**
  13027. * Fired when the secondary button state has changed
  13028. */
  13029. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13030. /**
  13031. * Fired when the pad state has changed
  13032. */
  13033. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13034. /**
  13035. * Fired when controllers stick values have changed
  13036. */
  13037. onPadValuesChangedObservable: Observable<StickValues>;
  13038. /**
  13039. * Array of button availible on the controller
  13040. */
  13041. protected _buttons: Array<MutableGamepadButton>;
  13042. private _onButtonStateChange;
  13043. /**
  13044. * Fired when a controller button's state has changed
  13045. * @param callback the callback containing the button that was modified
  13046. */
  13047. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13048. /**
  13049. * X and Y axis corrisponding to the controllers joystick
  13050. */
  13051. pad: StickValues;
  13052. /**
  13053. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13054. */
  13055. hand: string;
  13056. /**
  13057. * The default controller model for the controller
  13058. */
  13059. readonly defaultModel: AbstractMesh;
  13060. /**
  13061. * Creates a new WebVRController from a gamepad
  13062. * @param vrGamepad the gamepad that the WebVRController should be created from
  13063. */
  13064. constructor(vrGamepad: any);
  13065. /**
  13066. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13067. */
  13068. update(): void;
  13069. /**
  13070. * Function to be called when a button is modified
  13071. */
  13072. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13073. /**
  13074. * Loads a mesh and attaches it to the controller
  13075. * @param scene the scene the mesh should be added to
  13076. * @param meshLoaded callback for when the mesh has been loaded
  13077. */
  13078. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13079. private _setButtonValue;
  13080. private _changes;
  13081. private _checkChanges;
  13082. /**
  13083. * Disposes of th webVRCOntroller
  13084. */
  13085. dispose(): void;
  13086. }
  13087. }
  13088. declare module "babylonjs/Lights/hemisphericLight" {
  13089. import { Nullable } from "babylonjs/types";
  13090. import { Scene } from "babylonjs/scene";
  13091. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13092. import { Effect } from "babylonjs/Materials/effect";
  13093. import { Light } from "babylonjs/Lights/light";
  13094. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13095. /**
  13096. * The HemisphericLight simulates the ambient environment light,
  13097. * so the passed direction is the light reflection direction, not the incoming direction.
  13098. */
  13099. export class HemisphericLight extends Light {
  13100. /**
  13101. * The groundColor is the light in the opposite direction to the one specified during creation.
  13102. * 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.
  13103. */
  13104. groundColor: Color3;
  13105. /**
  13106. * The light reflection direction, not the incoming direction.
  13107. */
  13108. direction: Vector3;
  13109. /**
  13110. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13111. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13112. * The HemisphericLight can't cast shadows.
  13113. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13114. * @param name The friendly name of the light
  13115. * @param direction The direction of the light reflection
  13116. * @param scene The scene the light belongs to
  13117. */
  13118. constructor(name: string, direction: Vector3, scene: Scene);
  13119. protected _buildUniformLayout(): void;
  13120. /**
  13121. * Returns the string "HemisphericLight".
  13122. * @return The class name
  13123. */
  13124. getClassName(): string;
  13125. /**
  13126. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13127. * Returns the updated direction.
  13128. * @param target The target the direction should point to
  13129. * @return The computed direction
  13130. */
  13131. setDirectionToTarget(target: Vector3): Vector3;
  13132. /**
  13133. * Returns the shadow generator associated to the light.
  13134. * @returns Always null for hemispheric lights because it does not support shadows.
  13135. */
  13136. getShadowGenerator(): Nullable<IShadowGenerator>;
  13137. /**
  13138. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13139. * @param effect The effect to update
  13140. * @param lightIndex The index of the light in the effect to update
  13141. * @returns The hemispheric light
  13142. */
  13143. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13144. /**
  13145. * Computes the world matrix of the node
  13146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13147. * @param useWasUpdatedFlag defines a reserved property
  13148. * @returns the world matrix
  13149. */
  13150. computeWorldMatrix(): Matrix;
  13151. /**
  13152. * Returns the integer 3.
  13153. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13154. */
  13155. getTypeID(): number;
  13156. /**
  13157. * Prepares the list of defines specific to the light type.
  13158. * @param defines the list of defines
  13159. * @param lightIndex defines the index of the light for the effect
  13160. */
  13161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13162. }
  13163. }
  13164. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13165. /** @hidden */
  13166. export var vrMultiviewToSingleviewPixelShader: {
  13167. name: string;
  13168. shader: string;
  13169. };
  13170. }
  13171. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13173. import { Scene } from "babylonjs/scene";
  13174. /**
  13175. * Renders to multiple views with a single draw call
  13176. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13177. */
  13178. export class MultiviewRenderTarget extends RenderTargetTexture {
  13179. /**
  13180. * Creates a multiview render target
  13181. * @param scene scene used with the render target
  13182. * @param size the size of the render target (used for each view)
  13183. */
  13184. constructor(scene: Scene, size?: number | {
  13185. width: number;
  13186. height: number;
  13187. } | {
  13188. ratio: number;
  13189. });
  13190. /**
  13191. * @hidden
  13192. * @param faceIndex the face index, if its a cube texture
  13193. */
  13194. _bindFrameBuffer(faceIndex?: number): void;
  13195. /**
  13196. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13197. * @returns the view count
  13198. */
  13199. getViewCount(): number;
  13200. }
  13201. }
  13202. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13203. import { Camera } from "babylonjs/Cameras/camera";
  13204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13205. import { Nullable } from "babylonjs/types";
  13206. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13207. import { Matrix } from "babylonjs/Maths/math";
  13208. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13209. module "babylonjs/Engines/engine" {
  13210. interface Engine {
  13211. /**
  13212. * Creates a new multiview render target
  13213. * @param width defines the width of the texture
  13214. * @param height defines the height of the texture
  13215. * @returns the created multiview texture
  13216. */
  13217. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13218. /**
  13219. * Binds a multiview framebuffer to be drawn to
  13220. * @param multiviewTexture texture to bind
  13221. */
  13222. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13223. }
  13224. }
  13225. module "babylonjs/Cameras/camera" {
  13226. interface Camera {
  13227. /**
  13228. * @hidden
  13229. * 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)
  13230. */
  13231. _useMultiviewToSingleView: boolean;
  13232. /**
  13233. * @hidden
  13234. * 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)
  13235. */
  13236. _multiviewTexture: Nullable<RenderTargetTexture>;
  13237. /**
  13238. * @hidden
  13239. * ensures the multiview texture of the camera exists and has the specified width/height
  13240. * @param width height to set on the multiview texture
  13241. * @param height width to set on the multiview texture
  13242. */
  13243. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13244. }
  13245. }
  13246. module "babylonjs/scene" {
  13247. interface Scene {
  13248. /** @hidden */
  13249. _transformMatrixR: Matrix;
  13250. /** @hidden */
  13251. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13252. /** @hidden */
  13253. _createMultiviewUbo(): void;
  13254. /** @hidden */
  13255. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13256. /** @hidden */
  13257. _renderMultiviewToSingleView(camera: Camera): void;
  13258. }
  13259. }
  13260. }
  13261. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13262. import { Camera } from "babylonjs/Cameras/camera";
  13263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13264. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13265. import "babylonjs/Engines/Extensions/engine.multiview";
  13266. /**
  13267. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13268. * This will not be used for webXR as it supports displaying texture arrays directly
  13269. */
  13270. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13271. /**
  13272. * Initializes a VRMultiviewToSingleview
  13273. * @param name name of the post process
  13274. * @param camera camera to be applied to
  13275. * @param scaleFactor scaling factor to the size of the output texture
  13276. */
  13277. constructor(name: string, camera: Camera, scaleFactor: number);
  13278. }
  13279. }
  13280. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13281. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13282. import { Nullable } from "babylonjs/types";
  13283. import { Observable } from "babylonjs/Misc/observable";
  13284. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13285. import { Scene } from "babylonjs/scene";
  13286. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13287. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13288. import { Node } from "babylonjs/node";
  13289. import { Ray } from "babylonjs/Culling/ray";
  13290. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13291. /**
  13292. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13293. * IMPORTANT!! The data is right-hand data.
  13294. * @export
  13295. * @interface DevicePose
  13296. */
  13297. export interface DevicePose {
  13298. /**
  13299. * The position of the device, values in array are [x,y,z].
  13300. */
  13301. readonly position: Nullable<Float32Array>;
  13302. /**
  13303. * The linearVelocity of the device, values in array are [x,y,z].
  13304. */
  13305. readonly linearVelocity: Nullable<Float32Array>;
  13306. /**
  13307. * The linearAcceleration of the device, values in array are [x,y,z].
  13308. */
  13309. readonly linearAcceleration: Nullable<Float32Array>;
  13310. /**
  13311. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13312. */
  13313. readonly orientation: Nullable<Float32Array>;
  13314. /**
  13315. * The angularVelocity of the device, values in array are [x,y,z].
  13316. */
  13317. readonly angularVelocity: Nullable<Float32Array>;
  13318. /**
  13319. * The angularAcceleration of the device, values in array are [x,y,z].
  13320. */
  13321. readonly angularAcceleration: Nullable<Float32Array>;
  13322. }
  13323. /**
  13324. * Interface representing a pose controlled object in Babylon.
  13325. * A pose controlled object has both regular pose values as well as pose values
  13326. * from an external device such as a VR head mounted display
  13327. */
  13328. export interface PoseControlled {
  13329. /**
  13330. * The position of the object in babylon space.
  13331. */
  13332. position: Vector3;
  13333. /**
  13334. * The rotation quaternion of the object in babylon space.
  13335. */
  13336. rotationQuaternion: Quaternion;
  13337. /**
  13338. * The position of the device in babylon space.
  13339. */
  13340. devicePosition?: Vector3;
  13341. /**
  13342. * The rotation quaternion of the device in babylon space.
  13343. */
  13344. deviceRotationQuaternion: Quaternion;
  13345. /**
  13346. * The raw pose coming from the device.
  13347. */
  13348. rawPose: Nullable<DevicePose>;
  13349. /**
  13350. * The scale of the device to be used when translating from device space to babylon space.
  13351. */
  13352. deviceScaleFactor: number;
  13353. /**
  13354. * Updates the poseControlled values based on the input device pose.
  13355. * @param poseData the pose data to update the object with
  13356. */
  13357. updateFromDevice(poseData: DevicePose): void;
  13358. }
  13359. /**
  13360. * Set of options to customize the webVRCamera
  13361. */
  13362. export interface WebVROptions {
  13363. /**
  13364. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13365. */
  13366. trackPosition?: boolean;
  13367. /**
  13368. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13369. */
  13370. positionScale?: number;
  13371. /**
  13372. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13373. */
  13374. displayName?: string;
  13375. /**
  13376. * Should the native controller meshes be initialized. (default: true)
  13377. */
  13378. controllerMeshes?: boolean;
  13379. /**
  13380. * Creating a default HemiLight only on controllers. (default: true)
  13381. */
  13382. defaultLightingOnControllers?: boolean;
  13383. /**
  13384. * If you don't want to use the default VR button of the helper. (default: false)
  13385. */
  13386. useCustomVRButton?: boolean;
  13387. /**
  13388. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13389. */
  13390. customVRButton?: HTMLButtonElement;
  13391. /**
  13392. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13393. */
  13394. rayLength?: number;
  13395. /**
  13396. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13397. */
  13398. defaultHeight?: number;
  13399. /**
  13400. * If multiview should be used if availible (default: false)
  13401. */
  13402. useMultiview?: boolean;
  13403. }
  13404. /**
  13405. * This represents a WebVR camera.
  13406. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13407. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13408. */
  13409. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13410. private webVROptions;
  13411. /**
  13412. * @hidden
  13413. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13414. */
  13415. _vrDevice: any;
  13416. /**
  13417. * The rawPose of the vrDevice.
  13418. */
  13419. rawPose: Nullable<DevicePose>;
  13420. private _onVREnabled;
  13421. private _specsVersion;
  13422. private _attached;
  13423. private _frameData;
  13424. protected _descendants: Array<Node>;
  13425. private _deviceRoomPosition;
  13426. /** @hidden */
  13427. _deviceRoomRotationQuaternion: Quaternion;
  13428. private _standingMatrix;
  13429. /**
  13430. * Represents device position in babylon space.
  13431. */
  13432. devicePosition: Vector3;
  13433. /**
  13434. * Represents device rotation in babylon space.
  13435. */
  13436. deviceRotationQuaternion: Quaternion;
  13437. /**
  13438. * The scale of the device to be used when translating from device space to babylon space.
  13439. */
  13440. deviceScaleFactor: number;
  13441. private _deviceToWorld;
  13442. private _worldToDevice;
  13443. /**
  13444. * References to the webVR controllers for the vrDevice.
  13445. */
  13446. controllers: Array<WebVRController>;
  13447. /**
  13448. * Emits an event when a controller is attached.
  13449. */
  13450. onControllersAttachedObservable: Observable<WebVRController[]>;
  13451. /**
  13452. * Emits an event when a controller's mesh has been loaded;
  13453. */
  13454. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13455. /**
  13456. * Emits an event when the HMD's pose has been updated.
  13457. */
  13458. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13459. private _poseSet;
  13460. /**
  13461. * If the rig cameras be used as parent instead of this camera.
  13462. */
  13463. rigParenting: boolean;
  13464. private _lightOnControllers;
  13465. private _defaultHeight?;
  13466. /**
  13467. * Instantiates a WebVRFreeCamera.
  13468. * @param name The name of the WebVRFreeCamera
  13469. * @param position The starting anchor position for the camera
  13470. * @param scene The scene the camera belongs to
  13471. * @param webVROptions a set of customizable options for the webVRCamera
  13472. */
  13473. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13474. /**
  13475. * Gets the device distance from the ground in meters.
  13476. * @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.
  13477. */
  13478. deviceDistanceToRoomGround(): number;
  13479. /**
  13480. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13481. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13482. */
  13483. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13484. /**
  13485. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13486. * @returns A promise with a boolean set to if the standing matrix is supported.
  13487. */
  13488. useStandingMatrixAsync(): Promise<boolean>;
  13489. /**
  13490. * Disposes the camera
  13491. */
  13492. dispose(): void;
  13493. /**
  13494. * Gets a vrController by name.
  13495. * @param name The name of the controller to retreive
  13496. * @returns the controller matching the name specified or null if not found
  13497. */
  13498. getControllerByName(name: string): Nullable<WebVRController>;
  13499. private _leftController;
  13500. /**
  13501. * The controller corrisponding to the users left hand.
  13502. */
  13503. readonly leftController: Nullable<WebVRController>;
  13504. private _rightController;
  13505. /**
  13506. * The controller corrisponding to the users right hand.
  13507. */
  13508. readonly rightController: Nullable<WebVRController>;
  13509. /**
  13510. * Casts a ray forward from the vrCamera's gaze.
  13511. * @param length Length of the ray (default: 100)
  13512. * @returns the ray corrisponding to the gaze
  13513. */
  13514. getForwardRay(length?: number): Ray;
  13515. /**
  13516. * @hidden
  13517. * Updates the camera based on device's frame data
  13518. */
  13519. _checkInputs(): void;
  13520. /**
  13521. * Updates the poseControlled values based on the input device pose.
  13522. * @param poseData Pose coming from the device
  13523. */
  13524. updateFromDevice(poseData: DevicePose): void;
  13525. private _htmlElementAttached;
  13526. private _detachIfAttached;
  13527. /**
  13528. * WebVR's attach control will start broadcasting frames to the device.
  13529. * Note that in certain browsers (chrome for example) this function must be called
  13530. * within a user-interaction callback. Example:
  13531. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13532. *
  13533. * @param element html element to attach the vrDevice to
  13534. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13535. */
  13536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13537. /**
  13538. * Detaches the camera from the html element and disables VR
  13539. *
  13540. * @param element html element to detach from
  13541. */
  13542. detachControl(element: HTMLElement): void;
  13543. /**
  13544. * @returns the name of this class
  13545. */
  13546. getClassName(): string;
  13547. /**
  13548. * Calls resetPose on the vrDisplay
  13549. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13550. */
  13551. resetToCurrentRotation(): void;
  13552. /**
  13553. * @hidden
  13554. * Updates the rig cameras (left and right eye)
  13555. */
  13556. _updateRigCameras(): void;
  13557. private _workingVector;
  13558. private _oneVector;
  13559. private _workingMatrix;
  13560. private updateCacheCalled;
  13561. private _correctPositionIfNotTrackPosition;
  13562. /**
  13563. * @hidden
  13564. * Updates the cached values of the camera
  13565. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13566. */
  13567. _updateCache(ignoreParentClass?: boolean): void;
  13568. /**
  13569. * @hidden
  13570. * Get current device position in babylon world
  13571. */
  13572. _computeDevicePosition(): void;
  13573. /**
  13574. * Updates the current device position and rotation in the babylon world
  13575. */
  13576. update(): void;
  13577. /**
  13578. * @hidden
  13579. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13580. * @returns an identity matrix
  13581. */
  13582. _getViewMatrix(): Matrix;
  13583. private _tmpMatrix;
  13584. /**
  13585. * This function is called by the two RIG cameras.
  13586. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13587. * @hidden
  13588. */
  13589. _getWebVRViewMatrix(): Matrix;
  13590. /** @hidden */
  13591. _getWebVRProjectionMatrix(): Matrix;
  13592. private _onGamepadConnectedObserver;
  13593. private _onGamepadDisconnectedObserver;
  13594. private _updateCacheWhenTrackingDisabledObserver;
  13595. /**
  13596. * Initializes the controllers and their meshes
  13597. */
  13598. initControllers(): void;
  13599. }
  13600. }
  13601. declare module "babylonjs/PostProcesses/postProcess" {
  13602. import { Nullable } from "babylonjs/types";
  13603. import { SmartArray } from "babylonjs/Misc/smartArray";
  13604. import { Observable } from "babylonjs/Misc/observable";
  13605. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13606. import { Camera } from "babylonjs/Cameras/camera";
  13607. import { Effect } from "babylonjs/Materials/effect";
  13608. import "babylonjs/Shaders/postprocess.vertex";
  13609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13611. import { Engine } from "babylonjs/Engines/engine";
  13612. /**
  13613. * Size options for a post process
  13614. */
  13615. export type PostProcessOptions = {
  13616. width: number;
  13617. height: number;
  13618. };
  13619. /**
  13620. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13621. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13622. */
  13623. export class PostProcess {
  13624. /** Name of the PostProcess. */
  13625. name: string;
  13626. /**
  13627. * Gets or sets the unique id of the post process
  13628. */
  13629. uniqueId: number;
  13630. /**
  13631. * Width of the texture to apply the post process on
  13632. */
  13633. width: number;
  13634. /**
  13635. * Height of the texture to apply the post process on
  13636. */
  13637. height: number;
  13638. /**
  13639. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13640. * @hidden
  13641. */
  13642. _outputTexture: Nullable<InternalTexture>;
  13643. /**
  13644. * Sampling mode used by the shader
  13645. * See https://doc.babylonjs.com/classes/3.1/texture
  13646. */
  13647. renderTargetSamplingMode: number;
  13648. /**
  13649. * Clear color to use when screen clearing
  13650. */
  13651. clearColor: Color4;
  13652. /**
  13653. * If the buffer needs to be cleared before applying the post process. (default: true)
  13654. * Should be set to false if shader will overwrite all previous pixels.
  13655. */
  13656. autoClear: boolean;
  13657. /**
  13658. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13659. */
  13660. alphaMode: number;
  13661. /**
  13662. * Sets the setAlphaBlendConstants of the babylon engine
  13663. */
  13664. alphaConstants: Color4;
  13665. /**
  13666. * Animations to be used for the post processing
  13667. */
  13668. animations: import("babylonjs/Animations/animation").Animation[];
  13669. /**
  13670. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13671. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13672. */
  13673. enablePixelPerfectMode: boolean;
  13674. /**
  13675. * Force the postprocess to be applied without taking in account viewport
  13676. */
  13677. forceFullscreenViewport: boolean;
  13678. /**
  13679. * List of inspectable custom properties (used by the Inspector)
  13680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13681. */
  13682. inspectableCustomProperties: IInspectable[];
  13683. /**
  13684. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13685. *
  13686. * | Value | Type | Description |
  13687. * | ----- | ----------------------------------- | ----------- |
  13688. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13689. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13690. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13691. *
  13692. */
  13693. scaleMode: number;
  13694. /**
  13695. * Force textures to be a power of two (default: false)
  13696. */
  13697. alwaysForcePOT: boolean;
  13698. private _samples;
  13699. /**
  13700. * Number of sample textures (default: 1)
  13701. */
  13702. samples: number;
  13703. /**
  13704. * Modify the scale of the post process to be the same as the viewport (default: false)
  13705. */
  13706. adaptScaleToCurrentViewport: boolean;
  13707. private _camera;
  13708. private _scene;
  13709. private _engine;
  13710. private _options;
  13711. private _reusable;
  13712. private _textureType;
  13713. /**
  13714. * Smart array of input and output textures for the post process.
  13715. * @hidden
  13716. */
  13717. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13718. /**
  13719. * The index in _textures that corresponds to the output texture.
  13720. * @hidden
  13721. */
  13722. _currentRenderTextureInd: number;
  13723. private _effect;
  13724. private _samplers;
  13725. private _fragmentUrl;
  13726. private _vertexUrl;
  13727. private _parameters;
  13728. private _scaleRatio;
  13729. protected _indexParameters: any;
  13730. private _shareOutputWithPostProcess;
  13731. private _texelSize;
  13732. private _forcedOutputTexture;
  13733. /**
  13734. * Returns the fragment url or shader name used in the post process.
  13735. * @returns the fragment url or name in the shader store.
  13736. */
  13737. getEffectName(): string;
  13738. /**
  13739. * An event triggered when the postprocess is activated.
  13740. */
  13741. onActivateObservable: Observable<Camera>;
  13742. private _onActivateObserver;
  13743. /**
  13744. * A function that is added to the onActivateObservable
  13745. */
  13746. onActivate: Nullable<(camera: Camera) => void>;
  13747. /**
  13748. * An event triggered when the postprocess changes its size.
  13749. */
  13750. onSizeChangedObservable: Observable<PostProcess>;
  13751. private _onSizeChangedObserver;
  13752. /**
  13753. * A function that is added to the onSizeChangedObservable
  13754. */
  13755. onSizeChanged: (postProcess: PostProcess) => void;
  13756. /**
  13757. * An event triggered when the postprocess applies its effect.
  13758. */
  13759. onApplyObservable: Observable<Effect>;
  13760. private _onApplyObserver;
  13761. /**
  13762. * A function that is added to the onApplyObservable
  13763. */
  13764. onApply: (effect: Effect) => void;
  13765. /**
  13766. * An event triggered before rendering the postprocess
  13767. */
  13768. onBeforeRenderObservable: Observable<Effect>;
  13769. private _onBeforeRenderObserver;
  13770. /**
  13771. * A function that is added to the onBeforeRenderObservable
  13772. */
  13773. onBeforeRender: (effect: Effect) => void;
  13774. /**
  13775. * An event triggered after rendering the postprocess
  13776. */
  13777. onAfterRenderObservable: Observable<Effect>;
  13778. private _onAfterRenderObserver;
  13779. /**
  13780. * A function that is added to the onAfterRenderObservable
  13781. */
  13782. onAfterRender: (efect: Effect) => void;
  13783. /**
  13784. * 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
  13785. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13786. */
  13787. inputTexture: InternalTexture;
  13788. /**
  13789. * Gets the camera which post process is applied to.
  13790. * @returns The camera the post process is applied to.
  13791. */
  13792. getCamera(): Camera;
  13793. /**
  13794. * Gets the texel size of the postprocess.
  13795. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13796. */
  13797. readonly texelSize: Vector2;
  13798. /**
  13799. * Creates a new instance PostProcess
  13800. * @param name The name of the PostProcess.
  13801. * @param fragmentUrl The url of the fragment shader to be used.
  13802. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13803. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13804. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13805. * @param camera The camera to apply the render pass to.
  13806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13807. * @param engine The engine which the post process will be applied. (default: current engine)
  13808. * @param reusable If the post process can be reused on the same frame. (default: false)
  13809. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13810. * @param textureType Type of textures used when performing the post process. (default: 0)
  13811. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13812. * @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
  13813. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13814. */
  13815. constructor(
  13816. /** Name of the PostProcess. */
  13817. 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);
  13818. /**
  13819. * Gets a string idenfifying the name of the class
  13820. * @returns "PostProcess" string
  13821. */
  13822. getClassName(): string;
  13823. /**
  13824. * Gets the engine which this post process belongs to.
  13825. * @returns The engine the post process was enabled with.
  13826. */
  13827. getEngine(): Engine;
  13828. /**
  13829. * The effect that is created when initializing the post process.
  13830. * @returns The created effect corrisponding the the postprocess.
  13831. */
  13832. getEffect(): Effect;
  13833. /**
  13834. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13835. * @param postProcess The post process to share the output with.
  13836. * @returns This post process.
  13837. */
  13838. shareOutputWith(postProcess: PostProcess): PostProcess;
  13839. /**
  13840. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13841. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13842. */
  13843. useOwnOutput(): void;
  13844. /**
  13845. * Updates the effect with the current post process compile time values and recompiles the shader.
  13846. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13847. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13848. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13849. * @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
  13850. * @param onCompiled Called when the shader has been compiled.
  13851. * @param onError Called if there is an error when compiling a shader.
  13852. */
  13853. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13854. /**
  13855. * The post process is reusable if it can be used multiple times within one frame.
  13856. * @returns If the post process is reusable
  13857. */
  13858. isReusable(): boolean;
  13859. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13860. markTextureDirty(): void;
  13861. /**
  13862. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13863. * 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.
  13864. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13865. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13866. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13867. * @returns The target texture that was bound to be written to.
  13868. */
  13869. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13870. /**
  13871. * If the post process is supported.
  13872. */
  13873. readonly isSupported: boolean;
  13874. /**
  13875. * The aspect ratio of the output texture.
  13876. */
  13877. readonly aspectRatio: number;
  13878. /**
  13879. * Get a value indicating if the post-process is ready to be used
  13880. * @returns true if the post-process is ready (shader is compiled)
  13881. */
  13882. isReady(): boolean;
  13883. /**
  13884. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13885. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13886. */
  13887. apply(): Nullable<Effect>;
  13888. private _disposeTextures;
  13889. /**
  13890. * Disposes the post process.
  13891. * @param camera The camera to dispose the post process on.
  13892. */
  13893. dispose(camera?: Camera): void;
  13894. }
  13895. }
  13896. declare module "babylonjs/PostProcesses/postProcessManager" {
  13897. import { Nullable } from "babylonjs/types";
  13898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13900. import { Scene } from "babylonjs/scene";
  13901. /**
  13902. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13903. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13904. */
  13905. export class PostProcessManager {
  13906. private _scene;
  13907. private _indexBuffer;
  13908. private _vertexBuffers;
  13909. /**
  13910. * Creates a new instance PostProcess
  13911. * @param scene The scene that the post process is associated with.
  13912. */
  13913. constructor(scene: Scene);
  13914. private _prepareBuffers;
  13915. private _buildIndexBuffer;
  13916. /**
  13917. * Rebuilds the vertex buffers of the manager.
  13918. * @hidden
  13919. */
  13920. _rebuild(): void;
  13921. /**
  13922. * Prepares a frame to be run through a post process.
  13923. * @param sourceTexture The input texture to the post procesess. (default: null)
  13924. * @param postProcesses An array of post processes to be run. (default: null)
  13925. * @returns True if the post processes were able to be run.
  13926. * @hidden
  13927. */
  13928. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13929. /**
  13930. * Manually render a set of post processes to a texture.
  13931. * @param postProcesses An array of post processes to be run.
  13932. * @param targetTexture The target texture to render to.
  13933. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13934. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13935. * @param lodLevel defines which lod of the texture to render to
  13936. */
  13937. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13938. /**
  13939. * Finalize the result of the output of the postprocesses.
  13940. * @param doNotPresent If true the result will not be displayed to the screen.
  13941. * @param targetTexture The target texture to render to.
  13942. * @param faceIndex The index of the face to bind the target texture to.
  13943. * @param postProcesses The array of post processes to render.
  13944. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13945. * @hidden
  13946. */
  13947. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13948. /**
  13949. * Disposes of the post process manager.
  13950. */
  13951. dispose(): void;
  13952. }
  13953. }
  13954. declare module "babylonjs/Layers/layerSceneComponent" {
  13955. import { Scene } from "babylonjs/scene";
  13956. import { ISceneComponent } from "babylonjs/sceneComponent";
  13957. import { Layer } from "babylonjs/Layers/layer";
  13958. module "babylonjs/abstractScene" {
  13959. interface AbstractScene {
  13960. /**
  13961. * The list of layers (background and foreground) of the scene
  13962. */
  13963. layers: Array<Layer>;
  13964. }
  13965. }
  13966. /**
  13967. * Defines the layer scene component responsible to manage any layers
  13968. * in a given scene.
  13969. */
  13970. export class LayerSceneComponent implements ISceneComponent {
  13971. /**
  13972. * The component name helpfull to identify the component in the list of scene components.
  13973. */
  13974. readonly name: string;
  13975. /**
  13976. * The scene the component belongs to.
  13977. */
  13978. scene: Scene;
  13979. private _engine;
  13980. /**
  13981. * Creates a new instance of the component for the given scene
  13982. * @param scene Defines the scene to register the component in
  13983. */
  13984. constructor(scene: Scene);
  13985. /**
  13986. * Registers the component in a given scene
  13987. */
  13988. register(): void;
  13989. /**
  13990. * Rebuilds the elements related to this component in case of
  13991. * context lost for instance.
  13992. */
  13993. rebuild(): void;
  13994. /**
  13995. * Disposes the component and the associated ressources.
  13996. */
  13997. dispose(): void;
  13998. private _draw;
  13999. private _drawCameraPredicate;
  14000. private _drawCameraBackground;
  14001. private _drawCameraForeground;
  14002. private _drawRenderTargetPredicate;
  14003. private _drawRenderTargetBackground;
  14004. private _drawRenderTargetForeground;
  14005. }
  14006. }
  14007. declare module "babylonjs/Shaders/layer.fragment" {
  14008. /** @hidden */
  14009. export var layerPixelShader: {
  14010. name: string;
  14011. shader: string;
  14012. };
  14013. }
  14014. declare module "babylonjs/Shaders/layer.vertex" {
  14015. /** @hidden */
  14016. export var layerVertexShader: {
  14017. name: string;
  14018. shader: string;
  14019. };
  14020. }
  14021. declare module "babylonjs/Layers/layer" {
  14022. import { Observable } from "babylonjs/Misc/observable";
  14023. import { Nullable } from "babylonjs/types";
  14024. import { Scene } from "babylonjs/scene";
  14025. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14026. import { Texture } from "babylonjs/Materials/Textures/texture";
  14027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14028. import "babylonjs/Shaders/layer.fragment";
  14029. import "babylonjs/Shaders/layer.vertex";
  14030. /**
  14031. * This represents a full screen 2d layer.
  14032. * This can be useful to display a picture in the background of your scene for instance.
  14033. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14034. */
  14035. export class Layer {
  14036. /**
  14037. * Define the name of the layer.
  14038. */
  14039. name: string;
  14040. /**
  14041. * Define the texture the layer should display.
  14042. */
  14043. texture: Nullable<Texture>;
  14044. /**
  14045. * Is the layer in background or foreground.
  14046. */
  14047. isBackground: boolean;
  14048. /**
  14049. * Define the color of the layer (instead of texture).
  14050. */
  14051. color: Color4;
  14052. /**
  14053. * Define the scale of the layer in order to zoom in out of the texture.
  14054. */
  14055. scale: Vector2;
  14056. /**
  14057. * Define an offset for the layer in order to shift the texture.
  14058. */
  14059. offset: Vector2;
  14060. /**
  14061. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14062. */
  14063. alphaBlendingMode: number;
  14064. /**
  14065. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14066. * Alpha test will not mix with the background color in case of transparency.
  14067. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14068. */
  14069. alphaTest: boolean;
  14070. /**
  14071. * Define a mask to restrict the layer to only some of the scene cameras.
  14072. */
  14073. layerMask: number;
  14074. /**
  14075. * Define the list of render target the layer is visible into.
  14076. */
  14077. renderTargetTextures: RenderTargetTexture[];
  14078. /**
  14079. * Define if the layer is only used in renderTarget or if it also
  14080. * renders in the main frame buffer of the canvas.
  14081. */
  14082. renderOnlyInRenderTargetTextures: boolean;
  14083. private _scene;
  14084. private _vertexBuffers;
  14085. private _indexBuffer;
  14086. private _effect;
  14087. private _alphaTestEffect;
  14088. /**
  14089. * An event triggered when the layer is disposed.
  14090. */
  14091. onDisposeObservable: Observable<Layer>;
  14092. private _onDisposeObserver;
  14093. /**
  14094. * Back compatibility with callback before the onDisposeObservable existed.
  14095. * The set callback will be triggered when the layer has been disposed.
  14096. */
  14097. onDispose: () => void;
  14098. /**
  14099. * An event triggered before rendering the scene
  14100. */
  14101. onBeforeRenderObservable: Observable<Layer>;
  14102. private _onBeforeRenderObserver;
  14103. /**
  14104. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14105. * The set callback will be triggered just before rendering the layer.
  14106. */
  14107. onBeforeRender: () => void;
  14108. /**
  14109. * An event triggered after rendering the scene
  14110. */
  14111. onAfterRenderObservable: Observable<Layer>;
  14112. private _onAfterRenderObserver;
  14113. /**
  14114. * Back compatibility with callback before the onAfterRenderObservable existed.
  14115. * The set callback will be triggered just after rendering the layer.
  14116. */
  14117. onAfterRender: () => void;
  14118. /**
  14119. * Instantiates a new layer.
  14120. * This represents a full screen 2d layer.
  14121. * This can be useful to display a picture in the background of your scene for instance.
  14122. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14123. * @param name Define the name of the layer in the scene
  14124. * @param imgUrl Define the url of the texture to display in the layer
  14125. * @param scene Define the scene the layer belongs to
  14126. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14127. * @param color Defines a color for the layer
  14128. */
  14129. constructor(
  14130. /**
  14131. * Define the name of the layer.
  14132. */
  14133. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14134. private _createIndexBuffer;
  14135. /** @hidden */
  14136. _rebuild(): void;
  14137. /**
  14138. * Renders the layer in the scene.
  14139. */
  14140. render(): void;
  14141. /**
  14142. * Disposes and releases the associated ressources.
  14143. */
  14144. dispose(): void;
  14145. }
  14146. }
  14147. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14148. import { Scene } from "babylonjs/scene";
  14149. import { ISceneComponent } from "babylonjs/sceneComponent";
  14150. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14151. module "babylonjs/abstractScene" {
  14152. interface AbstractScene {
  14153. /**
  14154. * The list of procedural textures added to the scene
  14155. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14156. */
  14157. proceduralTextures: Array<ProceduralTexture>;
  14158. }
  14159. }
  14160. /**
  14161. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14162. * in a given scene.
  14163. */
  14164. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14165. /**
  14166. * The component name helpfull to identify the component in the list of scene components.
  14167. */
  14168. readonly name: string;
  14169. /**
  14170. * The scene the component belongs to.
  14171. */
  14172. scene: Scene;
  14173. /**
  14174. * Creates a new instance of the component for the given scene
  14175. * @param scene Defines the scene to register the component in
  14176. */
  14177. constructor(scene: Scene);
  14178. /**
  14179. * Registers the component in a given scene
  14180. */
  14181. register(): void;
  14182. /**
  14183. * Rebuilds the elements related to this component in case of
  14184. * context lost for instance.
  14185. */
  14186. rebuild(): void;
  14187. /**
  14188. * Disposes the component and the associated ressources.
  14189. */
  14190. dispose(): void;
  14191. private _beforeClear;
  14192. }
  14193. }
  14194. declare module "babylonjs/Shaders/procedural.vertex" {
  14195. /** @hidden */
  14196. export var proceduralVertexShader: {
  14197. name: string;
  14198. shader: string;
  14199. };
  14200. }
  14201. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14202. import { Observable } from "babylonjs/Misc/observable";
  14203. import { Nullable } from "babylonjs/types";
  14204. import { Scene } from "babylonjs/scene";
  14205. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14206. import { Effect } from "babylonjs/Materials/effect";
  14207. import { Texture } from "babylonjs/Materials/Textures/texture";
  14208. import "babylonjs/Shaders/procedural.vertex";
  14209. /**
  14210. * 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.
  14211. * This is the base class of any Procedural texture and contains most of the shareable code.
  14212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14213. */
  14214. export class ProceduralTexture extends Texture {
  14215. isCube: boolean;
  14216. /**
  14217. * Define if the texture is enabled or not (disabled texture will not render)
  14218. */
  14219. isEnabled: boolean;
  14220. /**
  14221. * Define if the texture must be cleared before rendering (default is true)
  14222. */
  14223. autoClear: boolean;
  14224. /**
  14225. * Callback called when the texture is generated
  14226. */
  14227. onGenerated: () => void;
  14228. /**
  14229. * Event raised when the texture is generated
  14230. */
  14231. onGeneratedObservable: Observable<ProceduralTexture>;
  14232. /** @hidden */
  14233. _generateMipMaps: boolean;
  14234. /** @hidden **/
  14235. _effect: Effect;
  14236. /** @hidden */
  14237. _textures: {
  14238. [key: string]: Texture;
  14239. };
  14240. private _size;
  14241. private _currentRefreshId;
  14242. private _refreshRate;
  14243. private _vertexBuffers;
  14244. private _indexBuffer;
  14245. private _uniforms;
  14246. private _samplers;
  14247. private _fragment;
  14248. private _floats;
  14249. private _ints;
  14250. private _floatsArrays;
  14251. private _colors3;
  14252. private _colors4;
  14253. private _vectors2;
  14254. private _vectors3;
  14255. private _matrices;
  14256. private _fallbackTexture;
  14257. private _fallbackTextureUsed;
  14258. private _engine;
  14259. private _cachedDefines;
  14260. private _contentUpdateId;
  14261. private _contentData;
  14262. /**
  14263. * Instantiates a new procedural texture.
  14264. * 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.
  14265. * This is the base class of any Procedural texture and contains most of the shareable code.
  14266. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14267. * @param name Define the name of the texture
  14268. * @param size Define the size of the texture to create
  14269. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14270. * @param scene Define the scene the texture belongs to
  14271. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14272. * @param generateMipMaps Define if the texture should creates mip maps or not
  14273. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14274. */
  14275. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14276. /**
  14277. * The effect that is created when initializing the post process.
  14278. * @returns The created effect corrisponding the the postprocess.
  14279. */
  14280. getEffect(): Effect;
  14281. /**
  14282. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14283. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14284. */
  14285. getContent(): Nullable<ArrayBufferView>;
  14286. private _createIndexBuffer;
  14287. /** @hidden */
  14288. _rebuild(): void;
  14289. /**
  14290. * Resets the texture in order to recreate its associated resources.
  14291. * This can be called in case of context loss
  14292. */
  14293. reset(): void;
  14294. protected _getDefines(): string;
  14295. /**
  14296. * Is the texture ready to be used ? (rendered at least once)
  14297. * @returns true if ready, otherwise, false.
  14298. */
  14299. isReady(): boolean;
  14300. /**
  14301. * Resets the refresh counter of the texture and start bak from scratch.
  14302. * Could be useful to regenerate the texture if it is setup to render only once.
  14303. */
  14304. resetRefreshCounter(): void;
  14305. /**
  14306. * Set the fragment shader to use in order to render the texture.
  14307. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14308. */
  14309. setFragment(fragment: any): void;
  14310. /**
  14311. * Define the refresh rate of the texture or the rendering frequency.
  14312. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14313. */
  14314. refreshRate: number;
  14315. /** @hidden */
  14316. _shouldRender(): boolean;
  14317. /**
  14318. * Get the size the texture is rendering at.
  14319. * @returns the size (texture is always squared)
  14320. */
  14321. getRenderSize(): number;
  14322. /**
  14323. * Resize the texture to new value.
  14324. * @param size Define the new size the texture should have
  14325. * @param generateMipMaps Define whether the new texture should create mip maps
  14326. */
  14327. resize(size: number, generateMipMaps: boolean): void;
  14328. private _checkUniform;
  14329. /**
  14330. * Set a texture in the shader program used to render.
  14331. * @param name Define the name of the uniform samplers as defined in the shader
  14332. * @param texture Define the texture to bind to this sampler
  14333. * @return the texture itself allowing "fluent" like uniform updates
  14334. */
  14335. setTexture(name: string, texture: Texture): ProceduralTexture;
  14336. /**
  14337. * Set a float in the shader.
  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. setFloat(name: string, value: number): ProceduralTexture;
  14343. /**
  14344. * Set a int in the shader.
  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. setInt(name: string, value: number): ProceduralTexture;
  14350. /**
  14351. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ProceduralTexture;
  14357. /**
  14358. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  14364. /**
  14365. * Set a vec4 in the shader from a Color4.
  14366. * @param name Define the name of the uniform as defined in the shader
  14367. * @param value Define the value to give to the uniform
  14368. * @return the texture itself allowing "fluent" like uniform updates
  14369. */
  14370. setColor4(name: string, value: Color4): ProceduralTexture;
  14371. /**
  14372. * Set a vec2 in the shader from a Vector2.
  14373. * @param name Define the name of the uniform as defined in the shader
  14374. * @param value Define the value to give to the uniform
  14375. * @return the texture itself allowing "fluent" like uniform updates
  14376. */
  14377. setVector2(name: string, value: Vector2): ProceduralTexture;
  14378. /**
  14379. * Set a vec3 in the shader from a Vector3.
  14380. * @param name Define the name of the uniform as defined in the shader
  14381. * @param value Define the value to give to the uniform
  14382. * @return the texture itself allowing "fluent" like uniform updates
  14383. */
  14384. setVector3(name: string, value: Vector3): ProceduralTexture;
  14385. /**
  14386. * Set a mat4 in the shader from a MAtrix.
  14387. * @param name Define the name of the uniform as defined in the shader
  14388. * @param value Define the value to give to the uniform
  14389. * @return the texture itself allowing "fluent" like uniform updates
  14390. */
  14391. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14392. /**
  14393. * Render the texture to its associated render target.
  14394. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14395. */
  14396. render(useCameraPostProcess?: boolean): void;
  14397. /**
  14398. * Clone the texture.
  14399. * @returns the cloned texture
  14400. */
  14401. clone(): ProceduralTexture;
  14402. /**
  14403. * Dispose the texture and release its asoociated resources.
  14404. */
  14405. dispose(): void;
  14406. }
  14407. }
  14408. declare module "babylonjs/Particles/baseParticleSystem" {
  14409. import { Nullable } from "babylonjs/types";
  14410. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14412. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14413. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14414. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14415. import { Scene } from "babylonjs/scene";
  14416. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14417. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14418. import { Texture } from "babylonjs/Materials/Textures/texture";
  14419. import { Animation } from "babylonjs/Animations/animation";
  14420. /**
  14421. * This represents the base class for particle system in Babylon.
  14422. * 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.
  14423. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14424. * @example https://doc.babylonjs.com/babylon101/particles
  14425. */
  14426. export class BaseParticleSystem {
  14427. /**
  14428. * Source color is added to the destination color without alpha affecting the result
  14429. */
  14430. static BLENDMODE_ONEONE: number;
  14431. /**
  14432. * Blend current color and particle color using particle’s alpha
  14433. */
  14434. static BLENDMODE_STANDARD: number;
  14435. /**
  14436. * Add current color and particle color multiplied by particle’s alpha
  14437. */
  14438. static BLENDMODE_ADD: number;
  14439. /**
  14440. * Multiply current color with particle color
  14441. */
  14442. static BLENDMODE_MULTIPLY: number;
  14443. /**
  14444. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14445. */
  14446. static BLENDMODE_MULTIPLYADD: number;
  14447. /**
  14448. * List of animations used by the particle system.
  14449. */
  14450. animations: Animation[];
  14451. /**
  14452. * The id of the Particle system.
  14453. */
  14454. id: string;
  14455. /**
  14456. * The friendly name of the Particle system.
  14457. */
  14458. name: string;
  14459. /**
  14460. * The rendering group used by the Particle system to chose when to render.
  14461. */
  14462. renderingGroupId: number;
  14463. /**
  14464. * The emitter represents the Mesh or position we are attaching the particle system to.
  14465. */
  14466. emitter: Nullable<AbstractMesh | Vector3>;
  14467. /**
  14468. * The maximum number of particles to emit per frame
  14469. */
  14470. emitRate: number;
  14471. /**
  14472. * If you want to launch only a few particles at once, that can be done, as well.
  14473. */
  14474. manualEmitCount: number;
  14475. /**
  14476. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14477. */
  14478. updateSpeed: number;
  14479. /**
  14480. * The amount of time the particle system is running (depends of the overall update speed).
  14481. */
  14482. targetStopDuration: number;
  14483. /**
  14484. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14485. */
  14486. disposeOnStop: boolean;
  14487. /**
  14488. * Minimum power of emitting particles.
  14489. */
  14490. minEmitPower: number;
  14491. /**
  14492. * Maximum power of emitting particles.
  14493. */
  14494. maxEmitPower: number;
  14495. /**
  14496. * Minimum life time of emitting particles.
  14497. */
  14498. minLifeTime: number;
  14499. /**
  14500. * Maximum life time of emitting particles.
  14501. */
  14502. maxLifeTime: number;
  14503. /**
  14504. * Minimum Size of emitting particles.
  14505. */
  14506. minSize: number;
  14507. /**
  14508. * Maximum Size of emitting particles.
  14509. */
  14510. maxSize: number;
  14511. /**
  14512. * Minimum scale of emitting particles on X axis.
  14513. */
  14514. minScaleX: number;
  14515. /**
  14516. * Maximum scale of emitting particles on X axis.
  14517. */
  14518. maxScaleX: number;
  14519. /**
  14520. * Minimum scale of emitting particles on Y axis.
  14521. */
  14522. minScaleY: number;
  14523. /**
  14524. * Maximum scale of emitting particles on Y axis.
  14525. */
  14526. maxScaleY: number;
  14527. /**
  14528. * Gets or sets the minimal initial rotation in radians.
  14529. */
  14530. minInitialRotation: number;
  14531. /**
  14532. * Gets or sets the maximal initial rotation in radians.
  14533. */
  14534. maxInitialRotation: number;
  14535. /**
  14536. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14537. */
  14538. minAngularSpeed: number;
  14539. /**
  14540. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14541. */
  14542. maxAngularSpeed: number;
  14543. /**
  14544. * The texture used to render each particle. (this can be a spritesheet)
  14545. */
  14546. particleTexture: Nullable<Texture>;
  14547. /**
  14548. * The layer mask we are rendering the particles through.
  14549. */
  14550. layerMask: number;
  14551. /**
  14552. * This can help using your own shader to render the particle system.
  14553. * The according effect will be created
  14554. */
  14555. customShader: any;
  14556. /**
  14557. * By default particle system starts as soon as they are created. This prevents the
  14558. * automatic start to happen and let you decide when to start emitting particles.
  14559. */
  14560. preventAutoStart: boolean;
  14561. private _noiseTexture;
  14562. /**
  14563. * Gets or sets a texture used to add random noise to particle positions
  14564. */
  14565. noiseTexture: Nullable<ProceduralTexture>;
  14566. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14567. noiseStrength: Vector3;
  14568. /**
  14569. * Callback triggered when the particle animation is ending.
  14570. */
  14571. onAnimationEnd: Nullable<() => void>;
  14572. /**
  14573. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14574. */
  14575. blendMode: number;
  14576. /**
  14577. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14578. * to override the particles.
  14579. */
  14580. forceDepthWrite: boolean;
  14581. /** 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 */
  14582. preWarmCycles: number;
  14583. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14584. preWarmStepOffset: number;
  14585. /**
  14586. * 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)
  14587. */
  14588. spriteCellChangeSpeed: number;
  14589. /**
  14590. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14591. */
  14592. startSpriteCellID: number;
  14593. /**
  14594. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14595. */
  14596. endSpriteCellID: number;
  14597. /**
  14598. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14599. */
  14600. spriteCellWidth: number;
  14601. /**
  14602. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14603. */
  14604. spriteCellHeight: number;
  14605. /**
  14606. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14607. */
  14608. spriteRandomStartCell: boolean;
  14609. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14610. translationPivot: Vector2;
  14611. /** @hidden */
  14612. protected _isAnimationSheetEnabled: boolean;
  14613. /**
  14614. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14615. */
  14616. beginAnimationOnStart: boolean;
  14617. /**
  14618. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14619. */
  14620. beginAnimationFrom: number;
  14621. /**
  14622. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14623. */
  14624. beginAnimationTo: number;
  14625. /**
  14626. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14627. */
  14628. beginAnimationLoop: boolean;
  14629. /**
  14630. * Gets or sets a world offset applied to all particles
  14631. */
  14632. worldOffset: Vector3;
  14633. /**
  14634. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14635. */
  14636. isAnimationSheetEnabled: boolean;
  14637. /**
  14638. * Get hosting scene
  14639. * @returns the scene
  14640. */
  14641. getScene(): Scene;
  14642. /**
  14643. * You can use gravity if you want to give an orientation to your particles.
  14644. */
  14645. gravity: Vector3;
  14646. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14647. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14648. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14649. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14650. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14651. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14652. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14653. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14654. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14655. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14656. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14657. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14658. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14659. /**
  14660. * Defines the delay in milliseconds before starting the system (0 by default)
  14661. */
  14662. startDelay: number;
  14663. /**
  14664. * Gets the current list of drag gradients.
  14665. * You must use addDragGradient and removeDragGradient to udpate this list
  14666. * @returns the list of drag gradients
  14667. */
  14668. getDragGradients(): Nullable<Array<FactorGradient>>;
  14669. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14670. limitVelocityDamping: number;
  14671. /**
  14672. * Gets the current list of limit velocity gradients.
  14673. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14674. * @returns the list of limit velocity gradients
  14675. */
  14676. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14677. /**
  14678. * Gets the current list of color gradients.
  14679. * You must use addColorGradient and removeColorGradient to udpate this list
  14680. * @returns the list of color gradients
  14681. */
  14682. getColorGradients(): Nullable<Array<ColorGradient>>;
  14683. /**
  14684. * Gets the current list of size gradients.
  14685. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14686. * @returns the list of size gradients
  14687. */
  14688. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14689. /**
  14690. * Gets the current list of color remap gradients.
  14691. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14692. * @returns the list of color remap gradients
  14693. */
  14694. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14695. /**
  14696. * Gets the current list of alpha remap gradients.
  14697. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14698. * @returns the list of alpha remap gradients
  14699. */
  14700. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14701. /**
  14702. * Gets the current list of life time gradients.
  14703. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14704. * @returns the list of life time gradients
  14705. */
  14706. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14707. /**
  14708. * Gets the current list of angular speed gradients.
  14709. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14710. * @returns the list of angular speed gradients
  14711. */
  14712. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14713. /**
  14714. * Gets the current list of velocity gradients.
  14715. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14716. * @returns the list of velocity gradients
  14717. */
  14718. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of start size gradients.
  14721. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14722. * @returns the list of start size gradients
  14723. */
  14724. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Gets the current list of emit rate gradients.
  14727. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14728. * @returns the list of emit rate gradients
  14729. */
  14730. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14731. /**
  14732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14734. */
  14735. direction1: Vector3;
  14736. /**
  14737. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14739. */
  14740. direction2: Vector3;
  14741. /**
  14742. * 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.
  14743. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14744. */
  14745. minEmitBox: Vector3;
  14746. /**
  14747. * 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.
  14748. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14749. */
  14750. maxEmitBox: Vector3;
  14751. /**
  14752. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14753. */
  14754. color1: Color4;
  14755. /**
  14756. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14757. */
  14758. color2: Color4;
  14759. /**
  14760. * Color the particle will have at the end of its lifetime
  14761. */
  14762. colorDead: Color4;
  14763. /**
  14764. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14765. */
  14766. textureMask: Color4;
  14767. /**
  14768. * The particle emitter type defines the emitter used by the particle system.
  14769. * It can be for example box, sphere, or cone...
  14770. */
  14771. particleEmitterType: IParticleEmitterType;
  14772. /** @hidden */
  14773. _isSubEmitter: boolean;
  14774. /**
  14775. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14776. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14777. */
  14778. billboardMode: number;
  14779. protected _isBillboardBased: boolean;
  14780. /**
  14781. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14782. */
  14783. isBillboardBased: boolean;
  14784. /**
  14785. * The scene the particle system belongs to.
  14786. */
  14787. protected _scene: Scene;
  14788. /**
  14789. * Local cache of defines for image processing.
  14790. */
  14791. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14792. /**
  14793. * Default configuration related to image processing available in the standard Material.
  14794. */
  14795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14796. /**
  14797. * Gets the image processing configuration used either in this material.
  14798. */
  14799. /**
  14800. * Sets the Default image processing configuration used either in the this material.
  14801. *
  14802. * If sets to null, the scene one is in use.
  14803. */
  14804. imageProcessingConfiguration: ImageProcessingConfiguration;
  14805. /**
  14806. * Attaches a new image processing configuration to the Standard Material.
  14807. * @param configuration
  14808. */
  14809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14810. /** @hidden */
  14811. protected _reset(): void;
  14812. /** @hidden */
  14813. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14814. /**
  14815. * Instantiates a particle system.
  14816. * 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.
  14817. * @param name The name of the particle system
  14818. */
  14819. constructor(name: string);
  14820. /**
  14821. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14824. * @returns the emitter
  14825. */
  14826. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14827. /**
  14828. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14829. * @param radius The radius of the hemisphere to emit from
  14830. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14831. * @returns the emitter
  14832. */
  14833. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14834. /**
  14835. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14836. * @param radius The radius of the sphere to emit from
  14837. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14838. * @returns the emitter
  14839. */
  14840. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14841. /**
  14842. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14843. * @param radius The radius of the sphere to emit from
  14844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14846. * @returns the emitter
  14847. */
  14848. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14849. /**
  14850. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14851. * @param radius The radius of the emission cylinder
  14852. * @param height The height of the emission cylinder
  14853. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14854. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14855. * @returns the emitter
  14856. */
  14857. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14858. /**
  14859. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14860. * @param radius The radius of the cylinder to emit from
  14861. * @param height The height of the emission cylinder
  14862. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14865. * @returns the emitter
  14866. */
  14867. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14868. /**
  14869. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14870. * @param radius The radius of the cone to emit from
  14871. * @param angle The base angle of the cone
  14872. * @returns the emitter
  14873. */
  14874. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14875. /**
  14876. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14879. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14880. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14881. * @returns the emitter
  14882. */
  14883. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14884. }
  14885. }
  14886. declare module "babylonjs/Particles/subEmitter" {
  14887. import { Scene } from "babylonjs/scene";
  14888. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14889. /**
  14890. * Type of sub emitter
  14891. */
  14892. export enum SubEmitterType {
  14893. /**
  14894. * Attached to the particle over it's lifetime
  14895. */
  14896. ATTACHED = 0,
  14897. /**
  14898. * Created when the particle dies
  14899. */
  14900. END = 1
  14901. }
  14902. /**
  14903. * Sub emitter class used to emit particles from an existing particle
  14904. */
  14905. export class SubEmitter {
  14906. /**
  14907. * the particle system to be used by the sub emitter
  14908. */
  14909. particleSystem: ParticleSystem;
  14910. /**
  14911. * Type of the submitter (Default: END)
  14912. */
  14913. type: SubEmitterType;
  14914. /**
  14915. * 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)
  14916. * Note: This only is supported when using an emitter of type Mesh
  14917. */
  14918. inheritDirection: boolean;
  14919. /**
  14920. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14921. */
  14922. inheritedVelocityAmount: number;
  14923. /**
  14924. * Creates a sub emitter
  14925. * @param particleSystem the particle system to be used by the sub emitter
  14926. */
  14927. constructor(
  14928. /**
  14929. * the particle system to be used by the sub emitter
  14930. */
  14931. particleSystem: ParticleSystem);
  14932. /**
  14933. * Clones the sub emitter
  14934. * @returns the cloned sub emitter
  14935. */
  14936. clone(): SubEmitter;
  14937. /**
  14938. * Serialize current object to a JSON object
  14939. * @returns the serialized object
  14940. */
  14941. serialize(): any;
  14942. /** @hidden */
  14943. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14944. /**
  14945. * Creates a new SubEmitter from a serialized JSON version
  14946. * @param serializationObject defines the JSON object to read from
  14947. * @param scene defines the hosting scene
  14948. * @param rootUrl defines the rootUrl for data loading
  14949. * @returns a new SubEmitter
  14950. */
  14951. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14952. /** Release associated resources */
  14953. dispose(): void;
  14954. }
  14955. }
  14956. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14957. /** @hidden */
  14958. export var clipPlaneFragmentDeclaration: {
  14959. name: string;
  14960. shader: string;
  14961. };
  14962. }
  14963. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14964. /** @hidden */
  14965. export var imageProcessingDeclaration: {
  14966. name: string;
  14967. shader: string;
  14968. };
  14969. }
  14970. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14971. /** @hidden */
  14972. export var imageProcessingFunctions: {
  14973. name: string;
  14974. shader: string;
  14975. };
  14976. }
  14977. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14978. /** @hidden */
  14979. export var clipPlaneFragment: {
  14980. name: string;
  14981. shader: string;
  14982. };
  14983. }
  14984. declare module "babylonjs/Shaders/particles.fragment" {
  14985. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14986. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14987. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14988. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14989. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14990. /** @hidden */
  14991. export var particlesPixelShader: {
  14992. name: string;
  14993. shader: string;
  14994. };
  14995. }
  14996. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14997. /** @hidden */
  14998. export var clipPlaneVertexDeclaration: {
  14999. name: string;
  15000. shader: string;
  15001. };
  15002. }
  15003. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15004. /** @hidden */
  15005. export var clipPlaneVertex: {
  15006. name: string;
  15007. shader: string;
  15008. };
  15009. }
  15010. declare module "babylonjs/Shaders/particles.vertex" {
  15011. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15012. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15013. /** @hidden */
  15014. export var particlesVertexShader: {
  15015. name: string;
  15016. shader: string;
  15017. };
  15018. }
  15019. declare module "babylonjs/Particles/particleSystem" {
  15020. import { Nullable } from "babylonjs/types";
  15021. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15022. import { Observable } from "babylonjs/Misc/observable";
  15023. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15024. import { Effect } from "babylonjs/Materials/effect";
  15025. import { Scene, IDisposable } from "babylonjs/scene";
  15026. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15027. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15028. import { Particle } from "babylonjs/Particles/particle";
  15029. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15030. import "babylonjs/Shaders/particles.fragment";
  15031. import "babylonjs/Shaders/particles.vertex";
  15032. /**
  15033. * This represents a particle system in Babylon.
  15034. * 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.
  15035. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15036. * @example https://doc.babylonjs.com/babylon101/particles
  15037. */
  15038. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15039. /**
  15040. * Billboard mode will only apply to Y axis
  15041. */
  15042. static readonly BILLBOARDMODE_Y: number;
  15043. /**
  15044. * Billboard mode will apply to all axes
  15045. */
  15046. static readonly BILLBOARDMODE_ALL: number;
  15047. /**
  15048. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15049. */
  15050. static readonly BILLBOARDMODE_STRETCHED: number;
  15051. /**
  15052. * This function can be defined to provide custom update for active particles.
  15053. * This function will be called instead of regular update (age, position, color, etc.).
  15054. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15055. */
  15056. updateFunction: (particles: Particle[]) => void;
  15057. private _emitterWorldMatrix;
  15058. /**
  15059. * This function can be defined to specify initial direction for every new particle.
  15060. * It by default use the emitterType defined function
  15061. */
  15062. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15063. /**
  15064. * This function can be defined to specify initial position for every new particle.
  15065. * It by default use the emitterType defined function
  15066. */
  15067. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15068. /**
  15069. * @hidden
  15070. */
  15071. _inheritedVelocityOffset: Vector3;
  15072. /**
  15073. * An event triggered when the system is disposed
  15074. */
  15075. onDisposeObservable: Observable<ParticleSystem>;
  15076. private _onDisposeObserver;
  15077. /**
  15078. * Sets a callback that will be triggered when the system is disposed
  15079. */
  15080. onDispose: () => void;
  15081. private _particles;
  15082. private _epsilon;
  15083. private _capacity;
  15084. private _stockParticles;
  15085. private _newPartsExcess;
  15086. private _vertexData;
  15087. private _vertexBuffer;
  15088. private _vertexBuffers;
  15089. private _spriteBuffer;
  15090. private _indexBuffer;
  15091. private _effect;
  15092. private _customEffect;
  15093. private _cachedDefines;
  15094. private _scaledColorStep;
  15095. private _colorDiff;
  15096. private _scaledDirection;
  15097. private _scaledGravity;
  15098. private _currentRenderId;
  15099. private _alive;
  15100. private _useInstancing;
  15101. private _started;
  15102. private _stopped;
  15103. private _actualFrame;
  15104. private _scaledUpdateSpeed;
  15105. private _vertexBufferSize;
  15106. /** @hidden */
  15107. _currentEmitRateGradient: Nullable<FactorGradient>;
  15108. /** @hidden */
  15109. _currentEmitRate1: number;
  15110. /** @hidden */
  15111. _currentEmitRate2: number;
  15112. /** @hidden */
  15113. _currentStartSizeGradient: Nullable<FactorGradient>;
  15114. /** @hidden */
  15115. _currentStartSize1: number;
  15116. /** @hidden */
  15117. _currentStartSize2: number;
  15118. private readonly _rawTextureWidth;
  15119. private _rampGradientsTexture;
  15120. private _useRampGradients;
  15121. /** Gets or sets a boolean indicating that ramp gradients must be used
  15122. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15123. */
  15124. useRampGradients: boolean;
  15125. /**
  15126. * 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.
  15127. * 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: [])
  15128. */
  15129. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15130. private _subEmitters;
  15131. /**
  15132. * @hidden
  15133. * If the particle systems emitter should be disposed when the particle system is disposed
  15134. */
  15135. _disposeEmitterOnDispose: boolean;
  15136. /**
  15137. * The current active Sub-systems, this property is used by the root particle system only.
  15138. */
  15139. activeSubSystems: Array<ParticleSystem>;
  15140. private _rootParticleSystem;
  15141. /**
  15142. * Gets the current list of active particles
  15143. */
  15144. readonly particles: Particle[];
  15145. /**
  15146. * Returns the string "ParticleSystem"
  15147. * @returns a string containing the class name
  15148. */
  15149. getClassName(): string;
  15150. /**
  15151. * Instantiates a particle system.
  15152. * 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.
  15153. * @param name The name of the particle system
  15154. * @param capacity The max number of particles alive at the same time
  15155. * @param scene The scene the particle system belongs to
  15156. * @param customEffect a custom effect used to change the way particles are rendered by default
  15157. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15158. * @param epsilon Offset used to render the particles
  15159. */
  15160. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15161. private _addFactorGradient;
  15162. private _removeFactorGradient;
  15163. /**
  15164. * Adds a new life time gradient
  15165. * @param gradient defines the gradient to use (between 0 and 1)
  15166. * @param factor defines the life time factor to affect to the specified gradient
  15167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15168. * @returns the current particle system
  15169. */
  15170. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15171. /**
  15172. * Remove a specific life time gradient
  15173. * @param gradient defines the gradient to remove
  15174. * @returns the current particle system
  15175. */
  15176. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15177. /**
  15178. * Adds a new size gradient
  15179. * @param gradient defines the gradient to use (between 0 and 1)
  15180. * @param factor defines the size factor to affect to the specified gradient
  15181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15182. * @returns the current particle system
  15183. */
  15184. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15185. /**
  15186. * Remove a specific size gradient
  15187. * @param gradient defines the gradient to remove
  15188. * @returns the current particle system
  15189. */
  15190. removeSizeGradient(gradient: number): IParticleSystem;
  15191. /**
  15192. * Adds a new color remap gradient
  15193. * @param gradient defines the gradient to use (between 0 and 1)
  15194. * @param min defines the color remap minimal range
  15195. * @param max defines the color remap maximal range
  15196. * @returns the current particle system
  15197. */
  15198. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15199. /**
  15200. * Remove a specific color remap gradient
  15201. * @param gradient defines the gradient to remove
  15202. * @returns the current particle system
  15203. */
  15204. removeColorRemapGradient(gradient: number): IParticleSystem;
  15205. /**
  15206. * Adds a new alpha remap gradient
  15207. * @param gradient defines the gradient to use (between 0 and 1)
  15208. * @param min defines the alpha remap minimal range
  15209. * @param max defines the alpha remap maximal range
  15210. * @returns the current particle system
  15211. */
  15212. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15213. /**
  15214. * Remove a specific alpha remap gradient
  15215. * @param gradient defines the gradient to remove
  15216. * @returns the current particle system
  15217. */
  15218. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15219. /**
  15220. * Adds a new angular speed gradient
  15221. * @param gradient defines the gradient to use (between 0 and 1)
  15222. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15227. /**
  15228. * Remove a specific angular speed gradient
  15229. * @param gradient defines the gradient to remove
  15230. * @returns the current particle system
  15231. */
  15232. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15233. /**
  15234. * Adds a new velocity gradient
  15235. * @param gradient defines the gradient to use (between 0 and 1)
  15236. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15241. /**
  15242. * Remove a specific velocity gradient
  15243. * @param gradient defines the gradient to remove
  15244. * @returns the current particle system
  15245. */
  15246. removeVelocityGradient(gradient: number): IParticleSystem;
  15247. /**
  15248. * Adds a new limit velocity gradient
  15249. * @param gradient defines the gradient to use (between 0 and 1)
  15250. * @param factor defines the limit velocity 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15255. /**
  15256. * Remove a specific limit velocity gradient
  15257. * @param gradient defines the gradient to remove
  15258. * @returns the current particle system
  15259. */
  15260. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15261. /**
  15262. * Adds a new drag gradient
  15263. * @param gradient defines the gradient to use (between 0 and 1)
  15264. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15269. /**
  15270. * Remove a specific drag gradient
  15271. * @param gradient defines the gradient to remove
  15272. * @returns the current particle system
  15273. */
  15274. removeDragGradient(gradient: number): IParticleSystem;
  15275. /**
  15276. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15277. * @param gradient defines the gradient to use (between 0 and 1)
  15278. * @param factor defines the emit rate value to affect to the specified gradient
  15279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15280. * @returns the current particle system
  15281. */
  15282. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15283. /**
  15284. * Remove a specific emit rate gradient
  15285. * @param gradient defines the gradient to remove
  15286. * @returns the current particle system
  15287. */
  15288. removeEmitRateGradient(gradient: number): IParticleSystem;
  15289. /**
  15290. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15291. * @param gradient defines the gradient to use (between 0 and 1)
  15292. * @param factor defines the start size value to affect to the specified gradient
  15293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15294. * @returns the current particle system
  15295. */
  15296. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15297. /**
  15298. * Remove a specific start size gradient
  15299. * @param gradient defines the gradient to remove
  15300. * @returns the current particle system
  15301. */
  15302. removeStartSizeGradient(gradient: number): IParticleSystem;
  15303. private _createRampGradientTexture;
  15304. /**
  15305. * Gets the current list of ramp gradients.
  15306. * You must use addRampGradient and removeRampGradient to udpate this list
  15307. * @returns the list of ramp gradients
  15308. */
  15309. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15310. /**
  15311. * Adds a new ramp gradient used to remap particle colors
  15312. * @param gradient defines the gradient to use (between 0 and 1)
  15313. * @param color defines the color to affect to the specified gradient
  15314. * @returns the current particle system
  15315. */
  15316. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15317. /**
  15318. * Remove a specific ramp gradient
  15319. * @param gradient defines the gradient to remove
  15320. * @returns the current particle system
  15321. */
  15322. removeRampGradient(gradient: number): ParticleSystem;
  15323. /**
  15324. * Adds a new color gradient
  15325. * @param gradient defines the gradient to use (between 0 and 1)
  15326. * @param color1 defines the color to affect to the specified gradient
  15327. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15328. * @returns this particle system
  15329. */
  15330. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15331. /**
  15332. * Remove a specific color gradient
  15333. * @param gradient defines the gradient to remove
  15334. * @returns this particle system
  15335. */
  15336. removeColorGradient(gradient: number): IParticleSystem;
  15337. private _fetchR;
  15338. protected _reset(): void;
  15339. private _resetEffect;
  15340. private _createVertexBuffers;
  15341. private _createIndexBuffer;
  15342. /**
  15343. * Gets the maximum number of particles active at the same time.
  15344. * @returns The max number of active particles.
  15345. */
  15346. getCapacity(): number;
  15347. /**
  15348. * Gets whether there are still active particles in the system.
  15349. * @returns True if it is alive, otherwise false.
  15350. */
  15351. isAlive(): boolean;
  15352. /**
  15353. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15354. * @returns True if it has been started, otherwise false.
  15355. */
  15356. isStarted(): boolean;
  15357. private _prepareSubEmitterInternalArray;
  15358. /**
  15359. * Starts the particle system and begins to emit
  15360. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15361. */
  15362. start(delay?: number): void;
  15363. /**
  15364. * Stops the particle system.
  15365. * @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.
  15366. */
  15367. stop(stopSubEmitters?: boolean): void;
  15368. /**
  15369. * Remove all active particles
  15370. */
  15371. reset(): void;
  15372. /**
  15373. * @hidden (for internal use only)
  15374. */
  15375. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15376. /**
  15377. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15378. * Its lifetime will start back at 0.
  15379. */
  15380. recycleParticle: (particle: Particle) => void;
  15381. private _stopSubEmitters;
  15382. private _createParticle;
  15383. private _removeFromRoot;
  15384. private _emitFromParticle;
  15385. private _update;
  15386. /** @hidden */
  15387. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15388. /** @hidden */
  15389. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15390. /** @hidden */
  15391. private _getEffect;
  15392. /**
  15393. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15394. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15395. */
  15396. animate(preWarmOnly?: boolean): void;
  15397. private _appendParticleVertices;
  15398. /**
  15399. * Rebuilds the particle system.
  15400. */
  15401. rebuild(): void;
  15402. /**
  15403. * Is this system ready to be used/rendered
  15404. * @return true if the system is ready
  15405. */
  15406. isReady(): boolean;
  15407. private _render;
  15408. /**
  15409. * Renders the particle system in its current state.
  15410. * @returns the current number of particles
  15411. */
  15412. render(): number;
  15413. /**
  15414. * Disposes the particle system and free the associated resources
  15415. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15416. */
  15417. dispose(disposeTexture?: boolean): void;
  15418. /**
  15419. * Clones the particle system.
  15420. * @param name The name of the cloned object
  15421. * @param newEmitter The new emitter to use
  15422. * @returns the cloned particle system
  15423. */
  15424. clone(name: string, newEmitter: any): ParticleSystem;
  15425. /**
  15426. * Serializes the particle system to a JSON object.
  15427. * @returns the JSON object
  15428. */
  15429. serialize(): any;
  15430. /** @hidden */
  15431. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15432. /** @hidden */
  15433. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15434. /**
  15435. * Parses a JSON object to create a particle system.
  15436. * @param parsedParticleSystem The JSON object to parse
  15437. * @param scene The scene to create the particle system in
  15438. * @param rootUrl The root url to use to load external dependencies like texture
  15439. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15440. * @returns the Parsed particle system
  15441. */
  15442. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15443. }
  15444. }
  15445. declare module "babylonjs/Particles/particle" {
  15446. import { Nullable } from "babylonjs/types";
  15447. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15448. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15449. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15450. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15451. /**
  15452. * A particle represents one of the element emitted by a particle system.
  15453. * This is mainly define by its coordinates, direction, velocity and age.
  15454. */
  15455. export class Particle {
  15456. /**
  15457. * The particle system the particle belongs to.
  15458. */
  15459. particleSystem: ParticleSystem;
  15460. private static _Count;
  15461. /**
  15462. * Unique ID of the particle
  15463. */
  15464. id: number;
  15465. /**
  15466. * The world position of the particle in the scene.
  15467. */
  15468. position: Vector3;
  15469. /**
  15470. * The world direction of the particle in the scene.
  15471. */
  15472. direction: Vector3;
  15473. /**
  15474. * The color of the particle.
  15475. */
  15476. color: Color4;
  15477. /**
  15478. * The color change of the particle per step.
  15479. */
  15480. colorStep: Color4;
  15481. /**
  15482. * Defines how long will the life of the particle be.
  15483. */
  15484. lifeTime: number;
  15485. /**
  15486. * The current age of the particle.
  15487. */
  15488. age: number;
  15489. /**
  15490. * The current size of the particle.
  15491. */
  15492. size: number;
  15493. /**
  15494. * The current scale of the particle.
  15495. */
  15496. scale: Vector2;
  15497. /**
  15498. * The current angle of the particle.
  15499. */
  15500. angle: number;
  15501. /**
  15502. * Defines how fast is the angle changing.
  15503. */
  15504. angularSpeed: number;
  15505. /**
  15506. * Defines the cell index used by the particle to be rendered from a sprite.
  15507. */
  15508. cellIndex: number;
  15509. /**
  15510. * The information required to support color remapping
  15511. */
  15512. remapData: Vector4;
  15513. /** @hidden */
  15514. _randomCellOffset?: number;
  15515. /** @hidden */
  15516. _initialDirection: Nullable<Vector3>;
  15517. /** @hidden */
  15518. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15519. /** @hidden */
  15520. _initialStartSpriteCellID: number;
  15521. /** @hidden */
  15522. _initialEndSpriteCellID: number;
  15523. /** @hidden */
  15524. _currentColorGradient: Nullable<ColorGradient>;
  15525. /** @hidden */
  15526. _currentColor1: Color4;
  15527. /** @hidden */
  15528. _currentColor2: Color4;
  15529. /** @hidden */
  15530. _currentSizeGradient: Nullable<FactorGradient>;
  15531. /** @hidden */
  15532. _currentSize1: number;
  15533. /** @hidden */
  15534. _currentSize2: number;
  15535. /** @hidden */
  15536. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15537. /** @hidden */
  15538. _currentAngularSpeed1: number;
  15539. /** @hidden */
  15540. _currentAngularSpeed2: number;
  15541. /** @hidden */
  15542. _currentVelocityGradient: Nullable<FactorGradient>;
  15543. /** @hidden */
  15544. _currentVelocity1: number;
  15545. /** @hidden */
  15546. _currentVelocity2: number;
  15547. /** @hidden */
  15548. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15549. /** @hidden */
  15550. _currentLimitVelocity1: number;
  15551. /** @hidden */
  15552. _currentLimitVelocity2: number;
  15553. /** @hidden */
  15554. _currentDragGradient: Nullable<FactorGradient>;
  15555. /** @hidden */
  15556. _currentDrag1: number;
  15557. /** @hidden */
  15558. _currentDrag2: number;
  15559. /** @hidden */
  15560. _randomNoiseCoordinates1: Vector3;
  15561. /** @hidden */
  15562. _randomNoiseCoordinates2: Vector3;
  15563. /**
  15564. * Creates a new instance Particle
  15565. * @param particleSystem the particle system the particle belongs to
  15566. */
  15567. constructor(
  15568. /**
  15569. * The particle system the particle belongs to.
  15570. */
  15571. particleSystem: ParticleSystem);
  15572. private updateCellInfoFromSystem;
  15573. /**
  15574. * Defines how the sprite cell index is updated for the particle
  15575. */
  15576. updateCellIndex(): void;
  15577. /** @hidden */
  15578. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15579. /** @hidden */
  15580. _inheritParticleInfoToSubEmitters(): void;
  15581. /** @hidden */
  15582. _reset(): void;
  15583. /**
  15584. * Copy the properties of particle to another one.
  15585. * @param other the particle to copy the information to.
  15586. */
  15587. copyTo(other: Particle): void;
  15588. }
  15589. }
  15590. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15591. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15592. import { Effect } from "babylonjs/Materials/effect";
  15593. import { Particle } from "babylonjs/Particles/particle";
  15594. /**
  15595. * Particle emitter represents a volume emitting particles.
  15596. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15597. */
  15598. export interface IParticleEmitterType {
  15599. /**
  15600. * Called by the particle System when the direction is computed for the created particle.
  15601. * @param worldMatrix is the world matrix of the particle system
  15602. * @param directionToUpdate is the direction vector to update with the result
  15603. * @param particle is the particle we are computed the direction for
  15604. */
  15605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15606. /**
  15607. * Called by the particle System when the position is computed for the created particle.
  15608. * @param worldMatrix is the world matrix of the particle system
  15609. * @param positionToUpdate is the position vector to update with the result
  15610. * @param particle is the particle we are computed the position for
  15611. */
  15612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15613. /**
  15614. * Clones the current emitter and returns a copy of it
  15615. * @returns the new emitter
  15616. */
  15617. clone(): IParticleEmitterType;
  15618. /**
  15619. * Called by the GPUParticleSystem to setup the update shader
  15620. * @param effect defines the update shader
  15621. */
  15622. applyToShader(effect: Effect): void;
  15623. /**
  15624. * Returns a string to use to update the GPU particles update shader
  15625. * @returns the effect defines string
  15626. */
  15627. getEffectDefines(): string;
  15628. /**
  15629. * Returns a string representing the class name
  15630. * @returns a string containing the class name
  15631. */
  15632. getClassName(): string;
  15633. /**
  15634. * Serializes the particle system to a JSON object.
  15635. * @returns the JSON object
  15636. */
  15637. serialize(): any;
  15638. /**
  15639. * Parse properties from a JSON object
  15640. * @param serializationObject defines the JSON object
  15641. */
  15642. parse(serializationObject: any): void;
  15643. }
  15644. }
  15645. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15646. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15647. import { Effect } from "babylonjs/Materials/effect";
  15648. import { Particle } from "babylonjs/Particles/particle";
  15649. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15650. /**
  15651. * Particle emitter emitting particles from the inside of a box.
  15652. * It emits the particles randomly between 2 given directions.
  15653. */
  15654. export class BoxParticleEmitter implements IParticleEmitterType {
  15655. /**
  15656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15657. */
  15658. direction1: Vector3;
  15659. /**
  15660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15661. */
  15662. direction2: Vector3;
  15663. /**
  15664. * 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.
  15665. */
  15666. minEmitBox: Vector3;
  15667. /**
  15668. * 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.
  15669. */
  15670. maxEmitBox: Vector3;
  15671. /**
  15672. * Creates a new instance BoxParticleEmitter
  15673. */
  15674. constructor();
  15675. /**
  15676. * Called by the particle System when the direction is computed for the created particle.
  15677. * @param worldMatrix is the world matrix of the particle system
  15678. * @param directionToUpdate is the direction vector to update with the result
  15679. * @param particle is the particle we are computed the direction for
  15680. */
  15681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15682. /**
  15683. * Called by the particle System when the position is computed for the created particle.
  15684. * @param worldMatrix is the world matrix of the particle system
  15685. * @param positionToUpdate is the position vector to update with the result
  15686. * @param particle is the particle we are computed the position for
  15687. */
  15688. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15689. /**
  15690. * Clones the current emitter and returns a copy of it
  15691. * @returns the new emitter
  15692. */
  15693. clone(): BoxParticleEmitter;
  15694. /**
  15695. * Called by the GPUParticleSystem to setup the update shader
  15696. * @param effect defines the update shader
  15697. */
  15698. applyToShader(effect: Effect): void;
  15699. /**
  15700. * Returns a string to use to update the GPU particles update shader
  15701. * @returns a string containng the defines string
  15702. */
  15703. getEffectDefines(): string;
  15704. /**
  15705. * Returns the string "BoxParticleEmitter"
  15706. * @returns a string containing the class name
  15707. */
  15708. getClassName(): string;
  15709. /**
  15710. * Serializes the particle system to a JSON object.
  15711. * @returns the JSON object
  15712. */
  15713. serialize(): any;
  15714. /**
  15715. * Parse properties from a JSON object
  15716. * @param serializationObject defines the JSON object
  15717. */
  15718. parse(serializationObject: any): void;
  15719. }
  15720. }
  15721. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15722. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15723. import { Effect } from "babylonjs/Materials/effect";
  15724. import { Particle } from "babylonjs/Particles/particle";
  15725. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15726. /**
  15727. * Particle emitter emitting particles from the inside of a cone.
  15728. * It emits the particles alongside the cone volume from the base to the particle.
  15729. * The emission direction might be randomized.
  15730. */
  15731. export class ConeParticleEmitter implements IParticleEmitterType {
  15732. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15733. directionRandomizer: number;
  15734. private _radius;
  15735. private _angle;
  15736. private _height;
  15737. /**
  15738. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15739. */
  15740. radiusRange: number;
  15741. /**
  15742. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15743. */
  15744. heightRange: number;
  15745. /**
  15746. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15747. */
  15748. emitFromSpawnPointOnly: boolean;
  15749. /**
  15750. * Gets or sets the radius of the emission cone
  15751. */
  15752. radius: number;
  15753. /**
  15754. * Gets or sets the angle of the emission cone
  15755. */
  15756. angle: number;
  15757. private _buildHeight;
  15758. /**
  15759. * Creates a new instance ConeParticleEmitter
  15760. * @param radius the radius of the emission cone (1 by default)
  15761. * @param angle the cone base angle (PI by default)
  15762. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15763. */
  15764. constructor(radius?: number, angle?: number,
  15765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15766. directionRandomizer?: number);
  15767. /**
  15768. * Called by the particle System when the direction is computed for the created particle.
  15769. * @param worldMatrix is the world matrix of the particle system
  15770. * @param directionToUpdate is the direction vector to update with the result
  15771. * @param particle is the particle we are computed the direction for
  15772. */
  15773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15774. /**
  15775. * Called by the particle System when the position is computed for the created particle.
  15776. * @param worldMatrix is the world matrix of the particle system
  15777. * @param positionToUpdate is the position vector to update with the result
  15778. * @param particle is the particle we are computed the position for
  15779. */
  15780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15781. /**
  15782. * Clones the current emitter and returns a copy of it
  15783. * @returns the new emitter
  15784. */
  15785. clone(): ConeParticleEmitter;
  15786. /**
  15787. * Called by the GPUParticleSystem to setup the update shader
  15788. * @param effect defines the update shader
  15789. */
  15790. applyToShader(effect: Effect): void;
  15791. /**
  15792. * Returns a string to use to update the GPU particles update shader
  15793. * @returns a string containng the defines string
  15794. */
  15795. getEffectDefines(): string;
  15796. /**
  15797. * Returns the string "ConeParticleEmitter"
  15798. * @returns a string containing the class name
  15799. */
  15800. getClassName(): string;
  15801. /**
  15802. * Serializes the particle system to a JSON object.
  15803. * @returns the JSON object
  15804. */
  15805. serialize(): any;
  15806. /**
  15807. * Parse properties from a JSON object
  15808. * @param serializationObject defines the JSON object
  15809. */
  15810. parse(serializationObject: any): void;
  15811. }
  15812. }
  15813. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15814. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15815. import { Effect } from "babylonjs/Materials/effect";
  15816. import { Particle } from "babylonjs/Particles/particle";
  15817. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15818. /**
  15819. * Particle emitter emitting particles from the inside of a cylinder.
  15820. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15821. */
  15822. export class CylinderParticleEmitter implements IParticleEmitterType {
  15823. /**
  15824. * The radius of the emission cylinder.
  15825. */
  15826. radius: number;
  15827. /**
  15828. * The height of the emission cylinder.
  15829. */
  15830. height: number;
  15831. /**
  15832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15833. */
  15834. radiusRange: number;
  15835. /**
  15836. * How much to randomize the particle direction [0-1].
  15837. */
  15838. directionRandomizer: number;
  15839. /**
  15840. * Creates a new instance CylinderParticleEmitter
  15841. * @param radius the radius of the emission cylinder (1 by default)
  15842. * @param height the height of the emission cylinder (1 by default)
  15843. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15844. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15845. */
  15846. constructor(
  15847. /**
  15848. * The radius of the emission cylinder.
  15849. */
  15850. radius?: number,
  15851. /**
  15852. * The height of the emission cylinder.
  15853. */
  15854. height?: number,
  15855. /**
  15856. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15857. */
  15858. radiusRange?: number,
  15859. /**
  15860. * How much to randomize the particle direction [0-1].
  15861. */
  15862. directionRandomizer?: number);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. */
  15869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15870. /**
  15871. * Called by the particle System when the position is computed for the created particle.
  15872. * @param worldMatrix is the world matrix of the particle system
  15873. * @param positionToUpdate is the position vector to update with the result
  15874. * @param particle is the particle we are computed the position for
  15875. */
  15876. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15877. /**
  15878. * Clones the current emitter and returns a copy of it
  15879. * @returns the new emitter
  15880. */
  15881. clone(): CylinderParticleEmitter;
  15882. /**
  15883. * Called by the GPUParticleSystem to setup the update shader
  15884. * @param effect defines the update shader
  15885. */
  15886. applyToShader(effect: Effect): void;
  15887. /**
  15888. * Returns a string to use to update the GPU particles update shader
  15889. * @returns a string containng the defines string
  15890. */
  15891. getEffectDefines(): string;
  15892. /**
  15893. * Returns the string "CylinderParticleEmitter"
  15894. * @returns a string containing the class name
  15895. */
  15896. getClassName(): string;
  15897. /**
  15898. * Serializes the particle system to a JSON object.
  15899. * @returns the JSON object
  15900. */
  15901. serialize(): any;
  15902. /**
  15903. * Parse properties from a JSON object
  15904. * @param serializationObject defines the JSON object
  15905. */
  15906. parse(serializationObject: any): void;
  15907. }
  15908. /**
  15909. * Particle emitter emitting particles from the inside of a cylinder.
  15910. * It emits the particles randomly between two vectors.
  15911. */
  15912. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15913. /**
  15914. * The min limit of the emission direction.
  15915. */
  15916. direction1: Vector3;
  15917. /**
  15918. * The max limit of the emission direction.
  15919. */
  15920. direction2: Vector3;
  15921. /**
  15922. * Creates a new instance CylinderDirectedParticleEmitter
  15923. * @param radius the radius of the emission cylinder (1 by default)
  15924. * @param height the height of the emission cylinder (1 by default)
  15925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15926. * @param direction1 the min limit of the emission direction (up vector by default)
  15927. * @param direction2 the max limit of the emission direction (up vector by default)
  15928. */
  15929. constructor(radius?: number, height?: number, radiusRange?: number,
  15930. /**
  15931. * The min limit of the emission direction.
  15932. */
  15933. direction1?: Vector3,
  15934. /**
  15935. * The max limit of the emission direction.
  15936. */
  15937. direction2?: Vector3);
  15938. /**
  15939. * Called by the particle System when the direction is computed for the created particle.
  15940. * @param worldMatrix is the world matrix of the particle system
  15941. * @param directionToUpdate is the direction vector to update with the result
  15942. * @param particle is the particle we are computed the direction for
  15943. */
  15944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15945. /**
  15946. * Clones the current emitter and returns a copy of it
  15947. * @returns the new emitter
  15948. */
  15949. clone(): CylinderDirectedParticleEmitter;
  15950. /**
  15951. * Called by the GPUParticleSystem to setup the update shader
  15952. * @param effect defines the update shader
  15953. */
  15954. applyToShader(effect: Effect): void;
  15955. /**
  15956. * Returns a string to use to update the GPU particles update shader
  15957. * @returns a string containng the defines string
  15958. */
  15959. getEffectDefines(): string;
  15960. /**
  15961. * Returns the string "CylinderDirectedParticleEmitter"
  15962. * @returns a string containing the class name
  15963. */
  15964. getClassName(): string;
  15965. /**
  15966. * Serializes the particle system to a JSON object.
  15967. * @returns the JSON object
  15968. */
  15969. serialize(): any;
  15970. /**
  15971. * Parse properties from a JSON object
  15972. * @param serializationObject defines the JSON object
  15973. */
  15974. parse(serializationObject: any): void;
  15975. }
  15976. }
  15977. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15978. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15979. import { Effect } from "babylonjs/Materials/effect";
  15980. import { Particle } from "babylonjs/Particles/particle";
  15981. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15982. /**
  15983. * Particle emitter emitting particles from the inside of a hemisphere.
  15984. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15985. */
  15986. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15987. /**
  15988. * The radius of the emission hemisphere.
  15989. */
  15990. radius: number;
  15991. /**
  15992. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15993. */
  15994. radiusRange: number;
  15995. /**
  15996. * How much to randomize the particle direction [0-1].
  15997. */
  15998. directionRandomizer: number;
  15999. /**
  16000. * Creates a new instance HemisphericParticleEmitter
  16001. * @param radius the radius of the emission hemisphere (1 by default)
  16002. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16003. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16004. */
  16005. constructor(
  16006. /**
  16007. * The radius of the emission hemisphere.
  16008. */
  16009. radius?: number,
  16010. /**
  16011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16012. */
  16013. radiusRange?: number,
  16014. /**
  16015. * How much to randomize the particle direction [0-1].
  16016. */
  16017. directionRandomizer?: number);
  16018. /**
  16019. * Called by the particle System when the direction is computed for the created particle.
  16020. * @param worldMatrix is the world matrix of the particle system
  16021. * @param directionToUpdate is the direction vector to update with the result
  16022. * @param particle is the particle we are computed the direction for
  16023. */
  16024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16025. /**
  16026. * Called by the particle System when the position is computed for the created particle.
  16027. * @param worldMatrix is the world matrix of the particle system
  16028. * @param positionToUpdate is the position vector to update with the result
  16029. * @param particle is the particle we are computed the position for
  16030. */
  16031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16032. /**
  16033. * Clones the current emitter and returns a copy of it
  16034. * @returns the new emitter
  16035. */
  16036. clone(): HemisphericParticleEmitter;
  16037. /**
  16038. * Called by the GPUParticleSystem to setup the update shader
  16039. * @param effect defines the update shader
  16040. */
  16041. applyToShader(effect: Effect): void;
  16042. /**
  16043. * Returns a string to use to update the GPU particles update shader
  16044. * @returns a string containng the defines string
  16045. */
  16046. getEffectDefines(): string;
  16047. /**
  16048. * Returns the string "HemisphericParticleEmitter"
  16049. * @returns a string containing the class name
  16050. */
  16051. getClassName(): string;
  16052. /**
  16053. * Serializes the particle system to a JSON object.
  16054. * @returns the JSON object
  16055. */
  16056. serialize(): any;
  16057. /**
  16058. * Parse properties from a JSON object
  16059. * @param serializationObject defines the JSON object
  16060. */
  16061. parse(serializationObject: any): void;
  16062. }
  16063. }
  16064. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16065. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16066. import { Effect } from "babylonjs/Materials/effect";
  16067. import { Particle } from "babylonjs/Particles/particle";
  16068. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16069. /**
  16070. * Particle emitter emitting particles from a point.
  16071. * It emits the particles randomly between 2 given directions.
  16072. */
  16073. export class PointParticleEmitter implements IParticleEmitterType {
  16074. /**
  16075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16076. */
  16077. direction1: Vector3;
  16078. /**
  16079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16080. */
  16081. direction2: Vector3;
  16082. /**
  16083. * Creates a new instance PointParticleEmitter
  16084. */
  16085. constructor();
  16086. /**
  16087. * Called by the particle System when the direction is computed for the created particle.
  16088. * @param worldMatrix is the world matrix of the particle system
  16089. * @param directionToUpdate is the direction vector to update with the result
  16090. * @param particle is the particle we are computed the direction for
  16091. */
  16092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16093. /**
  16094. * Called by the particle System when the position is computed for the created particle.
  16095. * @param worldMatrix is the world matrix of the particle system
  16096. * @param positionToUpdate is the position vector to update with the result
  16097. * @param particle is the particle we are computed the position for
  16098. */
  16099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16100. /**
  16101. * Clones the current emitter and returns a copy of it
  16102. * @returns the new emitter
  16103. */
  16104. clone(): PointParticleEmitter;
  16105. /**
  16106. * Called by the GPUParticleSystem to setup the update shader
  16107. * @param effect defines the update shader
  16108. */
  16109. applyToShader(effect: Effect): void;
  16110. /**
  16111. * Returns a string to use to update the GPU particles update shader
  16112. * @returns a string containng the defines string
  16113. */
  16114. getEffectDefines(): string;
  16115. /**
  16116. * Returns the string "PointParticleEmitter"
  16117. * @returns a string containing the class name
  16118. */
  16119. getClassName(): string;
  16120. /**
  16121. * Serializes the particle system to a JSON object.
  16122. * @returns the JSON object
  16123. */
  16124. serialize(): any;
  16125. /**
  16126. * Parse properties from a JSON object
  16127. * @param serializationObject defines the JSON object
  16128. */
  16129. parse(serializationObject: any): void;
  16130. }
  16131. }
  16132. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16133. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16134. import { Effect } from "babylonjs/Materials/effect";
  16135. import { Particle } from "babylonjs/Particles/particle";
  16136. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16137. /**
  16138. * Particle emitter emitting particles from the inside of a sphere.
  16139. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16140. */
  16141. export class SphereParticleEmitter implements IParticleEmitterType {
  16142. /**
  16143. * The radius of the emission sphere.
  16144. */
  16145. radius: number;
  16146. /**
  16147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16148. */
  16149. radiusRange: number;
  16150. /**
  16151. * How much to randomize the particle direction [0-1].
  16152. */
  16153. directionRandomizer: number;
  16154. /**
  16155. * Creates a new instance SphereParticleEmitter
  16156. * @param radius the radius of the emission sphere (1 by default)
  16157. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16158. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16159. */
  16160. constructor(
  16161. /**
  16162. * The radius of the emission sphere.
  16163. */
  16164. radius?: number,
  16165. /**
  16166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16167. */
  16168. radiusRange?: number,
  16169. /**
  16170. * How much to randomize the particle direction [0-1].
  16171. */
  16172. directionRandomizer?: number);
  16173. /**
  16174. * Called by the particle System when the direction is computed for the created particle.
  16175. * @param worldMatrix is the world matrix of the particle system
  16176. * @param directionToUpdate is the direction vector to update with the result
  16177. * @param particle is the particle we are computed the direction for
  16178. */
  16179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16180. /**
  16181. * Called by the particle System when the position is computed for the created particle.
  16182. * @param worldMatrix is the world matrix of the particle system
  16183. * @param positionToUpdate is the position vector to update with the result
  16184. * @param particle is the particle we are computed the position for
  16185. */
  16186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16187. /**
  16188. * Clones the current emitter and returns a copy of it
  16189. * @returns the new emitter
  16190. */
  16191. clone(): SphereParticleEmitter;
  16192. /**
  16193. * Called by the GPUParticleSystem to setup the update shader
  16194. * @param effect defines the update shader
  16195. */
  16196. applyToShader(effect: Effect): void;
  16197. /**
  16198. * Returns a string to use to update the GPU particles update shader
  16199. * @returns a string containng the defines string
  16200. */
  16201. getEffectDefines(): string;
  16202. /**
  16203. * Returns the string "SphereParticleEmitter"
  16204. * @returns a string containing the class name
  16205. */
  16206. getClassName(): string;
  16207. /**
  16208. * Serializes the particle system to a JSON object.
  16209. * @returns the JSON object
  16210. */
  16211. serialize(): any;
  16212. /**
  16213. * Parse properties from a JSON object
  16214. * @param serializationObject defines the JSON object
  16215. */
  16216. parse(serializationObject: any): void;
  16217. }
  16218. /**
  16219. * Particle emitter emitting particles from the inside of a sphere.
  16220. * It emits the particles randomly between two vectors.
  16221. */
  16222. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16223. /**
  16224. * The min limit of the emission direction.
  16225. */
  16226. direction1: Vector3;
  16227. /**
  16228. * The max limit of the emission direction.
  16229. */
  16230. direction2: Vector3;
  16231. /**
  16232. * Creates a new instance SphereDirectedParticleEmitter
  16233. * @param radius the radius of the emission sphere (1 by default)
  16234. * @param direction1 the min limit of the emission direction (up vector by default)
  16235. * @param direction2 the max limit of the emission direction (up vector by default)
  16236. */
  16237. constructor(radius?: number,
  16238. /**
  16239. * The min limit of the emission direction.
  16240. */
  16241. direction1?: Vector3,
  16242. /**
  16243. * The max limit of the emission direction.
  16244. */
  16245. direction2?: Vector3);
  16246. /**
  16247. * Called by the particle System when the direction is computed for the created particle.
  16248. * @param worldMatrix is the world matrix of the particle system
  16249. * @param directionToUpdate is the direction vector to update with the result
  16250. * @param particle is the particle we are computed the direction for
  16251. */
  16252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16253. /**
  16254. * Clones the current emitter and returns a copy of it
  16255. * @returns the new emitter
  16256. */
  16257. clone(): SphereDirectedParticleEmitter;
  16258. /**
  16259. * Called by the GPUParticleSystem to setup the update shader
  16260. * @param effect defines the update shader
  16261. */
  16262. applyToShader(effect: Effect): void;
  16263. /**
  16264. * Returns a string to use to update the GPU particles update shader
  16265. * @returns a string containng the defines string
  16266. */
  16267. getEffectDefines(): string;
  16268. /**
  16269. * Returns the string "SphereDirectedParticleEmitter"
  16270. * @returns a string containing the class name
  16271. */
  16272. getClassName(): string;
  16273. /**
  16274. * Serializes the particle system to a JSON object.
  16275. * @returns the JSON object
  16276. */
  16277. serialize(): any;
  16278. /**
  16279. * Parse properties from a JSON object
  16280. * @param serializationObject defines the JSON object
  16281. */
  16282. parse(serializationObject: any): void;
  16283. }
  16284. }
  16285. declare module "babylonjs/Particles/EmitterTypes/index" {
  16286. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16287. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16288. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16289. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16290. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16291. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16292. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16293. }
  16294. declare module "babylonjs/Particles/IParticleSystem" {
  16295. import { Nullable } from "babylonjs/types";
  16296. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16299. import { Texture } from "babylonjs/Materials/Textures/texture";
  16300. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16301. import { Scene } from "babylonjs/scene";
  16302. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16303. import { Animation } from "babylonjs/Animations/animation";
  16304. /**
  16305. * Interface representing a particle system in Babylon.js.
  16306. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16307. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16308. */
  16309. export interface IParticleSystem {
  16310. /**
  16311. * List of animations used by the particle system.
  16312. */
  16313. animations: Animation[];
  16314. /**
  16315. * The id of the Particle system.
  16316. */
  16317. id: string;
  16318. /**
  16319. * The name of the Particle system.
  16320. */
  16321. name: string;
  16322. /**
  16323. * The emitter represents the Mesh or position we are attaching the particle system to.
  16324. */
  16325. emitter: Nullable<AbstractMesh | Vector3>;
  16326. /**
  16327. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16328. */
  16329. isBillboardBased: boolean;
  16330. /**
  16331. * The rendering group used by the Particle system to chose when to render.
  16332. */
  16333. renderingGroupId: number;
  16334. /**
  16335. * The layer mask we are rendering the particles through.
  16336. */
  16337. layerMask: number;
  16338. /**
  16339. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16340. */
  16341. updateSpeed: number;
  16342. /**
  16343. * The amount of time the particle system is running (depends of the overall update speed).
  16344. */
  16345. targetStopDuration: number;
  16346. /**
  16347. * The texture used to render each particle. (this can be a spritesheet)
  16348. */
  16349. particleTexture: Nullable<Texture>;
  16350. /**
  16351. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16352. */
  16353. blendMode: number;
  16354. /**
  16355. * Minimum life time of emitting particles.
  16356. */
  16357. minLifeTime: number;
  16358. /**
  16359. * Maximum life time of emitting particles.
  16360. */
  16361. maxLifeTime: number;
  16362. /**
  16363. * Minimum Size of emitting particles.
  16364. */
  16365. minSize: number;
  16366. /**
  16367. * Maximum Size of emitting particles.
  16368. */
  16369. maxSize: number;
  16370. /**
  16371. * Minimum scale of emitting particles on X axis.
  16372. */
  16373. minScaleX: number;
  16374. /**
  16375. * Maximum scale of emitting particles on X axis.
  16376. */
  16377. maxScaleX: number;
  16378. /**
  16379. * Minimum scale of emitting particles on Y axis.
  16380. */
  16381. minScaleY: number;
  16382. /**
  16383. * Maximum scale of emitting particles on Y axis.
  16384. */
  16385. maxScaleY: number;
  16386. /**
  16387. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16388. */
  16389. color1: Color4;
  16390. /**
  16391. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16392. */
  16393. color2: Color4;
  16394. /**
  16395. * Color the particle will have at the end of its lifetime.
  16396. */
  16397. colorDead: Color4;
  16398. /**
  16399. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16400. */
  16401. emitRate: number;
  16402. /**
  16403. * You can use gravity if you want to give an orientation to your particles.
  16404. */
  16405. gravity: Vector3;
  16406. /**
  16407. * Minimum power of emitting particles.
  16408. */
  16409. minEmitPower: number;
  16410. /**
  16411. * Maximum power of emitting particles.
  16412. */
  16413. maxEmitPower: number;
  16414. /**
  16415. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16416. */
  16417. minAngularSpeed: number;
  16418. /**
  16419. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16420. */
  16421. maxAngularSpeed: number;
  16422. /**
  16423. * Gets or sets the minimal initial rotation in radians.
  16424. */
  16425. minInitialRotation: number;
  16426. /**
  16427. * Gets or sets the maximal initial rotation in radians.
  16428. */
  16429. maxInitialRotation: number;
  16430. /**
  16431. * The particle emitter type defines the emitter used by the particle system.
  16432. * It can be for example box, sphere, or cone...
  16433. */
  16434. particleEmitterType: Nullable<IParticleEmitterType>;
  16435. /**
  16436. * Defines the delay in milliseconds before starting the system (0 by default)
  16437. */
  16438. startDelay: number;
  16439. /**
  16440. * 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
  16441. */
  16442. preWarmCycles: number;
  16443. /**
  16444. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16445. */
  16446. preWarmStepOffset: number;
  16447. /**
  16448. * 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)
  16449. */
  16450. spriteCellChangeSpeed: number;
  16451. /**
  16452. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16453. */
  16454. startSpriteCellID: number;
  16455. /**
  16456. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16457. */
  16458. endSpriteCellID: number;
  16459. /**
  16460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16461. */
  16462. spriteCellWidth: number;
  16463. /**
  16464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16465. */
  16466. spriteCellHeight: number;
  16467. /**
  16468. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16469. */
  16470. spriteRandomStartCell: boolean;
  16471. /**
  16472. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16473. */
  16474. isAnimationSheetEnabled: boolean;
  16475. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16476. translationPivot: Vector2;
  16477. /**
  16478. * Gets or sets a texture used to add random noise to particle positions
  16479. */
  16480. noiseTexture: Nullable<BaseTexture>;
  16481. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16482. noiseStrength: Vector3;
  16483. /**
  16484. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16485. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16486. */
  16487. billboardMode: number;
  16488. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16489. limitVelocityDamping: number;
  16490. /**
  16491. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16492. */
  16493. beginAnimationOnStart: boolean;
  16494. /**
  16495. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16496. */
  16497. beginAnimationFrom: number;
  16498. /**
  16499. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16500. */
  16501. beginAnimationTo: number;
  16502. /**
  16503. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16504. */
  16505. beginAnimationLoop: boolean;
  16506. /**
  16507. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16508. */
  16509. disposeOnStop: boolean;
  16510. /**
  16511. * Gets the maximum number of particles active at the same time.
  16512. * @returns The max number of active particles.
  16513. */
  16514. getCapacity(): number;
  16515. /**
  16516. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16517. * @returns True if it has been started, otherwise false.
  16518. */
  16519. isStarted(): boolean;
  16520. /**
  16521. * Animates the particle system for this frame.
  16522. */
  16523. animate(): void;
  16524. /**
  16525. * Renders the particle system in its current state.
  16526. * @returns the current number of particles
  16527. */
  16528. render(): number;
  16529. /**
  16530. * Dispose the particle system and frees its associated resources.
  16531. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16532. */
  16533. dispose(disposeTexture?: boolean): void;
  16534. /**
  16535. * Clones the particle system.
  16536. * @param name The name of the cloned object
  16537. * @param newEmitter The new emitter to use
  16538. * @returns the cloned particle system
  16539. */
  16540. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16541. /**
  16542. * Serializes the particle system to a JSON object.
  16543. * @returns the JSON object
  16544. */
  16545. serialize(): any;
  16546. /**
  16547. * Rebuild the particle system
  16548. */
  16549. rebuild(): void;
  16550. /**
  16551. * Starts the particle system and begins to emit
  16552. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16553. */
  16554. start(delay?: number): void;
  16555. /**
  16556. * Stops the particle system.
  16557. */
  16558. stop(): void;
  16559. /**
  16560. * Remove all active particles
  16561. */
  16562. reset(): void;
  16563. /**
  16564. * Is this system ready to be used/rendered
  16565. * @return true if the system is ready
  16566. */
  16567. isReady(): boolean;
  16568. /**
  16569. * Adds a new color gradient
  16570. * @param gradient defines the gradient to use (between 0 and 1)
  16571. * @param color1 defines the color to affect to the specified gradient
  16572. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16573. * @returns the current particle system
  16574. */
  16575. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16576. /**
  16577. * Remove a specific color gradient
  16578. * @param gradient defines the gradient to remove
  16579. * @returns the current particle system
  16580. */
  16581. removeColorGradient(gradient: number): IParticleSystem;
  16582. /**
  16583. * Adds a new size gradient
  16584. * @param gradient defines the gradient to use (between 0 and 1)
  16585. * @param factor defines the size factor to affect to the specified gradient
  16586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16587. * @returns the current particle system
  16588. */
  16589. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16590. /**
  16591. * Remove a specific size gradient
  16592. * @param gradient defines the gradient to remove
  16593. * @returns the current particle system
  16594. */
  16595. removeSizeGradient(gradient: number): IParticleSystem;
  16596. /**
  16597. * Gets the current list of color gradients.
  16598. * You must use addColorGradient and removeColorGradient to udpate this list
  16599. * @returns the list of color gradients
  16600. */
  16601. getColorGradients(): Nullable<Array<ColorGradient>>;
  16602. /**
  16603. * Gets the current list of size gradients.
  16604. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16605. * @returns the list of size gradients
  16606. */
  16607. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16608. /**
  16609. * Gets the current list of angular speed gradients.
  16610. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16611. * @returns the list of angular speed gradients
  16612. */
  16613. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16614. /**
  16615. * Adds a new angular speed gradient
  16616. * @param gradient defines the gradient to use (between 0 and 1)
  16617. * @param factor defines the angular speed to affect to the specified gradient
  16618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16619. * @returns the current particle system
  16620. */
  16621. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16622. /**
  16623. * Remove a specific angular speed gradient
  16624. * @param gradient defines the gradient to remove
  16625. * @returns the current particle system
  16626. */
  16627. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16628. /**
  16629. * Gets the current list of velocity gradients.
  16630. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16631. * @returns the list of velocity gradients
  16632. */
  16633. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16634. /**
  16635. * Adds a new velocity gradient
  16636. * @param gradient defines the gradient to use (between 0 and 1)
  16637. * @param factor defines the velocity to affect to the specified gradient
  16638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16639. * @returns the current particle system
  16640. */
  16641. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16642. /**
  16643. * Remove a specific velocity gradient
  16644. * @param gradient defines the gradient to remove
  16645. * @returns the current particle system
  16646. */
  16647. removeVelocityGradient(gradient: number): IParticleSystem;
  16648. /**
  16649. * Gets the current list of limit velocity gradients.
  16650. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16651. * @returns the list of limit velocity gradients
  16652. */
  16653. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16654. /**
  16655. * Adds a new limit velocity gradient
  16656. * @param gradient defines the gradient to use (between 0 and 1)
  16657. * @param factor defines the limit velocity to affect to the specified gradient
  16658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16659. * @returns the current particle system
  16660. */
  16661. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16662. /**
  16663. * Remove a specific limit velocity gradient
  16664. * @param gradient defines the gradient to remove
  16665. * @returns the current particle system
  16666. */
  16667. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16668. /**
  16669. * Adds a new drag gradient
  16670. * @param gradient defines the gradient to use (between 0 and 1)
  16671. * @param factor defines the drag to affect to the specified gradient
  16672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16673. * @returns the current particle system
  16674. */
  16675. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16676. /**
  16677. * Remove a specific drag gradient
  16678. * @param gradient defines the gradient to remove
  16679. * @returns the current particle system
  16680. */
  16681. removeDragGradient(gradient: number): IParticleSystem;
  16682. /**
  16683. * Gets the current list of drag gradients.
  16684. * You must use addDragGradient and removeDragGradient to udpate this list
  16685. * @returns the list of drag gradients
  16686. */
  16687. getDragGradients(): Nullable<Array<FactorGradient>>;
  16688. /**
  16689. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16690. * @param gradient defines the gradient to use (between 0 and 1)
  16691. * @param factor defines the emit rate to affect to the specified gradient
  16692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16693. * @returns the current particle system
  16694. */
  16695. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16696. /**
  16697. * Remove a specific emit rate gradient
  16698. * @param gradient defines the gradient to remove
  16699. * @returns the current particle system
  16700. */
  16701. removeEmitRateGradient(gradient: number): IParticleSystem;
  16702. /**
  16703. * Gets the current list of emit rate gradients.
  16704. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16705. * @returns the list of emit rate gradients
  16706. */
  16707. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16708. /**
  16709. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16710. * @param gradient defines the gradient to use (between 0 and 1)
  16711. * @param factor defines the start size to affect to the specified gradient
  16712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16713. * @returns the current particle system
  16714. */
  16715. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16716. /**
  16717. * Remove a specific start size gradient
  16718. * @param gradient defines the gradient to remove
  16719. * @returns the current particle system
  16720. */
  16721. removeStartSizeGradient(gradient: number): IParticleSystem;
  16722. /**
  16723. * Gets the current list of start size gradients.
  16724. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16725. * @returns the list of start size gradients
  16726. */
  16727. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16728. /**
  16729. * Adds a new life time gradient
  16730. * @param gradient defines the gradient to use (between 0 and 1)
  16731. * @param factor defines the life time factor to affect to the specified gradient
  16732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16733. * @returns the current particle system
  16734. */
  16735. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16736. /**
  16737. * Remove a specific life time gradient
  16738. * @param gradient defines the gradient to remove
  16739. * @returns the current particle system
  16740. */
  16741. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16742. /**
  16743. * Gets the current list of life time gradients.
  16744. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16745. * @returns the list of life time gradients
  16746. */
  16747. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16748. /**
  16749. * Gets the current list of color gradients.
  16750. * You must use addColorGradient and removeColorGradient to udpate this list
  16751. * @returns the list of color gradients
  16752. */
  16753. getColorGradients(): Nullable<Array<ColorGradient>>;
  16754. /**
  16755. * Adds a new ramp gradient used to remap particle colors
  16756. * @param gradient defines the gradient to use (between 0 and 1)
  16757. * @param color defines the color to affect to the specified gradient
  16758. * @returns the current particle system
  16759. */
  16760. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16761. /**
  16762. * Gets the current list of ramp gradients.
  16763. * You must use addRampGradient and removeRampGradient to udpate this list
  16764. * @returns the list of ramp gradients
  16765. */
  16766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16767. /** Gets or sets a boolean indicating that ramp gradients must be used
  16768. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16769. */
  16770. useRampGradients: boolean;
  16771. /**
  16772. * Adds a new color remap gradient
  16773. * @param gradient defines the gradient to use (between 0 and 1)
  16774. * @param min defines the color remap minimal range
  16775. * @param max defines the color remap maximal range
  16776. * @returns the current particle system
  16777. */
  16778. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16779. /**
  16780. * Gets the current list of color remap gradients.
  16781. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16782. * @returns the list of color remap gradients
  16783. */
  16784. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16785. /**
  16786. * Adds a new alpha remap gradient
  16787. * @param gradient defines the gradient to use (between 0 and 1)
  16788. * @param min defines the alpha remap minimal range
  16789. * @param max defines the alpha remap maximal range
  16790. * @returns the current particle system
  16791. */
  16792. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16793. /**
  16794. * Gets the current list of alpha remap gradients.
  16795. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16796. * @returns the list of alpha remap gradients
  16797. */
  16798. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16799. /**
  16800. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16803. * @returns the emitter
  16804. */
  16805. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16806. /**
  16807. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16808. * @param radius The radius of the hemisphere to emit from
  16809. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16810. * @returns the emitter
  16811. */
  16812. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16813. /**
  16814. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16815. * @param radius The radius of the sphere to emit from
  16816. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16817. * @returns the emitter
  16818. */
  16819. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16820. /**
  16821. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16822. * @param radius The radius of the sphere to emit from
  16823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16825. * @returns the emitter
  16826. */
  16827. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16828. /**
  16829. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16830. * @param radius The radius of the emission cylinder
  16831. * @param height The height of the emission cylinder
  16832. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16833. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16834. * @returns the emitter
  16835. */
  16836. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16837. /**
  16838. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16839. * @param radius The radius of the cylinder to emit from
  16840. * @param height The height of the emission cylinder
  16841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16844. * @returns the emitter
  16845. */
  16846. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16847. /**
  16848. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16849. * @param radius The radius of the cone to emit from
  16850. * @param angle The base angle of the cone
  16851. * @returns the emitter
  16852. */
  16853. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16854. /**
  16855. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16858. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16859. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16860. * @returns the emitter
  16861. */
  16862. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16863. /**
  16864. * Get hosting scene
  16865. * @returns the scene
  16866. */
  16867. getScene(): Scene;
  16868. }
  16869. }
  16870. declare module "babylonjs/Meshes/instancedMesh" {
  16871. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16872. import { Vector3 } from "babylonjs/Maths/math";
  16873. import { Camera } from "babylonjs/Cameras/camera";
  16874. import { Node } from "babylonjs/node";
  16875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16876. import { Mesh } from "babylonjs/Meshes/mesh";
  16877. import { Material } from "babylonjs/Materials/material";
  16878. import { Skeleton } from "babylonjs/Bones/skeleton";
  16879. /**
  16880. * Creates an instance based on a source mesh.
  16881. */
  16882. export class InstancedMesh extends AbstractMesh {
  16883. private _sourceMesh;
  16884. private _currentLOD;
  16885. /** @hidden */
  16886. _indexInSourceMeshInstanceArray: number;
  16887. constructor(name: string, source: Mesh);
  16888. /**
  16889. * Returns the string "InstancedMesh".
  16890. */
  16891. getClassName(): string;
  16892. /**
  16893. * If the source mesh receives shadows
  16894. */
  16895. readonly receiveShadows: boolean;
  16896. /**
  16897. * The material of the source mesh
  16898. */
  16899. readonly material: Nullable<Material>;
  16900. /**
  16901. * Visibility of the source mesh
  16902. */
  16903. readonly visibility: number;
  16904. /**
  16905. * Skeleton of the source mesh
  16906. */
  16907. readonly skeleton: Nullable<Skeleton>;
  16908. /**
  16909. * Rendering ground id of the source mesh
  16910. */
  16911. renderingGroupId: number;
  16912. /**
  16913. * Returns the total number of vertices (integer).
  16914. */
  16915. getTotalVertices(): number;
  16916. /**
  16917. * Returns a positive integer : the total number of indices in this mesh geometry.
  16918. * @returns the numner of indices or zero if the mesh has no geometry.
  16919. */
  16920. getTotalIndices(): number;
  16921. /**
  16922. * The source mesh of the instance
  16923. */
  16924. readonly sourceMesh: Mesh;
  16925. /**
  16926. * Is this node ready to be used/rendered
  16927. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16928. * @return {boolean} is it ready
  16929. */
  16930. isReady(completeCheck?: boolean): boolean;
  16931. /**
  16932. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16933. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16934. * @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.
  16935. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16936. */
  16937. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16938. /**
  16939. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16940. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16941. * The `data` are either a numeric array either a Float32Array.
  16942. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16943. * 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).
  16944. * Note that a new underlying VertexBuffer object is created each call.
  16945. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16946. *
  16947. * Possible `kind` values :
  16948. * - VertexBuffer.PositionKind
  16949. * - VertexBuffer.UVKind
  16950. * - VertexBuffer.UV2Kind
  16951. * - VertexBuffer.UV3Kind
  16952. * - VertexBuffer.UV4Kind
  16953. * - VertexBuffer.UV5Kind
  16954. * - VertexBuffer.UV6Kind
  16955. * - VertexBuffer.ColorKind
  16956. * - VertexBuffer.MatricesIndicesKind
  16957. * - VertexBuffer.MatricesIndicesExtraKind
  16958. * - VertexBuffer.MatricesWeightsKind
  16959. * - VertexBuffer.MatricesWeightsExtraKind
  16960. *
  16961. * Returns the Mesh.
  16962. */
  16963. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16964. /**
  16965. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16966. * If the mesh has no geometry, it is simply returned as it is.
  16967. * The `data` are either a numeric array either a Float32Array.
  16968. * No new underlying VertexBuffer object is created.
  16969. * 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.
  16970. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16971. *
  16972. * Possible `kind` values :
  16973. * - VertexBuffer.PositionKind
  16974. * - VertexBuffer.UVKind
  16975. * - VertexBuffer.UV2Kind
  16976. * - VertexBuffer.UV3Kind
  16977. * - VertexBuffer.UV4Kind
  16978. * - VertexBuffer.UV5Kind
  16979. * - VertexBuffer.UV6Kind
  16980. * - VertexBuffer.ColorKind
  16981. * - VertexBuffer.MatricesIndicesKind
  16982. * - VertexBuffer.MatricesIndicesExtraKind
  16983. * - VertexBuffer.MatricesWeightsKind
  16984. * - VertexBuffer.MatricesWeightsExtraKind
  16985. *
  16986. * Returns the Mesh.
  16987. */
  16988. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16989. /**
  16990. * Sets the mesh indices.
  16991. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16992. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16993. * This method creates a new index buffer each call.
  16994. * Returns the Mesh.
  16995. */
  16996. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16997. /**
  16998. * Boolean : True if the mesh owns the requested kind of data.
  16999. */
  17000. isVerticesDataPresent(kind: string): boolean;
  17001. /**
  17002. * Returns an array of indices (IndicesArray).
  17003. */
  17004. getIndices(): Nullable<IndicesArray>;
  17005. readonly _positions: Nullable<Vector3[]>;
  17006. /**
  17007. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17008. * This means the mesh underlying bounding box and sphere are recomputed.
  17009. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17010. * @returns the current mesh
  17011. */
  17012. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17013. /** @hidden */
  17014. _preActivate(): InstancedMesh;
  17015. /** @hidden */
  17016. _activate(renderId: number): InstancedMesh;
  17017. /**
  17018. * Returns the current associated LOD AbstractMesh.
  17019. */
  17020. getLOD(camera: Camera): AbstractMesh;
  17021. /** @hidden */
  17022. _syncSubMeshes(): InstancedMesh;
  17023. /** @hidden */
  17024. _generatePointsArray(): boolean;
  17025. /**
  17026. * Creates a new InstancedMesh from the current mesh.
  17027. * - name (string) : the cloned mesh name
  17028. * - newParent (optional Node) : the optional Node to parent the clone to.
  17029. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17030. *
  17031. * Returns the clone.
  17032. */
  17033. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17034. /**
  17035. * Disposes the InstancedMesh.
  17036. * Returns nothing.
  17037. */
  17038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17039. }
  17040. }
  17041. declare module "babylonjs/Materials/shaderMaterial" {
  17042. import { Scene } from "babylonjs/scene";
  17043. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17045. import { Mesh } from "babylonjs/Meshes/mesh";
  17046. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17048. import { Texture } from "babylonjs/Materials/Textures/texture";
  17049. import { Material } from "babylonjs/Materials/material";
  17050. /**
  17051. * Defines the options associated with the creation of a shader material.
  17052. */
  17053. export interface IShaderMaterialOptions {
  17054. /**
  17055. * Does the material work in alpha blend mode
  17056. */
  17057. needAlphaBlending: boolean;
  17058. /**
  17059. * Does the material work in alpha test mode
  17060. */
  17061. needAlphaTesting: boolean;
  17062. /**
  17063. * The list of attribute names used in the shader
  17064. */
  17065. attributes: string[];
  17066. /**
  17067. * The list of unifrom names used in the shader
  17068. */
  17069. uniforms: string[];
  17070. /**
  17071. * The list of UBO names used in the shader
  17072. */
  17073. uniformBuffers: string[];
  17074. /**
  17075. * The list of sampler names used in the shader
  17076. */
  17077. samplers: string[];
  17078. /**
  17079. * The list of defines used in the shader
  17080. */
  17081. defines: string[];
  17082. }
  17083. /**
  17084. * 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.
  17085. *
  17086. * This returned material effects how the mesh will look based on the code in the shaders.
  17087. *
  17088. * @see http://doc.babylonjs.com/how_to/shader_material
  17089. */
  17090. export class ShaderMaterial extends Material {
  17091. private _shaderPath;
  17092. private _options;
  17093. private _textures;
  17094. private _textureArrays;
  17095. private _floats;
  17096. private _ints;
  17097. private _floatsArrays;
  17098. private _colors3;
  17099. private _colors3Arrays;
  17100. private _colors4;
  17101. private _vectors2;
  17102. private _vectors3;
  17103. private _vectors4;
  17104. private _matrices;
  17105. private _matrices3x3;
  17106. private _matrices2x2;
  17107. private _vectors2Arrays;
  17108. private _vectors3Arrays;
  17109. private _cachedWorldViewMatrix;
  17110. private _renderId;
  17111. /**
  17112. * Instantiate a new shader material.
  17113. * 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.
  17114. * This returned material effects how the mesh will look based on the code in the shaders.
  17115. * @see http://doc.babylonjs.com/how_to/shader_material
  17116. * @param name Define the name of the material in the scene
  17117. * @param scene Define the scene the material belongs to
  17118. * @param shaderPath Defines the route to the shader code in one of three ways:
  17119. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17120. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17121. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17122. * @param options Define the options used to create the shader
  17123. */
  17124. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17125. /**
  17126. * Gets the options used to compile the shader.
  17127. * They can be modified to trigger a new compilation
  17128. */
  17129. readonly options: IShaderMaterialOptions;
  17130. /**
  17131. * Gets the current class name of the material e.g. "ShaderMaterial"
  17132. * Mainly use in serialization.
  17133. * @returns the class name
  17134. */
  17135. getClassName(): string;
  17136. /**
  17137. * Specifies if the material will require alpha blending
  17138. * @returns a boolean specifying if alpha blending is needed
  17139. */
  17140. needAlphaBlending(): boolean;
  17141. /**
  17142. * Specifies if this material should be rendered in alpha test mode
  17143. * @returns a boolean specifying if an alpha test is needed.
  17144. */
  17145. needAlphaTesting(): boolean;
  17146. private _checkUniform;
  17147. /**
  17148. * Set a texture in the shader.
  17149. * @param name Define the name of the uniform samplers as defined in the shader
  17150. * @param texture Define the texture to bind to this sampler
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setTexture(name: string, texture: Texture): ShaderMaterial;
  17154. /**
  17155. * Set a texture array in the shader.
  17156. * @param name Define the name of the uniform sampler array as defined in the shader
  17157. * @param textures Define the list of textures to bind to this sampler
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17161. /**
  17162. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  17168. /**
  17169. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  17175. /**
  17176. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  17182. /**
  17183. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  17189. /**
  17190. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17196. /**
  17197. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  17203. /**
  17204. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  17210. /**
  17211. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  17217. /**
  17218. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  17224. /**
  17225. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17231. /**
  17232. * Set a mat3 in the shader from a Float32Array.
  17233. * @param name Define the name of the uniform as defined in the shader
  17234. * @param value Define the value to give to the uniform
  17235. * @return the material itself allowing "fluent" like uniform updates
  17236. */
  17237. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17238. /**
  17239. * Set a mat2 in the shader from a Float32Array.
  17240. * @param name Define the name of the uniform as defined in the shader
  17241. * @param value Define the value to give to the uniform
  17242. * @return the material itself allowing "fluent" like uniform updates
  17243. */
  17244. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17245. /**
  17246. * Set a vec2 array in the shader from a number array.
  17247. * @param name Define the name of the uniform as defined in the shader
  17248. * @param value Define the value to give to the uniform
  17249. * @return the material itself allowing "fluent" like uniform updates
  17250. */
  17251. setArray2(name: string, value: number[]): ShaderMaterial;
  17252. /**
  17253. * Set a vec3 array in the shader from a number array.
  17254. * @param name Define the name of the uniform as defined in the shader
  17255. * @param value Define the value to give to the uniform
  17256. * @return the material itself allowing "fluent" like uniform updates
  17257. */
  17258. setArray3(name: string, value: number[]): ShaderMaterial;
  17259. private _checkCache;
  17260. /**
  17261. * Specifies that the submesh is ready to be used
  17262. * @param mesh defines the mesh to check
  17263. * @param subMesh defines which submesh to check
  17264. * @param useInstances specifies that instances should be used
  17265. * @returns a boolean indicating that the submesh is ready or not
  17266. */
  17267. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17268. /**
  17269. * Checks if the material is ready to render the requested mesh
  17270. * @param mesh Define the mesh to render
  17271. * @param useInstances Define whether or not the material is used with instances
  17272. * @returns true if ready, otherwise false
  17273. */
  17274. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17275. /**
  17276. * Binds the world matrix to the material
  17277. * @param world defines the world transformation matrix
  17278. */
  17279. bindOnlyWorldMatrix(world: Matrix): void;
  17280. /**
  17281. * Binds the material to the mesh
  17282. * @param world defines the world transformation matrix
  17283. * @param mesh defines the mesh to bind the material to
  17284. */
  17285. bind(world: Matrix, mesh?: Mesh): void;
  17286. /**
  17287. * Gets the active textures from the material
  17288. * @returns an array of textures
  17289. */
  17290. getActiveTextures(): BaseTexture[];
  17291. /**
  17292. * Specifies if the material uses a texture
  17293. * @param texture defines the texture to check against the material
  17294. * @returns a boolean specifying if the material uses the texture
  17295. */
  17296. hasTexture(texture: BaseTexture): boolean;
  17297. /**
  17298. * Makes a duplicate of the material, and gives it a new name
  17299. * @param name defines the new name for the duplicated material
  17300. * @returns the cloned material
  17301. */
  17302. clone(name: string): ShaderMaterial;
  17303. /**
  17304. * Disposes the material
  17305. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17306. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17307. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17308. */
  17309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17310. /**
  17311. * Serializes this material in a JSON representation
  17312. * @returns the serialized material object
  17313. */
  17314. serialize(): any;
  17315. /**
  17316. * Creates a shader material from parsed shader material data
  17317. * @param source defines the JSON represnetation of the material
  17318. * @param scene defines the hosting scene
  17319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17320. * @returns a new material
  17321. */
  17322. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17323. }
  17324. }
  17325. declare module "babylonjs/Shaders/color.fragment" {
  17326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17328. /** @hidden */
  17329. export var colorPixelShader: {
  17330. name: string;
  17331. shader: string;
  17332. };
  17333. }
  17334. declare module "babylonjs/Shaders/color.vertex" {
  17335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17336. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17337. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17338. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17339. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17340. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17341. /** @hidden */
  17342. export var colorVertexShader: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Meshes/linesMesh" {
  17348. import { Nullable } from "babylonjs/types";
  17349. import { Scene } from "babylonjs/scene";
  17350. import { Color3 } from "babylonjs/Maths/math";
  17351. import { Node } from "babylonjs/node";
  17352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17353. import { Mesh } from "babylonjs/Meshes/mesh";
  17354. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17355. import { Effect } from "babylonjs/Materials/effect";
  17356. import { Material } from "babylonjs/Materials/material";
  17357. import "babylonjs/Shaders/color.fragment";
  17358. import "babylonjs/Shaders/color.vertex";
  17359. /**
  17360. * Line mesh
  17361. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17362. */
  17363. export class LinesMesh extends Mesh {
  17364. /**
  17365. * If vertex color should be applied to the mesh
  17366. */
  17367. useVertexColor?: boolean | undefined;
  17368. /**
  17369. * If vertex alpha should be applied to the mesh
  17370. */
  17371. useVertexAlpha?: boolean | undefined;
  17372. /**
  17373. * Color of the line (Default: White)
  17374. */
  17375. color: Color3;
  17376. /**
  17377. * Alpha of the line (Default: 1)
  17378. */
  17379. alpha: number;
  17380. /**
  17381. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17382. * This margin is expressed in world space coordinates, so its value may vary.
  17383. * Default value is 0.1
  17384. */
  17385. intersectionThreshold: number;
  17386. private _colorShader;
  17387. /**
  17388. * Creates a new LinesMesh
  17389. * @param name defines the name
  17390. * @param scene defines the hosting scene
  17391. * @param parent defines the parent mesh if any
  17392. * @param source defines the optional source LinesMesh used to clone data from
  17393. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17394. * When false, achieved by calling a clone(), also passing False.
  17395. * This will make creation of children, recursive.
  17396. * @param useVertexColor defines if this LinesMesh supports vertex color
  17397. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17398. */
  17399. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17400. /**
  17401. * If vertex color should be applied to the mesh
  17402. */
  17403. useVertexColor?: boolean | undefined,
  17404. /**
  17405. * If vertex alpha should be applied to the mesh
  17406. */
  17407. useVertexAlpha?: boolean | undefined);
  17408. private _addClipPlaneDefine;
  17409. private _removeClipPlaneDefine;
  17410. isReady(): boolean;
  17411. /**
  17412. * Returns the string "LineMesh"
  17413. */
  17414. getClassName(): string;
  17415. /**
  17416. * @hidden
  17417. */
  17418. /**
  17419. * @hidden
  17420. */
  17421. material: Material;
  17422. /**
  17423. * @hidden
  17424. */
  17425. readonly checkCollisions: boolean;
  17426. /** @hidden */
  17427. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17428. /** @hidden */
  17429. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17430. /**
  17431. * Disposes of the line mesh
  17432. * @param doNotRecurse If children should be disposed
  17433. */
  17434. dispose(doNotRecurse?: boolean): void;
  17435. /**
  17436. * Returns a new LineMesh object cloned from the current one.
  17437. */
  17438. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17439. /**
  17440. * Creates a new InstancedLinesMesh object from the mesh model.
  17441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17442. * @param name defines the name of the new instance
  17443. * @returns a new InstancedLinesMesh
  17444. */
  17445. createInstance(name: string): InstancedLinesMesh;
  17446. }
  17447. /**
  17448. * Creates an instance based on a source LinesMesh
  17449. */
  17450. export class InstancedLinesMesh extends InstancedMesh {
  17451. /**
  17452. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17453. * This margin is expressed in world space coordinates, so its value may vary.
  17454. * Initilized with the intersectionThreshold value of the source LinesMesh
  17455. */
  17456. intersectionThreshold: number;
  17457. constructor(name: string, source: LinesMesh);
  17458. /**
  17459. * Returns the string "InstancedLinesMesh".
  17460. */
  17461. getClassName(): string;
  17462. }
  17463. }
  17464. declare module "babylonjs/Shaders/line.fragment" {
  17465. /** @hidden */
  17466. export var linePixelShader: {
  17467. name: string;
  17468. shader: string;
  17469. };
  17470. }
  17471. declare module "babylonjs/Shaders/line.vertex" {
  17472. /** @hidden */
  17473. export var lineVertexShader: {
  17474. name: string;
  17475. shader: string;
  17476. };
  17477. }
  17478. declare module "babylonjs/Rendering/edgesRenderer" {
  17479. import { Nullable } from "babylonjs/types";
  17480. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17482. import { Vector3 } from "babylonjs/Maths/math";
  17483. import { IDisposable } from "babylonjs/scene";
  17484. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17485. import "babylonjs/Shaders/line.fragment";
  17486. import "babylonjs/Shaders/line.vertex";
  17487. module "babylonjs/Meshes/abstractMesh" {
  17488. interface AbstractMesh {
  17489. /**
  17490. * Disables the mesh edge rendering mode
  17491. * @returns the currentAbstractMesh
  17492. */
  17493. disableEdgesRendering(): AbstractMesh;
  17494. /**
  17495. * Enables the edge rendering mode on the mesh.
  17496. * This mode makes the mesh edges visible
  17497. * @param epsilon defines the maximal distance between two angles to detect a face
  17498. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17499. * @returns the currentAbstractMesh
  17500. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17501. */
  17502. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17503. /**
  17504. * Gets the edgesRenderer associated with the mesh
  17505. */
  17506. edgesRenderer: Nullable<EdgesRenderer>;
  17507. }
  17508. }
  17509. module "babylonjs/Meshes/linesMesh" {
  17510. interface LinesMesh {
  17511. /**
  17512. * Enables the edge rendering mode on the mesh.
  17513. * This mode makes the mesh edges visible
  17514. * @param epsilon defines the maximal distance between two angles to detect a face
  17515. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17516. * @returns the currentAbstractMesh
  17517. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17518. */
  17519. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17520. }
  17521. }
  17522. module "babylonjs/Meshes/linesMesh" {
  17523. interface InstancedLinesMesh {
  17524. /**
  17525. * Enables the edge rendering mode on the mesh.
  17526. * This mode makes the mesh edges visible
  17527. * @param epsilon defines the maximal distance between two angles to detect a face
  17528. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17529. * @returns the current InstancedLinesMesh
  17530. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17531. */
  17532. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17533. }
  17534. }
  17535. /**
  17536. * Defines the minimum contract an Edges renderer should follow.
  17537. */
  17538. export interface IEdgesRenderer extends IDisposable {
  17539. /**
  17540. * Gets or sets a boolean indicating if the edgesRenderer is active
  17541. */
  17542. isEnabled: boolean;
  17543. /**
  17544. * Renders the edges of the attached mesh,
  17545. */
  17546. render(): void;
  17547. /**
  17548. * Checks wether or not the edges renderer is ready to render.
  17549. * @return true if ready, otherwise false.
  17550. */
  17551. isReady(): boolean;
  17552. }
  17553. /**
  17554. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17555. */
  17556. export class EdgesRenderer implements IEdgesRenderer {
  17557. /**
  17558. * Define the size of the edges with an orthographic camera
  17559. */
  17560. edgesWidthScalerForOrthographic: number;
  17561. /**
  17562. * Define the size of the edges with a perspective camera
  17563. */
  17564. edgesWidthScalerForPerspective: number;
  17565. protected _source: AbstractMesh;
  17566. protected _linesPositions: number[];
  17567. protected _linesNormals: number[];
  17568. protected _linesIndices: number[];
  17569. protected _epsilon: number;
  17570. protected _indicesCount: number;
  17571. protected _lineShader: ShaderMaterial;
  17572. protected _ib: WebGLBuffer;
  17573. protected _buffers: {
  17574. [key: string]: Nullable<VertexBuffer>;
  17575. };
  17576. protected _checkVerticesInsteadOfIndices: boolean;
  17577. private _meshRebuildObserver;
  17578. private _meshDisposeObserver;
  17579. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17580. isEnabled: boolean;
  17581. /**
  17582. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17583. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17584. * @param source Mesh used to create edges
  17585. * @param epsilon sum of angles in adjacency to check for edge
  17586. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17587. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17588. */
  17589. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17590. protected _prepareRessources(): void;
  17591. /** @hidden */
  17592. _rebuild(): void;
  17593. /**
  17594. * Releases the required resources for the edges renderer
  17595. */
  17596. dispose(): void;
  17597. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17598. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17599. /**
  17600. * Checks if the pair of p0 and p1 is en edge
  17601. * @param faceIndex
  17602. * @param edge
  17603. * @param faceNormals
  17604. * @param p0
  17605. * @param p1
  17606. * @private
  17607. */
  17608. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17609. /**
  17610. * push line into the position, normal and index buffer
  17611. * @protected
  17612. */
  17613. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17614. /**
  17615. * Generates lines edges from adjacencjes
  17616. * @private
  17617. */
  17618. _generateEdgesLines(): void;
  17619. /**
  17620. * Checks wether or not the edges renderer is ready to render.
  17621. * @return true if ready, otherwise false.
  17622. */
  17623. isReady(): boolean;
  17624. /**
  17625. * Renders the edges of the attached mesh,
  17626. */
  17627. render(): void;
  17628. }
  17629. /**
  17630. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17631. */
  17632. export class LineEdgesRenderer extends EdgesRenderer {
  17633. /**
  17634. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17635. * @param source LineMesh used to generate edges
  17636. * @param epsilon not important (specified angle for edge detection)
  17637. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17638. */
  17639. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17640. /**
  17641. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17642. */
  17643. _generateEdgesLines(): void;
  17644. }
  17645. }
  17646. declare module "babylonjs/Rendering/renderingGroup" {
  17647. import { SmartArray } from "babylonjs/Misc/smartArray";
  17648. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17650. import { Nullable } from "babylonjs/types";
  17651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17652. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17653. import { Material } from "babylonjs/Materials/material";
  17654. import { Scene } from "babylonjs/scene";
  17655. /**
  17656. * This represents the object necessary to create a rendering group.
  17657. * This is exclusively used and created by the rendering manager.
  17658. * To modify the behavior, you use the available helpers in your scene or meshes.
  17659. * @hidden
  17660. */
  17661. export class RenderingGroup {
  17662. index: number;
  17663. private _scene;
  17664. private _opaqueSubMeshes;
  17665. private _transparentSubMeshes;
  17666. private _alphaTestSubMeshes;
  17667. private _depthOnlySubMeshes;
  17668. private _particleSystems;
  17669. private _spriteManagers;
  17670. private _opaqueSortCompareFn;
  17671. private _alphaTestSortCompareFn;
  17672. private _transparentSortCompareFn;
  17673. private _renderOpaque;
  17674. private _renderAlphaTest;
  17675. private _renderTransparent;
  17676. private _edgesRenderers;
  17677. onBeforeTransparentRendering: () => void;
  17678. /**
  17679. * Set the opaque sort comparison function.
  17680. * If null the sub meshes will be render in the order they were created
  17681. */
  17682. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17683. /**
  17684. * Set the alpha test sort comparison function.
  17685. * If null the sub meshes will be render in the order they were created
  17686. */
  17687. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17688. /**
  17689. * Set the transparent sort comparison function.
  17690. * If null the sub meshes will be render in the order they were created
  17691. */
  17692. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17693. /**
  17694. * Creates a new rendering group.
  17695. * @param index The rendering group index
  17696. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17697. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17698. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17699. */
  17700. 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>);
  17701. /**
  17702. * Render all the sub meshes contained in the group.
  17703. * @param customRenderFunction Used to override the default render behaviour of the group.
  17704. * @returns true if rendered some submeshes.
  17705. */
  17706. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17707. /**
  17708. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17709. * @param subMeshes The submeshes to render
  17710. */
  17711. private renderOpaqueSorted;
  17712. /**
  17713. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17714. * @param subMeshes The submeshes to render
  17715. */
  17716. private renderAlphaTestSorted;
  17717. /**
  17718. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17719. * @param subMeshes The submeshes to render
  17720. */
  17721. private renderTransparentSorted;
  17722. /**
  17723. * Renders the submeshes in a specified order.
  17724. * @param subMeshes The submeshes to sort before render
  17725. * @param sortCompareFn The comparison function use to sort
  17726. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17727. * @param transparent Specifies to activate blending if true
  17728. */
  17729. private static renderSorted;
  17730. /**
  17731. * Renders the submeshes in the order they were dispatched (no sort applied).
  17732. * @param subMeshes The submeshes to render
  17733. */
  17734. private static renderUnsorted;
  17735. /**
  17736. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17737. * are rendered back to front if in the same alpha index.
  17738. *
  17739. * @param a The first submesh
  17740. * @param b The second submesh
  17741. * @returns The result of the comparison
  17742. */
  17743. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17744. /**
  17745. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17746. * are rendered back to front.
  17747. *
  17748. * @param a The first submesh
  17749. * @param b The second submesh
  17750. * @returns The result of the comparison
  17751. */
  17752. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17753. /**
  17754. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17755. * are rendered front to back (prevent overdraw).
  17756. *
  17757. * @param a The first submesh
  17758. * @param b The second submesh
  17759. * @returns The result of the comparison
  17760. */
  17761. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17762. /**
  17763. * Resets the different lists of submeshes to prepare a new frame.
  17764. */
  17765. prepare(): void;
  17766. dispose(): void;
  17767. /**
  17768. * Inserts the submesh in its correct queue depending on its material.
  17769. * @param subMesh The submesh to dispatch
  17770. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17771. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17772. */
  17773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17774. dispatchSprites(spriteManager: ISpriteManager): void;
  17775. dispatchParticles(particleSystem: IParticleSystem): void;
  17776. private _renderParticles;
  17777. private _renderSprites;
  17778. }
  17779. }
  17780. declare module "babylonjs/Rendering/renderingManager" {
  17781. import { Nullable } from "babylonjs/types";
  17782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17784. import { SmartArray } from "babylonjs/Misc/smartArray";
  17785. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17787. import { Material } from "babylonjs/Materials/material";
  17788. import { Scene } from "babylonjs/scene";
  17789. import { Camera } from "babylonjs/Cameras/camera";
  17790. /**
  17791. * Interface describing the different options available in the rendering manager
  17792. * regarding Auto Clear between groups.
  17793. */
  17794. export interface IRenderingManagerAutoClearSetup {
  17795. /**
  17796. * Defines whether or not autoclear is enable.
  17797. */
  17798. autoClear: boolean;
  17799. /**
  17800. * Defines whether or not to autoclear the depth buffer.
  17801. */
  17802. depth: boolean;
  17803. /**
  17804. * Defines whether or not to autoclear the stencil buffer.
  17805. */
  17806. stencil: boolean;
  17807. }
  17808. /**
  17809. * This class is used by the onRenderingGroupObservable
  17810. */
  17811. export class RenderingGroupInfo {
  17812. /**
  17813. * The Scene that being rendered
  17814. */
  17815. scene: Scene;
  17816. /**
  17817. * The camera currently used for the rendering pass
  17818. */
  17819. camera: Nullable<Camera>;
  17820. /**
  17821. * The ID of the renderingGroup being processed
  17822. */
  17823. renderingGroupId: number;
  17824. }
  17825. /**
  17826. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17827. * It is enable to manage the different groups as well as the different necessary sort functions.
  17828. * This should not be used directly aside of the few static configurations
  17829. */
  17830. export class RenderingManager {
  17831. /**
  17832. * The max id used for rendering groups (not included)
  17833. */
  17834. static MAX_RENDERINGGROUPS: number;
  17835. /**
  17836. * The min id used for rendering groups (included)
  17837. */
  17838. static MIN_RENDERINGGROUPS: number;
  17839. /**
  17840. * Used to globally prevent autoclearing scenes.
  17841. */
  17842. static AUTOCLEAR: boolean;
  17843. /**
  17844. * @hidden
  17845. */
  17846. _useSceneAutoClearSetup: boolean;
  17847. private _scene;
  17848. private _renderingGroups;
  17849. private _depthStencilBufferAlreadyCleaned;
  17850. private _autoClearDepthStencil;
  17851. private _customOpaqueSortCompareFn;
  17852. private _customAlphaTestSortCompareFn;
  17853. private _customTransparentSortCompareFn;
  17854. private _renderingGroupInfo;
  17855. /**
  17856. * Instantiates a new rendering group for a particular scene
  17857. * @param scene Defines the scene the groups belongs to
  17858. */
  17859. constructor(scene: Scene);
  17860. private _clearDepthStencilBuffer;
  17861. /**
  17862. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17863. * @hidden
  17864. */
  17865. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17866. /**
  17867. * Resets the different information of the group to prepare a new frame
  17868. * @hidden
  17869. */
  17870. reset(): void;
  17871. /**
  17872. * Dispose and release the group and its associated resources.
  17873. * @hidden
  17874. */
  17875. dispose(): void;
  17876. /**
  17877. * Clear the info related to rendering groups preventing retention points during dispose.
  17878. */
  17879. freeRenderingGroups(): void;
  17880. private _prepareRenderingGroup;
  17881. /**
  17882. * Add a sprite manager to the rendering manager in order to render it this frame.
  17883. * @param spriteManager Define the sprite manager to render
  17884. */
  17885. dispatchSprites(spriteManager: ISpriteManager): void;
  17886. /**
  17887. * Add a particle system to the rendering manager in order to render it this frame.
  17888. * @param particleSystem Define the particle system to render
  17889. */
  17890. dispatchParticles(particleSystem: IParticleSystem): void;
  17891. /**
  17892. * Add a submesh to the manager in order to render it this frame
  17893. * @param subMesh The submesh to dispatch
  17894. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17895. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17896. */
  17897. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17898. /**
  17899. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17900. * This allowed control for front to back rendering or reversly depending of the special needs.
  17901. *
  17902. * @param renderingGroupId The rendering group id corresponding to its index
  17903. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17904. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17905. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17906. */
  17907. 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;
  17908. /**
  17909. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17910. *
  17911. * @param renderingGroupId The rendering group id corresponding to its index
  17912. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17913. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17914. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17915. */
  17916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17917. /**
  17918. * Gets the current auto clear configuration for one rendering group of the rendering
  17919. * manager.
  17920. * @param index the rendering group index to get the information for
  17921. * @returns The auto clear setup for the requested rendering group
  17922. */
  17923. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17924. }
  17925. }
  17926. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17927. import { Observable } from "babylonjs/Misc/observable";
  17928. import { SmartArray } from "babylonjs/Misc/smartArray";
  17929. import { Nullable } from "babylonjs/types";
  17930. import { Camera } from "babylonjs/Cameras/camera";
  17931. import { Scene } from "babylonjs/scene";
  17932. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17933. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17937. import { Texture } from "babylonjs/Materials/Textures/texture";
  17938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17939. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17940. import { Engine } from "babylonjs/Engines/engine";
  17941. /**
  17942. * This Helps creating a texture that will be created from a camera in your scene.
  17943. * It is basically a dynamic texture that could be used to create special effects for instance.
  17944. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17945. */
  17946. export class RenderTargetTexture extends Texture {
  17947. isCube: boolean;
  17948. /**
  17949. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17950. */
  17951. static readonly REFRESHRATE_RENDER_ONCE: number;
  17952. /**
  17953. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17954. */
  17955. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17956. /**
  17957. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17958. * the central point of your effect and can save a lot of performances.
  17959. */
  17960. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17961. /**
  17962. * Use this predicate to dynamically define the list of mesh you want to render.
  17963. * If set, the renderList property will be overwritten.
  17964. */
  17965. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17966. private _renderList;
  17967. /**
  17968. * Use this list to define the list of mesh you want to render.
  17969. */
  17970. renderList: Nullable<Array<AbstractMesh>>;
  17971. private _hookArray;
  17972. /**
  17973. * Define if particles should be rendered in your texture.
  17974. */
  17975. renderParticles: boolean;
  17976. /**
  17977. * Define if sprites should be rendered in your texture.
  17978. */
  17979. renderSprites: boolean;
  17980. /**
  17981. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17982. */
  17983. coordinatesMode: number;
  17984. /**
  17985. * Define the camera used to render the texture.
  17986. */
  17987. activeCamera: Nullable<Camera>;
  17988. /**
  17989. * Override the render function of the texture with your own one.
  17990. */
  17991. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17992. /**
  17993. * Define if camera post processes should be use while rendering the texture.
  17994. */
  17995. useCameraPostProcesses: boolean;
  17996. /**
  17997. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17998. */
  17999. ignoreCameraViewport: boolean;
  18000. private _postProcessManager;
  18001. private _postProcesses;
  18002. private _resizeObserver;
  18003. /**
  18004. * An event triggered when the texture is unbind.
  18005. */
  18006. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18007. /**
  18008. * An event triggered when the texture is unbind.
  18009. */
  18010. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18011. private _onAfterUnbindObserver;
  18012. /**
  18013. * Set a after unbind callback in the texture.
  18014. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18015. */
  18016. onAfterUnbind: () => void;
  18017. /**
  18018. * An event triggered before rendering the texture
  18019. */
  18020. onBeforeRenderObservable: Observable<number>;
  18021. private _onBeforeRenderObserver;
  18022. /**
  18023. * Set a before render callback in the texture.
  18024. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18025. */
  18026. onBeforeRender: (faceIndex: number) => void;
  18027. /**
  18028. * An event triggered after rendering the texture
  18029. */
  18030. onAfterRenderObservable: Observable<number>;
  18031. private _onAfterRenderObserver;
  18032. /**
  18033. * Set a after render callback in the texture.
  18034. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18035. */
  18036. onAfterRender: (faceIndex: number) => void;
  18037. /**
  18038. * An event triggered after the texture clear
  18039. */
  18040. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18041. private _onClearObserver;
  18042. /**
  18043. * Set a clear callback in the texture.
  18044. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18045. */
  18046. onClear: (Engine: Engine) => void;
  18047. /**
  18048. * Define the clear color of the Render Target if it should be different from the scene.
  18049. */
  18050. clearColor: Color4;
  18051. protected _size: number | {
  18052. width: number;
  18053. height: number;
  18054. };
  18055. protected _initialSizeParameter: number | {
  18056. width: number;
  18057. height: number;
  18058. } | {
  18059. ratio: number;
  18060. };
  18061. protected _sizeRatio: Nullable<number>;
  18062. /** @hidden */
  18063. _generateMipMaps: boolean;
  18064. protected _renderingManager: RenderingManager;
  18065. /** @hidden */
  18066. _waitingRenderList: string[];
  18067. protected _doNotChangeAspectRatio: boolean;
  18068. protected _currentRefreshId: number;
  18069. protected _refreshRate: number;
  18070. protected _textureMatrix: Matrix;
  18071. protected _samples: number;
  18072. protected _renderTargetOptions: RenderTargetCreationOptions;
  18073. /**
  18074. * Gets render target creation options that were used.
  18075. */
  18076. readonly renderTargetOptions: RenderTargetCreationOptions;
  18077. protected _engine: Engine;
  18078. protected _onRatioRescale(): void;
  18079. /**
  18080. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18081. * It must define where the camera used to render the texture is set
  18082. */
  18083. boundingBoxPosition: Vector3;
  18084. private _boundingBoxSize;
  18085. /**
  18086. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18087. * When defined, the cubemap will switch to local mode
  18088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18089. * @example https://www.babylonjs-playground.com/#RNASML
  18090. */
  18091. boundingBoxSize: Vector3;
  18092. /**
  18093. * In case the RTT has been created with a depth texture, get the associated
  18094. * depth texture.
  18095. * Otherwise, return null.
  18096. */
  18097. depthStencilTexture: Nullable<InternalTexture>;
  18098. /**
  18099. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18100. * or used a shadow, depth texture...
  18101. * @param name The friendly name of the texture
  18102. * @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)
  18103. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18104. * @param generateMipMaps True if mip maps need to be generated after render.
  18105. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18106. * @param type The type of the buffer in the RTT (int, half float, float...)
  18107. * @param isCube True if a cube texture needs to be created
  18108. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18109. * @param generateDepthBuffer True to generate a depth buffer
  18110. * @param generateStencilBuffer True to generate a stencil buffer
  18111. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18112. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18113. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18114. */
  18115. constructor(name: string, size: number | {
  18116. width: number;
  18117. height: number;
  18118. } | {
  18119. ratio: number;
  18120. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18121. /**
  18122. * Creates a depth stencil texture.
  18123. * This is only available in WebGL 2 or with the depth texture extension available.
  18124. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18125. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18126. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18127. */
  18128. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18129. private _processSizeParameter;
  18130. /**
  18131. * Define the number of samples to use in case of MSAA.
  18132. * It defaults to one meaning no MSAA has been enabled.
  18133. */
  18134. samples: number;
  18135. /**
  18136. * Resets the refresh counter of the texture and start bak from scratch.
  18137. * Could be useful to regenerate the texture if it is setup to render only once.
  18138. */
  18139. resetRefreshCounter(): void;
  18140. /**
  18141. * Define the refresh rate of the texture or the rendering frequency.
  18142. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18143. */
  18144. refreshRate: number;
  18145. /**
  18146. * Adds a post process to the render target rendering passes.
  18147. * @param postProcess define the post process to add
  18148. */
  18149. addPostProcess(postProcess: PostProcess): void;
  18150. /**
  18151. * Clear all the post processes attached to the render target
  18152. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18153. */
  18154. clearPostProcesses(dispose?: boolean): void;
  18155. /**
  18156. * Remove one of the post process from the list of attached post processes to the texture
  18157. * @param postProcess define the post process to remove from the list
  18158. */
  18159. removePostProcess(postProcess: PostProcess): void;
  18160. /** @hidden */
  18161. _shouldRender(): boolean;
  18162. /**
  18163. * Gets the actual render size of the texture.
  18164. * @returns the width of the render size
  18165. */
  18166. getRenderSize(): number;
  18167. /**
  18168. * Gets the actual render width of the texture.
  18169. * @returns the width of the render size
  18170. */
  18171. getRenderWidth(): number;
  18172. /**
  18173. * Gets the actual render height of the texture.
  18174. * @returns the height of the render size
  18175. */
  18176. getRenderHeight(): number;
  18177. /**
  18178. * Get if the texture can be rescaled or not.
  18179. */
  18180. readonly canRescale: boolean;
  18181. /**
  18182. * Resize the texture using a ratio.
  18183. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18184. */
  18185. scale(ratio: number): void;
  18186. /**
  18187. * Get the texture reflection matrix used to rotate/transform the reflection.
  18188. * @returns the reflection matrix
  18189. */
  18190. getReflectionTextureMatrix(): Matrix;
  18191. /**
  18192. * Resize the texture to a new desired size.
  18193. * Be carrefull as it will recreate all the data in the new texture.
  18194. * @param size Define the new size. It can be:
  18195. * - a number for squared texture,
  18196. * - an object containing { width: number, height: number }
  18197. * - or an object containing a ratio { ratio: number }
  18198. */
  18199. resize(size: number | {
  18200. width: number;
  18201. height: number;
  18202. } | {
  18203. ratio: number;
  18204. }): void;
  18205. /**
  18206. * Renders all the objects from the render list into the texture.
  18207. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18208. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18209. */
  18210. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18211. private _bestReflectionRenderTargetDimension;
  18212. /**
  18213. * @hidden
  18214. * @param faceIndex face index to bind to if this is a cubetexture
  18215. */
  18216. _bindFrameBuffer(faceIndex?: number): void;
  18217. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18218. private renderToTarget;
  18219. /**
  18220. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18221. * This allowed control for front to back rendering or reversly depending of the special needs.
  18222. *
  18223. * @param renderingGroupId The rendering group id corresponding to its index
  18224. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18225. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18226. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18227. */
  18228. 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;
  18229. /**
  18230. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18231. *
  18232. * @param renderingGroupId The rendering group id corresponding to its index
  18233. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18234. */
  18235. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18236. /**
  18237. * Clones the texture.
  18238. * @returns the cloned texture
  18239. */
  18240. clone(): RenderTargetTexture;
  18241. /**
  18242. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18243. * @returns The JSON representation of the texture
  18244. */
  18245. serialize(): any;
  18246. /**
  18247. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18248. */
  18249. disposeFramebufferObjects(): void;
  18250. /**
  18251. * Dispose the texture and release its associated resources.
  18252. */
  18253. dispose(): void;
  18254. /** @hidden */
  18255. _rebuild(): void;
  18256. /**
  18257. * Clear the info related to rendering groups preventing retention point in material dispose.
  18258. */
  18259. freeRenderingGroups(): void;
  18260. /**
  18261. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18262. * @returns the view count
  18263. */
  18264. getViewCount(): number;
  18265. }
  18266. }
  18267. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18268. import { Scene } from "babylonjs/scene";
  18269. import { Plane } from "babylonjs/Maths/math";
  18270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18271. /**
  18272. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18273. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18274. * You can then easily use it as a reflectionTexture on a flat surface.
  18275. * In case the surface is not a plane, please consider relying on reflection probes.
  18276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18277. */
  18278. export class MirrorTexture extends RenderTargetTexture {
  18279. private scene;
  18280. /**
  18281. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18282. * 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.
  18283. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18284. */
  18285. mirrorPlane: Plane;
  18286. /**
  18287. * Define the blur ratio used to blur the reflection if needed.
  18288. */
  18289. blurRatio: number;
  18290. /**
  18291. * Define the adaptive blur kernel used to blur the reflection if needed.
  18292. * This will autocompute the closest best match for the `blurKernel`
  18293. */
  18294. adaptiveBlurKernel: number;
  18295. /**
  18296. * Define the blur kernel used to blur the reflection if needed.
  18297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18298. */
  18299. blurKernel: number;
  18300. /**
  18301. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18303. */
  18304. blurKernelX: number;
  18305. /**
  18306. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18307. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18308. */
  18309. blurKernelY: number;
  18310. private _autoComputeBlurKernel;
  18311. protected _onRatioRescale(): void;
  18312. private _updateGammaSpace;
  18313. private _imageProcessingConfigChangeObserver;
  18314. private _transformMatrix;
  18315. private _mirrorMatrix;
  18316. private _savedViewMatrix;
  18317. private _blurX;
  18318. private _blurY;
  18319. private _adaptiveBlurKernel;
  18320. private _blurKernelX;
  18321. private _blurKernelY;
  18322. private _blurRatio;
  18323. /**
  18324. * Instantiates a Mirror Texture.
  18325. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18326. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18327. * You can then easily use it as a reflectionTexture on a flat surface.
  18328. * In case the surface is not a plane, please consider relying on reflection probes.
  18329. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18330. * @param name
  18331. * @param size
  18332. * @param scene
  18333. * @param generateMipMaps
  18334. * @param type
  18335. * @param samplingMode
  18336. * @param generateDepthBuffer
  18337. */
  18338. constructor(name: string, size: number | {
  18339. width: number;
  18340. height: number;
  18341. } | {
  18342. ratio: number;
  18343. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18344. private _preparePostProcesses;
  18345. /**
  18346. * Clone the mirror texture.
  18347. * @returns the cloned texture
  18348. */
  18349. clone(): MirrorTexture;
  18350. /**
  18351. * Serialize the texture to a JSON representation you could use in Parse later on
  18352. * @returns the serialized JSON representation
  18353. */
  18354. serialize(): any;
  18355. /**
  18356. * Dispose the texture and release its associated resources.
  18357. */
  18358. dispose(): void;
  18359. }
  18360. }
  18361. declare module "babylonjs/Materials/Textures/texture" {
  18362. import { Observable } from "babylonjs/Misc/observable";
  18363. import { Nullable } from "babylonjs/types";
  18364. import { Scene } from "babylonjs/scene";
  18365. import { Matrix } from "babylonjs/Maths/math";
  18366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18367. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18368. /**
  18369. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18370. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18371. */
  18372. export class Texture extends BaseTexture {
  18373. /** @hidden */
  18374. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18375. /** @hidden */
  18376. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18377. /** @hidden */
  18378. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18379. /** nearest is mag = nearest and min = nearest and mip = linear */
  18380. static readonly NEAREST_SAMPLINGMODE: number;
  18381. /** nearest is mag = nearest and min = nearest and mip = linear */
  18382. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18384. static readonly BILINEAR_SAMPLINGMODE: number;
  18385. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18386. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18387. /** Trilinear is mag = linear and min = linear and mip = linear */
  18388. static readonly TRILINEAR_SAMPLINGMODE: number;
  18389. /** Trilinear is mag = linear and min = linear and mip = linear */
  18390. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18391. /** mag = nearest and min = nearest and mip = nearest */
  18392. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18393. /** mag = nearest and min = linear and mip = nearest */
  18394. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18395. /** mag = nearest and min = linear and mip = linear */
  18396. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18397. /** mag = nearest and min = linear and mip = none */
  18398. static readonly NEAREST_LINEAR: number;
  18399. /** mag = nearest and min = nearest and mip = none */
  18400. static readonly NEAREST_NEAREST: number;
  18401. /** mag = linear and min = nearest and mip = nearest */
  18402. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18403. /** mag = linear and min = nearest and mip = linear */
  18404. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18405. /** mag = linear and min = linear and mip = none */
  18406. static readonly LINEAR_LINEAR: number;
  18407. /** mag = linear and min = nearest and mip = none */
  18408. static readonly LINEAR_NEAREST: number;
  18409. /** Explicit coordinates mode */
  18410. static readonly EXPLICIT_MODE: number;
  18411. /** Spherical coordinates mode */
  18412. static readonly SPHERICAL_MODE: number;
  18413. /** Planar coordinates mode */
  18414. static readonly PLANAR_MODE: number;
  18415. /** Cubic coordinates mode */
  18416. static readonly CUBIC_MODE: number;
  18417. /** Projection coordinates mode */
  18418. static readonly PROJECTION_MODE: number;
  18419. /** Inverse Cubic coordinates mode */
  18420. static readonly SKYBOX_MODE: number;
  18421. /** Inverse Cubic coordinates mode */
  18422. static readonly INVCUBIC_MODE: number;
  18423. /** Equirectangular coordinates mode */
  18424. static readonly EQUIRECTANGULAR_MODE: number;
  18425. /** Equirectangular Fixed coordinates mode */
  18426. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18427. /** Equirectangular Fixed Mirrored coordinates mode */
  18428. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18429. /** Texture is not repeating outside of 0..1 UVs */
  18430. static readonly CLAMP_ADDRESSMODE: number;
  18431. /** Texture is repeating outside of 0..1 UVs */
  18432. static readonly WRAP_ADDRESSMODE: number;
  18433. /** Texture is repeating and mirrored */
  18434. static readonly MIRROR_ADDRESSMODE: number;
  18435. /**
  18436. * 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
  18437. */
  18438. static UseSerializedUrlIfAny: boolean;
  18439. /**
  18440. * Define the url of the texture.
  18441. */
  18442. url: Nullable<string>;
  18443. /**
  18444. * Define an offset on the texture to offset the u coordinates of the UVs
  18445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18446. */
  18447. uOffset: number;
  18448. /**
  18449. * Define an offset on the texture to offset the v coordinates of the UVs
  18450. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18451. */
  18452. vOffset: number;
  18453. /**
  18454. * Define an offset on the texture to scale the u coordinates of the UVs
  18455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18456. */
  18457. uScale: number;
  18458. /**
  18459. * Define an offset on the texture to scale the v coordinates of the UVs
  18460. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18461. */
  18462. vScale: number;
  18463. /**
  18464. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18465. * @see http://doc.babylonjs.com/how_to/more_materials
  18466. */
  18467. uAng: number;
  18468. /**
  18469. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18470. * @see http://doc.babylonjs.com/how_to/more_materials
  18471. */
  18472. vAng: number;
  18473. /**
  18474. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18475. * @see http://doc.babylonjs.com/how_to/more_materials
  18476. */
  18477. wAng: number;
  18478. /**
  18479. * Defines the center of rotation (U)
  18480. */
  18481. uRotationCenter: number;
  18482. /**
  18483. * Defines the center of rotation (V)
  18484. */
  18485. vRotationCenter: number;
  18486. /**
  18487. * Defines the center of rotation (W)
  18488. */
  18489. wRotationCenter: number;
  18490. /**
  18491. * Are mip maps generated for this texture or not.
  18492. */
  18493. readonly noMipmap: boolean;
  18494. /**
  18495. * List of inspectable custom properties (used by the Inspector)
  18496. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18497. */
  18498. inspectableCustomProperties: IInspectable[];
  18499. private _noMipmap;
  18500. /** @hidden */
  18501. _invertY: boolean;
  18502. private _rowGenerationMatrix;
  18503. private _cachedTextureMatrix;
  18504. private _projectionModeMatrix;
  18505. private _t0;
  18506. private _t1;
  18507. private _t2;
  18508. private _cachedUOffset;
  18509. private _cachedVOffset;
  18510. private _cachedUScale;
  18511. private _cachedVScale;
  18512. private _cachedUAng;
  18513. private _cachedVAng;
  18514. private _cachedWAng;
  18515. private _cachedProjectionMatrixId;
  18516. private _cachedCoordinatesMode;
  18517. /** @hidden */
  18518. protected _initialSamplingMode: number;
  18519. /** @hidden */
  18520. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18521. private _deleteBuffer;
  18522. protected _format: Nullable<number>;
  18523. private _delayedOnLoad;
  18524. private _delayedOnError;
  18525. /**
  18526. * Observable triggered once the texture has been loaded.
  18527. */
  18528. onLoadObservable: Observable<Texture>;
  18529. protected _isBlocking: boolean;
  18530. /**
  18531. * Is the texture preventing material to render while loading.
  18532. * If false, a default texture will be used instead of the loading one during the preparation step.
  18533. */
  18534. isBlocking: boolean;
  18535. /**
  18536. * Get the current sampling mode associated with the texture.
  18537. */
  18538. readonly samplingMode: number;
  18539. /**
  18540. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18541. */
  18542. readonly invertY: boolean;
  18543. /**
  18544. * Instantiates a new texture.
  18545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18547. * @param url define the url of the picture to load as a texture
  18548. * @param scene define the scene the texture will belong to
  18549. * @param noMipmap define if the texture will require mip maps or not
  18550. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18551. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18552. * @param onLoad define a callback triggered when the texture has been loaded
  18553. * @param onError define a callback triggered when an error occurred during the loading session
  18554. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18555. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18556. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18557. */
  18558. 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);
  18559. /**
  18560. * Update the url (and optional buffer) of this texture if url was null during construction.
  18561. * @param url the url of the texture
  18562. * @param buffer the buffer of the texture (defaults to null)
  18563. * @param onLoad callback called when the texture is loaded (defaults to null)
  18564. */
  18565. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18566. /**
  18567. * Finish the loading sequence of a texture flagged as delayed load.
  18568. * @hidden
  18569. */
  18570. delayLoad(): void;
  18571. private _prepareRowForTextureGeneration;
  18572. /**
  18573. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18574. * @returns the transform matrix of the texture.
  18575. */
  18576. getTextureMatrix(): Matrix;
  18577. /**
  18578. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18579. * @returns The reflection texture transform
  18580. */
  18581. getReflectionTextureMatrix(): Matrix;
  18582. /**
  18583. * Clones the texture.
  18584. * @returns the cloned texture
  18585. */
  18586. clone(): Texture;
  18587. /**
  18588. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18589. * @returns The JSON representation of the texture
  18590. */
  18591. serialize(): any;
  18592. /**
  18593. * Get the current class name of the texture useful for serialization or dynamic coding.
  18594. * @returns "Texture"
  18595. */
  18596. getClassName(): string;
  18597. /**
  18598. * Dispose the texture and release its associated resources.
  18599. */
  18600. dispose(): void;
  18601. /**
  18602. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18603. * @param parsedTexture Define the JSON representation of the texture
  18604. * @param scene Define the scene the parsed texture should be instantiated in
  18605. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18606. * @returns The parsed texture if successful
  18607. */
  18608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18609. /**
  18610. * Creates a texture from its base 64 representation.
  18611. * @param data Define the base64 payload without the data: prefix
  18612. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18613. * @param scene Define the scene the texture should belong to
  18614. * @param noMipmap Forces the texture to not create mip map information if true
  18615. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18616. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18617. * @param onLoad define a callback triggered when the texture has been loaded
  18618. * @param onError define a callback triggered when an error occurred during the loading session
  18619. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18620. * @returns the created texture
  18621. */
  18622. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18623. /**
  18624. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18625. * @param data Define the base64 payload without the data: prefix
  18626. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18627. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18628. * @param scene Define the scene the texture should belong to
  18629. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18630. * @param noMipmap Forces the texture to not create mip map information if true
  18631. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18632. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18633. * @param onLoad define a callback triggered when the texture has been loaded
  18634. * @param onError define a callback triggered when an error occurred during the loading session
  18635. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18636. * @returns the created texture
  18637. */
  18638. 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;
  18639. }
  18640. }
  18641. declare module "babylonjs/Materials/Textures/rawTexture" {
  18642. import { Scene } from "babylonjs/scene";
  18643. import { Texture } from "babylonjs/Materials/Textures/texture";
  18644. /**
  18645. * Raw texture can help creating a texture directly from an array of data.
  18646. * This can be super useful if you either get the data from an uncompressed source or
  18647. * if you wish to create your texture pixel by pixel.
  18648. */
  18649. export class RawTexture extends Texture {
  18650. /**
  18651. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18652. */
  18653. format: number;
  18654. private _engine;
  18655. /**
  18656. * Instantiates a new RawTexture.
  18657. * Raw texture can help creating a texture directly from an array of data.
  18658. * This can be super useful if you either get the data from an uncompressed source or
  18659. * if you wish to create your texture pixel by pixel.
  18660. * @param data define the array of data to use to create the texture
  18661. * @param width define the width of the texture
  18662. * @param height define the height of the texture
  18663. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18664. * @param scene define the scene the texture belongs to
  18665. * @param generateMipMaps define whether mip maps should be generated or not
  18666. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18667. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18668. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18669. */
  18670. constructor(data: ArrayBufferView, width: number, height: number,
  18671. /**
  18672. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18673. */
  18674. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18675. /**
  18676. * Updates the texture underlying data.
  18677. * @param data Define the new data of the texture
  18678. */
  18679. update(data: ArrayBufferView): void;
  18680. /**
  18681. * Creates a luminance texture from some data.
  18682. * @param data Define the texture data
  18683. * @param width Define the width of the texture
  18684. * @param height Define the height of the texture
  18685. * @param scene Define the scene the texture belongs to
  18686. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18687. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18688. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18689. * @returns the luminance texture
  18690. */
  18691. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18692. /**
  18693. * Creates a luminance alpha texture from some data.
  18694. * @param data Define the texture data
  18695. * @param width Define the width of the texture
  18696. * @param height Define the height of the texture
  18697. * @param scene Define the scene the texture belongs to
  18698. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18699. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18700. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18701. * @returns the luminance alpha texture
  18702. */
  18703. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18704. /**
  18705. * Creates an alpha texture from some data.
  18706. * @param data Define the texture data
  18707. * @param width Define the width of the texture
  18708. * @param height Define the height of the texture
  18709. * @param scene Define the scene the texture belongs to
  18710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18713. * @returns the alpha texture
  18714. */
  18715. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18716. /**
  18717. * Creates a RGB texture from some data.
  18718. * @param data Define the texture data
  18719. * @param width Define the width of the texture
  18720. * @param height Define the height of the texture
  18721. * @param scene Define the scene the texture belongs to
  18722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18726. * @returns the RGB alpha texture
  18727. */
  18728. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18729. /**
  18730. * Creates a RGBA texture from some data.
  18731. * @param data Define the texture data
  18732. * @param width Define the width of the texture
  18733. * @param height Define the height of the texture
  18734. * @param scene Define the scene the texture belongs to
  18735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18739. * @returns the RGBA texture
  18740. */
  18741. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18742. /**
  18743. * Creates a R texture from some data.
  18744. * @param data Define the texture data
  18745. * @param width Define the width of the texture
  18746. * @param height Define the height of the texture
  18747. * @param scene Define the scene the texture belongs to
  18748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18752. * @returns the R texture
  18753. */
  18754. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18755. }
  18756. }
  18757. declare module "babylonjs/Animations/runtimeAnimation" {
  18758. import { Animation } from "babylonjs/Animations/animation";
  18759. import { Animatable } from "babylonjs/Animations/animatable";
  18760. import { Scene } from "babylonjs/scene";
  18761. /**
  18762. * Defines a runtime animation
  18763. */
  18764. export class RuntimeAnimation {
  18765. private _events;
  18766. /**
  18767. * The current frame of the runtime animation
  18768. */
  18769. private _currentFrame;
  18770. /**
  18771. * The animation used by the runtime animation
  18772. */
  18773. private _animation;
  18774. /**
  18775. * The target of the runtime animation
  18776. */
  18777. private _target;
  18778. /**
  18779. * The initiating animatable
  18780. */
  18781. private _host;
  18782. /**
  18783. * The original value of the runtime animation
  18784. */
  18785. private _originalValue;
  18786. /**
  18787. * The original blend value of the runtime animation
  18788. */
  18789. private _originalBlendValue;
  18790. /**
  18791. * The offsets cache of the runtime animation
  18792. */
  18793. private _offsetsCache;
  18794. /**
  18795. * The high limits cache of the runtime animation
  18796. */
  18797. private _highLimitsCache;
  18798. /**
  18799. * Specifies if the runtime animation has been stopped
  18800. */
  18801. private _stopped;
  18802. /**
  18803. * The blending factor of the runtime animation
  18804. */
  18805. private _blendingFactor;
  18806. /**
  18807. * The BabylonJS scene
  18808. */
  18809. private _scene;
  18810. /**
  18811. * The current value of the runtime animation
  18812. */
  18813. private _currentValue;
  18814. /** @hidden */
  18815. _workValue: any;
  18816. /**
  18817. * The active target of the runtime animation
  18818. */
  18819. private _activeTarget;
  18820. /**
  18821. * The target path of the runtime animation
  18822. */
  18823. private _targetPath;
  18824. /**
  18825. * The weight of the runtime animation
  18826. */
  18827. private _weight;
  18828. /**
  18829. * The ratio offset of the runtime animation
  18830. */
  18831. private _ratioOffset;
  18832. /**
  18833. * The previous delay of the runtime animation
  18834. */
  18835. private _previousDelay;
  18836. /**
  18837. * The previous ratio of the runtime animation
  18838. */
  18839. private _previousRatio;
  18840. /**
  18841. * Gets the current frame of the runtime animation
  18842. */
  18843. readonly currentFrame: number;
  18844. /**
  18845. * Gets the weight of the runtime animation
  18846. */
  18847. readonly weight: number;
  18848. /**
  18849. * Gets the current value of the runtime animation
  18850. */
  18851. readonly currentValue: any;
  18852. /**
  18853. * Gets the target path of the runtime animation
  18854. */
  18855. readonly targetPath: string;
  18856. /**
  18857. * Gets the actual target of the runtime animation
  18858. */
  18859. readonly target: any;
  18860. /**
  18861. * Create a new RuntimeAnimation object
  18862. * @param target defines the target of the animation
  18863. * @param animation defines the source animation object
  18864. * @param scene defines the hosting scene
  18865. * @param host defines the initiating Animatable
  18866. */
  18867. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18868. /**
  18869. * Gets the animation from the runtime animation
  18870. */
  18871. readonly animation: Animation;
  18872. /**
  18873. * Resets the runtime animation to the beginning
  18874. * @param restoreOriginal defines whether to restore the target property to the original value
  18875. */
  18876. reset(restoreOriginal?: boolean): void;
  18877. /**
  18878. * Specifies if the runtime animation is stopped
  18879. * @returns Boolean specifying if the runtime animation is stopped
  18880. */
  18881. isStopped(): boolean;
  18882. /**
  18883. * Disposes of the runtime animation
  18884. */
  18885. dispose(): void;
  18886. /**
  18887. * Interpolates the animation from the current frame
  18888. * @param currentFrame The frame to interpolate the animation to
  18889. * @param repeatCount The number of times that the animation should loop
  18890. * @param loopMode The type of looping mode to use
  18891. * @param offsetValue Animation offset value
  18892. * @param highLimitValue The high limit value
  18893. * @returns The interpolated value
  18894. */
  18895. private _interpolate;
  18896. /**
  18897. * Apply the interpolated value to the target
  18898. * @param currentValue defines the value computed by the animation
  18899. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18900. */
  18901. setValue(currentValue: any, weight?: number): void;
  18902. private _setValue;
  18903. /**
  18904. * Gets the loop pmode of the runtime animation
  18905. * @returns Loop Mode
  18906. */
  18907. private _getCorrectLoopMode;
  18908. /**
  18909. * Move the current animation to a given frame
  18910. * @param frame defines the frame to move to
  18911. */
  18912. goToFrame(frame: number): void;
  18913. /**
  18914. * @hidden Internal use only
  18915. */
  18916. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18917. /**
  18918. * Execute the current animation
  18919. * @param delay defines the delay to add to the current frame
  18920. * @param from defines the lower bound of the animation range
  18921. * @param to defines the upper bound of the animation range
  18922. * @param loop defines if the current animation must loop
  18923. * @param speedRatio defines the current speed ratio
  18924. * @param weight defines the weight of the animation (default is -1 so no weight)
  18925. * @param onLoop optional callback called when animation loops
  18926. * @returns a boolean indicating if the animation is running
  18927. */
  18928. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18929. }
  18930. }
  18931. declare module "babylonjs/Animations/animatable" {
  18932. import { Animation } from "babylonjs/Animations/animation";
  18933. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18934. import { Nullable } from "babylonjs/types";
  18935. import { Observable } from "babylonjs/Misc/observable";
  18936. import { Scene } from "babylonjs/scene";
  18937. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18938. import { Node } from "babylonjs/node";
  18939. /**
  18940. * Class used to store an actual running animation
  18941. */
  18942. export class Animatable {
  18943. /** defines the target object */
  18944. target: any;
  18945. /** defines the starting frame number (default is 0) */
  18946. fromFrame: number;
  18947. /** defines the ending frame number (default is 100) */
  18948. toFrame: number;
  18949. /** defines if the animation must loop (default is false) */
  18950. loopAnimation: boolean;
  18951. /** defines a callback to call when animation ends if it is not looping */
  18952. onAnimationEnd?: (() => void) | null | undefined;
  18953. /** defines a callback to call when animation loops */
  18954. onAnimationLoop?: (() => void) | null | undefined;
  18955. private _localDelayOffset;
  18956. private _pausedDelay;
  18957. private _runtimeAnimations;
  18958. private _paused;
  18959. private _scene;
  18960. private _speedRatio;
  18961. private _weight;
  18962. private _syncRoot;
  18963. /**
  18964. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18965. * This will only apply for non looping animation (default is true)
  18966. */
  18967. disposeOnEnd: boolean;
  18968. /**
  18969. * Gets a boolean indicating if the animation has started
  18970. */
  18971. animationStarted: boolean;
  18972. /**
  18973. * Observer raised when the animation ends
  18974. */
  18975. onAnimationEndObservable: Observable<Animatable>;
  18976. /**
  18977. * Observer raised when the animation loops
  18978. */
  18979. onAnimationLoopObservable: Observable<Animatable>;
  18980. /**
  18981. * Gets the root Animatable used to synchronize and normalize animations
  18982. */
  18983. readonly syncRoot: Animatable;
  18984. /**
  18985. * Gets the current frame of the first RuntimeAnimation
  18986. * Used to synchronize Animatables
  18987. */
  18988. readonly masterFrame: number;
  18989. /**
  18990. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18991. */
  18992. weight: number;
  18993. /**
  18994. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18995. */
  18996. speedRatio: number;
  18997. /**
  18998. * Creates a new Animatable
  18999. * @param scene defines the hosting scene
  19000. * @param target defines the target object
  19001. * @param fromFrame defines the starting frame number (default is 0)
  19002. * @param toFrame defines the ending frame number (default is 100)
  19003. * @param loopAnimation defines if the animation must loop (default is false)
  19004. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19005. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19006. * @param animations defines a group of animation to add to the new Animatable
  19007. * @param onAnimationLoop defines a callback to call when animation loops
  19008. */
  19009. constructor(scene: Scene,
  19010. /** defines the target object */
  19011. target: any,
  19012. /** defines the starting frame number (default is 0) */
  19013. fromFrame?: number,
  19014. /** defines the ending frame number (default is 100) */
  19015. toFrame?: number,
  19016. /** defines if the animation must loop (default is false) */
  19017. loopAnimation?: boolean, speedRatio?: number,
  19018. /** defines a callback to call when animation ends if it is not looping */
  19019. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19020. /** defines a callback to call when animation loops */
  19021. onAnimationLoop?: (() => void) | null | undefined);
  19022. /**
  19023. * Synchronize and normalize current Animatable with a source Animatable
  19024. * This is useful when using animation weights and when animations are not of the same length
  19025. * @param root defines the root Animatable to synchronize with
  19026. * @returns the current Animatable
  19027. */
  19028. syncWith(root: Animatable): Animatable;
  19029. /**
  19030. * Gets the list of runtime animations
  19031. * @returns an array of RuntimeAnimation
  19032. */
  19033. getAnimations(): RuntimeAnimation[];
  19034. /**
  19035. * Adds more animations to the current animatable
  19036. * @param target defines the target of the animations
  19037. * @param animations defines the new animations to add
  19038. */
  19039. appendAnimations(target: any, animations: Animation[]): void;
  19040. /**
  19041. * Gets the source animation for a specific property
  19042. * @param property defines the propertyu to look for
  19043. * @returns null or the source animation for the given property
  19044. */
  19045. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19046. /**
  19047. * Gets the runtime animation for a specific property
  19048. * @param property defines the propertyu to look for
  19049. * @returns null or the runtime animation for the given property
  19050. */
  19051. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19052. /**
  19053. * Resets the animatable to its original state
  19054. */
  19055. reset(): void;
  19056. /**
  19057. * Allows the animatable to blend with current running animations
  19058. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19059. * @param blendingSpeed defines the blending speed to use
  19060. */
  19061. enableBlending(blendingSpeed: number): void;
  19062. /**
  19063. * Disable animation blending
  19064. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19065. */
  19066. disableBlending(): void;
  19067. /**
  19068. * Jump directly to a given frame
  19069. * @param frame defines the frame to jump to
  19070. */
  19071. goToFrame(frame: number): void;
  19072. /**
  19073. * Pause the animation
  19074. */
  19075. pause(): void;
  19076. /**
  19077. * Restart the animation
  19078. */
  19079. restart(): void;
  19080. private _raiseOnAnimationEnd;
  19081. /**
  19082. * Stop and delete the current animation
  19083. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19084. * @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)
  19085. */
  19086. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19087. /**
  19088. * Wait asynchronously for the animation to end
  19089. * @returns a promise which will be fullfilled when the animation ends
  19090. */
  19091. waitAsync(): Promise<Animatable>;
  19092. /** @hidden */
  19093. _animate(delay: number): boolean;
  19094. }
  19095. module "babylonjs/scene" {
  19096. interface Scene {
  19097. /** @hidden */
  19098. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19099. /** @hidden */
  19100. _processLateAnimationBindingsForMatrices(holder: {
  19101. totalWeight: number;
  19102. animations: RuntimeAnimation[];
  19103. originalValue: Matrix;
  19104. }): any;
  19105. /** @hidden */
  19106. _processLateAnimationBindingsForQuaternions(holder: {
  19107. totalWeight: number;
  19108. animations: RuntimeAnimation[];
  19109. originalValue: Quaternion;
  19110. }, refQuaternion: Quaternion): Quaternion;
  19111. /** @hidden */
  19112. _processLateAnimationBindings(): void;
  19113. /**
  19114. * Will start the animation sequence of a given target
  19115. * @param target defines the target
  19116. * @param from defines from which frame should animation start
  19117. * @param to defines until which frame should animation run.
  19118. * @param weight defines the weight to apply to the animation (1.0 by default)
  19119. * @param loop defines if the animation loops
  19120. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19121. * @param onAnimationEnd defines the function to be executed when the animation ends
  19122. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19123. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19124. * @param onAnimationLoop defines the callback to call when an animation loops
  19125. * @returns the animatable object created for this animation
  19126. */
  19127. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19128. /**
  19129. * Will start the animation sequence of a given target
  19130. * @param target defines the target
  19131. * @param from defines from which frame should animation start
  19132. * @param to defines until which frame should animation run.
  19133. * @param loop defines if the animation loops
  19134. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19135. * @param onAnimationEnd defines the function to be executed when the animation ends
  19136. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19137. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19138. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19139. * @param onAnimationLoop defines the callback to call when an animation loops
  19140. * @returns the animatable object created for this animation
  19141. */
  19142. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19143. /**
  19144. * Will start the animation sequence of a given target and its hierarchy
  19145. * @param target defines the target
  19146. * @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.
  19147. * @param from defines from which frame should animation start
  19148. * @param to defines until which frame should animation run.
  19149. * @param loop defines if the animation loops
  19150. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19151. * @param onAnimationEnd defines the function to be executed when the animation ends
  19152. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19153. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19154. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19155. * @param onAnimationLoop defines the callback to call when an animation loops
  19156. * @returns the list of created animatables
  19157. */
  19158. 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[];
  19159. /**
  19160. * Begin a new animation on a given node
  19161. * @param target defines the target where the animation will take place
  19162. * @param animations defines the list of animations to start
  19163. * @param from defines the initial value
  19164. * @param to defines the final value
  19165. * @param loop defines if you want animation to loop (off by default)
  19166. * @param speedRatio defines the speed ratio to apply to all animations
  19167. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19168. * @param onAnimationLoop defines the callback to call when an animation loops
  19169. * @returns the list of created animatables
  19170. */
  19171. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19172. /**
  19173. * Begin a new animation on a given node and its hierarchy
  19174. * @param target defines the root node where the animation will take place
  19175. * @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.
  19176. * @param animations defines the list of animations to start
  19177. * @param from defines the initial value
  19178. * @param to defines the final value
  19179. * @param loop defines if you want animation to loop (off by default)
  19180. * @param speedRatio defines the speed ratio to apply to all animations
  19181. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19182. * @param onAnimationLoop defines the callback to call when an animation loops
  19183. * @returns the list of animatables created for all nodes
  19184. */
  19185. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19186. /**
  19187. * Gets the animatable associated with a specific target
  19188. * @param target defines the target of the animatable
  19189. * @returns the required animatable if found
  19190. */
  19191. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19192. /**
  19193. * Gets all animatables associated with a given target
  19194. * @param target defines the target to look animatables for
  19195. * @returns an array of Animatables
  19196. */
  19197. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19198. /**
  19199. * Will stop the animation of the given target
  19200. * @param target - the target
  19201. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19202. * @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)
  19203. */
  19204. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19205. /**
  19206. * Stops and removes all animations that have been applied to the scene
  19207. */
  19208. stopAllAnimations(): void;
  19209. }
  19210. }
  19211. module "babylonjs/Bones/bone" {
  19212. interface Bone {
  19213. /**
  19214. * Copy an animation range from another bone
  19215. * @param source defines the source bone
  19216. * @param rangeName defines the range name to copy
  19217. * @param frameOffset defines the frame offset
  19218. * @param rescaleAsRequired defines if rescaling must be applied if required
  19219. * @param skelDimensionsRatio defines the scaling ratio
  19220. * @returns true if operation was successful
  19221. */
  19222. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19223. }
  19224. }
  19225. }
  19226. declare module "babylonjs/Bones/skeleton" {
  19227. import { Bone } from "babylonjs/Bones/bone";
  19228. import { IAnimatable } from "babylonjs/Misc/tools";
  19229. import { Observable } from "babylonjs/Misc/observable";
  19230. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19231. import { Scene } from "babylonjs/scene";
  19232. import { Nullable } from "babylonjs/types";
  19233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19234. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19235. import { Animatable } from "babylonjs/Animations/animatable";
  19236. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19237. import { Animation } from "babylonjs/Animations/animation";
  19238. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19239. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19240. /**
  19241. * Class used to handle skinning animations
  19242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19243. */
  19244. export class Skeleton implements IAnimatable {
  19245. /** defines the skeleton name */
  19246. name: string;
  19247. /** defines the skeleton Id */
  19248. id: string;
  19249. /**
  19250. * Defines the list of child bones
  19251. */
  19252. bones: Bone[];
  19253. /**
  19254. * Defines an estimate of the dimension of the skeleton at rest
  19255. */
  19256. dimensionsAtRest: Vector3;
  19257. /**
  19258. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19259. */
  19260. needInitialSkinMatrix: boolean;
  19261. /**
  19262. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19263. */
  19264. overrideMesh: Nullable<AbstractMesh>;
  19265. /**
  19266. * Gets the list of animations attached to this skeleton
  19267. */
  19268. animations: Array<Animation>;
  19269. private _scene;
  19270. private _isDirty;
  19271. private _transformMatrices;
  19272. private _transformMatrixTexture;
  19273. private _meshesWithPoseMatrix;
  19274. private _animatables;
  19275. private _identity;
  19276. private _synchronizedWithMesh;
  19277. private _ranges;
  19278. private _lastAbsoluteTransformsUpdateId;
  19279. private _canUseTextureForBones;
  19280. private _uniqueId;
  19281. /** @hidden */
  19282. _numBonesWithLinkedTransformNode: number;
  19283. /**
  19284. * Specifies if the skeleton should be serialized
  19285. */
  19286. doNotSerialize: boolean;
  19287. private _useTextureToStoreBoneMatrices;
  19288. /**
  19289. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19290. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19291. */
  19292. useTextureToStoreBoneMatrices: boolean;
  19293. private _animationPropertiesOverride;
  19294. /**
  19295. * Gets or sets the animation properties override
  19296. */
  19297. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19298. /**
  19299. * List of inspectable custom properties (used by the Inspector)
  19300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19301. */
  19302. inspectableCustomProperties: IInspectable[];
  19303. /**
  19304. * An observable triggered before computing the skeleton's matrices
  19305. */
  19306. onBeforeComputeObservable: Observable<Skeleton>;
  19307. /**
  19308. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19309. */
  19310. readonly isUsingTextureForMatrices: boolean;
  19311. /**
  19312. * Gets the unique ID of this skeleton
  19313. */
  19314. readonly uniqueId: number;
  19315. /**
  19316. * Creates a new skeleton
  19317. * @param name defines the skeleton name
  19318. * @param id defines the skeleton Id
  19319. * @param scene defines the hosting scene
  19320. */
  19321. constructor(
  19322. /** defines the skeleton name */
  19323. name: string,
  19324. /** defines the skeleton Id */
  19325. id: string, scene: Scene);
  19326. /**
  19327. * Gets the current object class name.
  19328. * @return the class name
  19329. */
  19330. getClassName(): string;
  19331. /**
  19332. * Returns an array containing the root bones
  19333. * @returns an array containing the root bones
  19334. */
  19335. getChildren(): Array<Bone>;
  19336. /**
  19337. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19338. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19339. * @returns a Float32Array containing matrices data
  19340. */
  19341. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19342. /**
  19343. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19344. * @returns a raw texture containing the data
  19345. */
  19346. getTransformMatrixTexture(): Nullable<RawTexture>;
  19347. /**
  19348. * Gets the current hosting scene
  19349. * @returns a scene object
  19350. */
  19351. getScene(): Scene;
  19352. /**
  19353. * Gets a string representing the current skeleton data
  19354. * @param fullDetails defines a boolean indicating if we want a verbose version
  19355. * @returns a string representing the current skeleton data
  19356. */
  19357. toString(fullDetails?: boolean): string;
  19358. /**
  19359. * Get bone's index searching by name
  19360. * @param name defines bone's name to search for
  19361. * @return the indice of the bone. Returns -1 if not found
  19362. */
  19363. getBoneIndexByName(name: string): number;
  19364. /**
  19365. * Creater a new animation range
  19366. * @param name defines the name of the range
  19367. * @param from defines the start key
  19368. * @param to defines the end key
  19369. */
  19370. createAnimationRange(name: string, from: number, to: number): void;
  19371. /**
  19372. * Delete a specific animation range
  19373. * @param name defines the name of the range
  19374. * @param deleteFrames defines if frames must be removed as well
  19375. */
  19376. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19377. /**
  19378. * Gets a specific animation range
  19379. * @param name defines the name of the range to look for
  19380. * @returns the requested animation range or null if not found
  19381. */
  19382. getAnimationRange(name: string): Nullable<AnimationRange>;
  19383. /**
  19384. * Gets the list of all animation ranges defined on this skeleton
  19385. * @returns an array
  19386. */
  19387. getAnimationRanges(): Nullable<AnimationRange>[];
  19388. /**
  19389. * Copy animation range from a source skeleton.
  19390. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19391. * @param source defines the source skeleton
  19392. * @param name defines the name of the range to copy
  19393. * @param rescaleAsRequired defines if rescaling must be applied if required
  19394. * @returns true if operation was successful
  19395. */
  19396. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19397. /**
  19398. * Forces the skeleton to go to rest pose
  19399. */
  19400. returnToRest(): void;
  19401. private _getHighestAnimationFrame;
  19402. /**
  19403. * Begin a specific animation range
  19404. * @param name defines the name of the range to start
  19405. * @param loop defines if looping must be turned on (false by default)
  19406. * @param speedRatio defines the speed ratio to apply (1 by default)
  19407. * @param onAnimationEnd defines a callback which will be called when animation will end
  19408. * @returns a new animatable
  19409. */
  19410. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19411. /** @hidden */
  19412. _markAsDirty(): void;
  19413. /** @hidden */
  19414. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19415. /** @hidden */
  19416. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19417. private _computeTransformMatrices;
  19418. /**
  19419. * Build all resources required to render a skeleton
  19420. */
  19421. prepare(): void;
  19422. /**
  19423. * Gets the list of animatables currently running for this skeleton
  19424. * @returns an array of animatables
  19425. */
  19426. getAnimatables(): IAnimatable[];
  19427. /**
  19428. * Clone the current skeleton
  19429. * @param name defines the name of the new skeleton
  19430. * @param id defines the id of the enw skeleton
  19431. * @returns the new skeleton
  19432. */
  19433. clone(name: string, id: string): Skeleton;
  19434. /**
  19435. * Enable animation blending for this skeleton
  19436. * @param blendingSpeed defines the blending speed to apply
  19437. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19438. */
  19439. enableBlending(blendingSpeed?: number): void;
  19440. /**
  19441. * Releases all resources associated with the current skeleton
  19442. */
  19443. dispose(): void;
  19444. /**
  19445. * Serialize the skeleton in a JSON object
  19446. * @returns a JSON object
  19447. */
  19448. serialize(): any;
  19449. /**
  19450. * Creates a new skeleton from serialized data
  19451. * @param parsedSkeleton defines the serialized data
  19452. * @param scene defines the hosting scene
  19453. * @returns a new skeleton
  19454. */
  19455. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19456. /**
  19457. * Compute all node absolute transforms
  19458. * @param forceUpdate defines if computation must be done even if cache is up to date
  19459. */
  19460. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19461. /**
  19462. * Gets the root pose matrix
  19463. * @returns a matrix
  19464. */
  19465. getPoseMatrix(): Nullable<Matrix>;
  19466. /**
  19467. * Sorts bones per internal index
  19468. */
  19469. sortBones(): void;
  19470. private _sortBones;
  19471. }
  19472. }
  19473. declare module "babylonjs/Morph/morphTarget" {
  19474. import { IAnimatable } from "babylonjs/Misc/tools";
  19475. import { Observable } from "babylonjs/Misc/observable";
  19476. import { Nullable, FloatArray } from "babylonjs/types";
  19477. import { Scene } from "babylonjs/scene";
  19478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19479. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19480. /**
  19481. * Defines a target to use with MorphTargetManager
  19482. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19483. */
  19484. export class MorphTarget implements IAnimatable {
  19485. /** defines the name of the target */
  19486. name: string;
  19487. /**
  19488. * Gets or sets the list of animations
  19489. */
  19490. animations: import("babylonjs/Animations/animation").Animation[];
  19491. private _scene;
  19492. private _positions;
  19493. private _normals;
  19494. private _tangents;
  19495. private _influence;
  19496. /**
  19497. * Observable raised when the influence changes
  19498. */
  19499. onInfluenceChanged: Observable<boolean>;
  19500. /** @hidden */
  19501. _onDataLayoutChanged: Observable<void>;
  19502. /**
  19503. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19504. */
  19505. influence: number;
  19506. /**
  19507. * Gets or sets the id of the morph Target
  19508. */
  19509. id: string;
  19510. private _animationPropertiesOverride;
  19511. /**
  19512. * Gets or sets the animation properties override
  19513. */
  19514. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19515. /**
  19516. * Creates a new MorphTarget
  19517. * @param name defines the name of the target
  19518. * @param influence defines the influence to use
  19519. * @param scene defines the scene the morphtarget belongs to
  19520. */
  19521. constructor(
  19522. /** defines the name of the target */
  19523. name: string, influence?: number, scene?: Nullable<Scene>);
  19524. /**
  19525. * Gets a boolean defining if the target contains position data
  19526. */
  19527. readonly hasPositions: boolean;
  19528. /**
  19529. * Gets a boolean defining if the target contains normal data
  19530. */
  19531. readonly hasNormals: boolean;
  19532. /**
  19533. * Gets a boolean defining if the target contains tangent data
  19534. */
  19535. readonly hasTangents: boolean;
  19536. /**
  19537. * Affects position data to this target
  19538. * @param data defines the position data to use
  19539. */
  19540. setPositions(data: Nullable<FloatArray>): void;
  19541. /**
  19542. * Gets the position data stored in this target
  19543. * @returns a FloatArray containing the position data (or null if not present)
  19544. */
  19545. getPositions(): Nullable<FloatArray>;
  19546. /**
  19547. * Affects normal data to this target
  19548. * @param data defines the normal data to use
  19549. */
  19550. setNormals(data: Nullable<FloatArray>): void;
  19551. /**
  19552. * Gets the normal data stored in this target
  19553. * @returns a FloatArray containing the normal data (or null if not present)
  19554. */
  19555. getNormals(): Nullable<FloatArray>;
  19556. /**
  19557. * Affects tangent data to this target
  19558. * @param data defines the tangent data to use
  19559. */
  19560. setTangents(data: Nullable<FloatArray>): void;
  19561. /**
  19562. * Gets the tangent data stored in this target
  19563. * @returns a FloatArray containing the tangent data (or null if not present)
  19564. */
  19565. getTangents(): Nullable<FloatArray>;
  19566. /**
  19567. * Serializes the current target into a Serialization object
  19568. * @returns the serialized object
  19569. */
  19570. serialize(): any;
  19571. /**
  19572. * Returns the string "MorphTarget"
  19573. * @returns "MorphTarget"
  19574. */
  19575. getClassName(): string;
  19576. /**
  19577. * Creates a new target from serialized data
  19578. * @param serializationObject defines the serialized data to use
  19579. * @returns a new MorphTarget
  19580. */
  19581. static Parse(serializationObject: any): MorphTarget;
  19582. /**
  19583. * Creates a MorphTarget from mesh data
  19584. * @param mesh defines the source mesh
  19585. * @param name defines the name to use for the new target
  19586. * @param influence defines the influence to attach to the target
  19587. * @returns a new MorphTarget
  19588. */
  19589. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19590. }
  19591. }
  19592. declare module "babylonjs/Morph/morphTargetManager" {
  19593. import { Nullable } from "babylonjs/types";
  19594. import { Scene } from "babylonjs/scene";
  19595. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19596. /**
  19597. * This class is used to deform meshes using morphing between different targets
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19599. */
  19600. export class MorphTargetManager {
  19601. private _targets;
  19602. private _targetInfluenceChangedObservers;
  19603. private _targetDataLayoutChangedObservers;
  19604. private _activeTargets;
  19605. private _scene;
  19606. private _influences;
  19607. private _supportsNormals;
  19608. private _supportsTangents;
  19609. private _vertexCount;
  19610. private _uniqueId;
  19611. private _tempInfluences;
  19612. /**
  19613. * Creates a new MorphTargetManager
  19614. * @param scene defines the current scene
  19615. */
  19616. constructor(scene?: Nullable<Scene>);
  19617. /**
  19618. * Gets the unique ID of this manager
  19619. */
  19620. readonly uniqueId: number;
  19621. /**
  19622. * Gets the number of vertices handled by this manager
  19623. */
  19624. readonly vertexCount: number;
  19625. /**
  19626. * Gets a boolean indicating if this manager supports morphing of normals
  19627. */
  19628. readonly supportsNormals: boolean;
  19629. /**
  19630. * Gets a boolean indicating if this manager supports morphing of tangents
  19631. */
  19632. readonly supportsTangents: boolean;
  19633. /**
  19634. * Gets the number of targets stored in this manager
  19635. */
  19636. readonly numTargets: number;
  19637. /**
  19638. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19639. */
  19640. readonly numInfluencers: number;
  19641. /**
  19642. * Gets the list of influences (one per target)
  19643. */
  19644. readonly influences: Float32Array;
  19645. /**
  19646. * Gets the active target at specified index. An active target is a target with an influence > 0
  19647. * @param index defines the index to check
  19648. * @returns the requested target
  19649. */
  19650. getActiveTarget(index: number): MorphTarget;
  19651. /**
  19652. * Gets the target at specified index
  19653. * @param index defines the index to check
  19654. * @returns the requested target
  19655. */
  19656. getTarget(index: number): MorphTarget;
  19657. /**
  19658. * Add a new target to this manager
  19659. * @param target defines the target to add
  19660. */
  19661. addTarget(target: MorphTarget): void;
  19662. /**
  19663. * Removes a target from the manager
  19664. * @param target defines the target to remove
  19665. */
  19666. removeTarget(target: MorphTarget): void;
  19667. /**
  19668. * Serializes the current manager into a Serialization object
  19669. * @returns the serialized object
  19670. */
  19671. serialize(): any;
  19672. private _syncActiveTargets;
  19673. /**
  19674. * Syncrhonize the targets with all the meshes using this morph target manager
  19675. */
  19676. synchronize(): void;
  19677. /**
  19678. * Creates a new MorphTargetManager from serialized data
  19679. * @param serializationObject defines the serialized data
  19680. * @param scene defines the hosting scene
  19681. * @returns the new MorphTargetManager
  19682. */
  19683. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19684. }
  19685. }
  19686. declare module "babylonjs/Meshes/groundMesh" {
  19687. import { Scene } from "babylonjs/scene";
  19688. import { Vector3 } from "babylonjs/Maths/math";
  19689. import { Mesh } from "babylonjs/Meshes/mesh";
  19690. /**
  19691. * Mesh representing the gorund
  19692. */
  19693. export class GroundMesh extends Mesh {
  19694. /** If octree should be generated */
  19695. generateOctree: boolean;
  19696. private _heightQuads;
  19697. /** @hidden */
  19698. _subdivisionsX: number;
  19699. /** @hidden */
  19700. _subdivisionsY: number;
  19701. /** @hidden */
  19702. _width: number;
  19703. /** @hidden */
  19704. _height: number;
  19705. /** @hidden */
  19706. _minX: number;
  19707. /** @hidden */
  19708. _maxX: number;
  19709. /** @hidden */
  19710. _minZ: number;
  19711. /** @hidden */
  19712. _maxZ: number;
  19713. constructor(name: string, scene: Scene);
  19714. /**
  19715. * "GroundMesh"
  19716. * @returns "GroundMesh"
  19717. */
  19718. getClassName(): string;
  19719. /**
  19720. * The minimum of x and y subdivisions
  19721. */
  19722. readonly subdivisions: number;
  19723. /**
  19724. * X subdivisions
  19725. */
  19726. readonly subdivisionsX: number;
  19727. /**
  19728. * Y subdivisions
  19729. */
  19730. readonly subdivisionsY: number;
  19731. /**
  19732. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19733. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19734. * @param chunksCount the number of subdivisions for x and y
  19735. * @param octreeBlocksSize (Default: 32)
  19736. */
  19737. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19738. /**
  19739. * Returns a height (y) value in the Worl system :
  19740. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19741. * @param x x coordinate
  19742. * @param z z coordinate
  19743. * @returns the ground y position if (x, z) are outside the ground surface.
  19744. */
  19745. getHeightAtCoordinates(x: number, z: number): number;
  19746. /**
  19747. * Returns a normalized vector (Vector3) orthogonal to the ground
  19748. * at the ground coordinates (x, z) expressed in the World system.
  19749. * @param x x coordinate
  19750. * @param z z coordinate
  19751. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19752. */
  19753. getNormalAtCoordinates(x: number, z: number): Vector3;
  19754. /**
  19755. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19756. * at the ground coordinates (x, z) expressed in the World system.
  19757. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19758. * @param x x coordinate
  19759. * @param z z coordinate
  19760. * @param ref vector to store the result
  19761. * @returns the GroundMesh.
  19762. */
  19763. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19764. /**
  19765. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19766. * if the ground has been updated.
  19767. * This can be used in the render loop.
  19768. * @returns the GroundMesh.
  19769. */
  19770. updateCoordinateHeights(): GroundMesh;
  19771. private _getFacetAt;
  19772. private _initHeightQuads;
  19773. private _computeHeightQuads;
  19774. /**
  19775. * Serializes this ground mesh
  19776. * @param serializationObject object to write serialization to
  19777. */
  19778. serialize(serializationObject: any): void;
  19779. /**
  19780. * Parses a serialized ground mesh
  19781. * @param parsedMesh the serialized mesh
  19782. * @param scene the scene to create the ground mesh in
  19783. * @returns the created ground mesh
  19784. */
  19785. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19786. }
  19787. }
  19788. declare module "babylonjs/Physics/physicsJoint" {
  19789. import { Vector3 } from "babylonjs/Maths/math";
  19790. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19791. /**
  19792. * Interface for Physics-Joint data
  19793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19794. */
  19795. export interface PhysicsJointData {
  19796. /**
  19797. * The main pivot of the joint
  19798. */
  19799. mainPivot?: Vector3;
  19800. /**
  19801. * The connected pivot of the joint
  19802. */
  19803. connectedPivot?: Vector3;
  19804. /**
  19805. * The main axis of the joint
  19806. */
  19807. mainAxis?: Vector3;
  19808. /**
  19809. * The connected axis of the joint
  19810. */
  19811. connectedAxis?: Vector3;
  19812. /**
  19813. * The collision of the joint
  19814. */
  19815. collision?: boolean;
  19816. /**
  19817. * Native Oimo/Cannon/Energy data
  19818. */
  19819. nativeParams?: any;
  19820. }
  19821. /**
  19822. * This is a holder class for the physics joint created by the physics plugin
  19823. * It holds a set of functions to control the underlying joint
  19824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19825. */
  19826. export class PhysicsJoint {
  19827. /**
  19828. * The type of the physics joint
  19829. */
  19830. type: number;
  19831. /**
  19832. * The data for the physics joint
  19833. */
  19834. jointData: PhysicsJointData;
  19835. private _physicsJoint;
  19836. protected _physicsPlugin: IPhysicsEnginePlugin;
  19837. /**
  19838. * Initializes the physics joint
  19839. * @param type The type of the physics joint
  19840. * @param jointData The data for the physics joint
  19841. */
  19842. constructor(
  19843. /**
  19844. * The type of the physics joint
  19845. */
  19846. type: number,
  19847. /**
  19848. * The data for the physics joint
  19849. */
  19850. jointData: PhysicsJointData);
  19851. /**
  19852. * Gets the physics joint
  19853. */
  19854. /**
  19855. * Sets the physics joint
  19856. */
  19857. physicsJoint: any;
  19858. /**
  19859. * Sets the physics plugin
  19860. */
  19861. physicsPlugin: IPhysicsEnginePlugin;
  19862. /**
  19863. * Execute a function that is physics-plugin specific.
  19864. * @param {Function} func the function that will be executed.
  19865. * It accepts two parameters: the physics world and the physics joint
  19866. */
  19867. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19868. /**
  19869. * Distance-Joint type
  19870. */
  19871. static DistanceJoint: number;
  19872. /**
  19873. * Hinge-Joint type
  19874. */
  19875. static HingeJoint: number;
  19876. /**
  19877. * Ball-and-Socket joint type
  19878. */
  19879. static BallAndSocketJoint: number;
  19880. /**
  19881. * Wheel-Joint type
  19882. */
  19883. static WheelJoint: number;
  19884. /**
  19885. * Slider-Joint type
  19886. */
  19887. static SliderJoint: number;
  19888. /**
  19889. * Prismatic-Joint type
  19890. */
  19891. static PrismaticJoint: number;
  19892. /**
  19893. * Universal-Joint type
  19894. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19895. */
  19896. static UniversalJoint: number;
  19897. /**
  19898. * Hinge-Joint 2 type
  19899. */
  19900. static Hinge2Joint: number;
  19901. /**
  19902. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19903. */
  19904. static PointToPointJoint: number;
  19905. /**
  19906. * Spring-Joint type
  19907. */
  19908. static SpringJoint: number;
  19909. /**
  19910. * Lock-Joint type
  19911. */
  19912. static LockJoint: number;
  19913. }
  19914. /**
  19915. * A class representing a physics distance joint
  19916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19917. */
  19918. export class DistanceJoint extends PhysicsJoint {
  19919. /**
  19920. *
  19921. * @param jointData The data for the Distance-Joint
  19922. */
  19923. constructor(jointData: DistanceJointData);
  19924. /**
  19925. * Update the predefined distance.
  19926. * @param maxDistance The maximum preferred distance
  19927. * @param minDistance The minimum preferred distance
  19928. */
  19929. updateDistance(maxDistance: number, minDistance?: number): void;
  19930. }
  19931. /**
  19932. * Represents a Motor-Enabled Joint
  19933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19934. */
  19935. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19936. /**
  19937. * Initializes the Motor-Enabled Joint
  19938. * @param type The type of the joint
  19939. * @param jointData The physica joint data for the joint
  19940. */
  19941. constructor(type: number, jointData: PhysicsJointData);
  19942. /**
  19943. * Set the motor values.
  19944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19945. * @param force the force to apply
  19946. * @param maxForce max force for this motor.
  19947. */
  19948. setMotor(force?: number, maxForce?: number): void;
  19949. /**
  19950. * Set the motor's limits.
  19951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19952. * @param upperLimit The upper limit of the motor
  19953. * @param lowerLimit The lower limit of the motor
  19954. */
  19955. setLimit(upperLimit: number, lowerLimit?: number): void;
  19956. }
  19957. /**
  19958. * This class represents a single physics Hinge-Joint
  19959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19960. */
  19961. export class HingeJoint extends MotorEnabledJoint {
  19962. /**
  19963. * Initializes the Hinge-Joint
  19964. * @param jointData The joint data for the Hinge-Joint
  19965. */
  19966. constructor(jointData: PhysicsJointData);
  19967. /**
  19968. * Set the motor values.
  19969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19970. * @param {number} force the force to apply
  19971. * @param {number} maxForce max force for this motor.
  19972. */
  19973. setMotor(force?: number, maxForce?: number): void;
  19974. /**
  19975. * Set the motor's limits.
  19976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19977. * @param upperLimit The upper limit of the motor
  19978. * @param lowerLimit The lower limit of the motor
  19979. */
  19980. setLimit(upperLimit: number, lowerLimit?: number): void;
  19981. }
  19982. /**
  19983. * This class represents a dual hinge physics joint (same as wheel joint)
  19984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19985. */
  19986. export class Hinge2Joint extends MotorEnabledJoint {
  19987. /**
  19988. * Initializes the Hinge2-Joint
  19989. * @param jointData The joint data for the Hinge2-Joint
  19990. */
  19991. constructor(jointData: PhysicsJointData);
  19992. /**
  19993. * Set the motor values.
  19994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19995. * @param {number} targetSpeed the speed the motor is to reach
  19996. * @param {number} maxForce max force for this motor.
  19997. * @param {motorIndex} the motor's index, 0 or 1.
  19998. */
  19999. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20000. /**
  20001. * Set the motor limits.
  20002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20003. * @param {number} upperLimit the upper limit
  20004. * @param {number} lowerLimit lower limit
  20005. * @param {motorIndex} the motor's index, 0 or 1.
  20006. */
  20007. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20008. }
  20009. /**
  20010. * Interface for a motor enabled joint
  20011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20012. */
  20013. export interface IMotorEnabledJoint {
  20014. /**
  20015. * Physics joint
  20016. */
  20017. physicsJoint: any;
  20018. /**
  20019. * Sets the motor of the motor-enabled joint
  20020. * @param force The force of the motor
  20021. * @param maxForce The maximum force of the motor
  20022. * @param motorIndex The index of the motor
  20023. */
  20024. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20025. /**
  20026. * Sets the limit of the motor
  20027. * @param upperLimit The upper limit of the motor
  20028. * @param lowerLimit The lower limit of the motor
  20029. * @param motorIndex The index of the motor
  20030. */
  20031. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20032. }
  20033. /**
  20034. * Joint data for a Distance-Joint
  20035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20036. */
  20037. export interface DistanceJointData extends PhysicsJointData {
  20038. /**
  20039. * Max distance the 2 joint objects can be apart
  20040. */
  20041. maxDistance: number;
  20042. }
  20043. /**
  20044. * Joint data from a spring joint
  20045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20046. */
  20047. export interface SpringJointData extends PhysicsJointData {
  20048. /**
  20049. * Length of the spring
  20050. */
  20051. length: number;
  20052. /**
  20053. * Stiffness of the spring
  20054. */
  20055. stiffness: number;
  20056. /**
  20057. * Damping of the spring
  20058. */
  20059. damping: number;
  20060. /** this callback will be called when applying the force to the impostors. */
  20061. forceApplicationCallback: () => void;
  20062. }
  20063. }
  20064. declare module "babylonjs/Physics/physicsRaycastResult" {
  20065. import { Vector3 } from "babylonjs/Maths/math";
  20066. /**
  20067. * Holds the data for the raycast result
  20068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20069. */
  20070. export class PhysicsRaycastResult {
  20071. private _hasHit;
  20072. private _hitDistance;
  20073. private _hitNormalWorld;
  20074. private _hitPointWorld;
  20075. private _rayFromWorld;
  20076. private _rayToWorld;
  20077. /**
  20078. * Gets if there was a hit
  20079. */
  20080. readonly hasHit: boolean;
  20081. /**
  20082. * Gets the distance from the hit
  20083. */
  20084. readonly hitDistance: number;
  20085. /**
  20086. * Gets the hit normal/direction in the world
  20087. */
  20088. readonly hitNormalWorld: Vector3;
  20089. /**
  20090. * Gets the hit point in the world
  20091. */
  20092. readonly hitPointWorld: Vector3;
  20093. /**
  20094. * Gets the ray "start point" of the ray in the world
  20095. */
  20096. readonly rayFromWorld: Vector3;
  20097. /**
  20098. * Gets the ray "end point" of the ray in the world
  20099. */
  20100. readonly rayToWorld: Vector3;
  20101. /**
  20102. * Sets the hit data (normal & point in world space)
  20103. * @param hitNormalWorld defines the normal in world space
  20104. * @param hitPointWorld defines the point in world space
  20105. */
  20106. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20107. /**
  20108. * Sets the distance from the start point to the hit point
  20109. * @param distance
  20110. */
  20111. setHitDistance(distance: number): void;
  20112. /**
  20113. * Calculates the distance manually
  20114. */
  20115. calculateHitDistance(): void;
  20116. /**
  20117. * Resets all the values to default
  20118. * @param from The from point on world space
  20119. * @param to The to point on world space
  20120. */
  20121. reset(from?: Vector3, to?: Vector3): void;
  20122. }
  20123. /**
  20124. * Interface for the size containing width and height
  20125. */
  20126. interface IXYZ {
  20127. /**
  20128. * X
  20129. */
  20130. x: number;
  20131. /**
  20132. * Y
  20133. */
  20134. y: number;
  20135. /**
  20136. * Z
  20137. */
  20138. z: number;
  20139. }
  20140. }
  20141. declare module "babylonjs/Physics/IPhysicsEngine" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20145. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20146. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20147. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20148. /**
  20149. * Interface used to describe a physics joint
  20150. */
  20151. export interface PhysicsImpostorJoint {
  20152. /** Defines the main impostor to which the joint is linked */
  20153. mainImpostor: PhysicsImpostor;
  20154. /** Defines the impostor that is connected to the main impostor using this joint */
  20155. connectedImpostor: PhysicsImpostor;
  20156. /** Defines the joint itself */
  20157. joint: PhysicsJoint;
  20158. }
  20159. /** @hidden */
  20160. export interface IPhysicsEnginePlugin {
  20161. world: any;
  20162. name: string;
  20163. setGravity(gravity: Vector3): void;
  20164. setTimeStep(timeStep: number): void;
  20165. getTimeStep(): number;
  20166. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20170. removePhysicsBody(impostor: PhysicsImpostor): void;
  20171. generateJoint(joint: PhysicsImpostorJoint): void;
  20172. removeJoint(joint: PhysicsImpostorJoint): void;
  20173. isSupported(): boolean;
  20174. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20175. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20177. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20179. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20180. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20181. getBodyMass(impostor: PhysicsImpostor): number;
  20182. getBodyFriction(impostor: PhysicsImpostor): number;
  20183. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20184. getBodyRestitution(impostor: PhysicsImpostor): number;
  20185. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20186. getBodyPressure?(impostor: PhysicsImpostor): number;
  20187. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20188. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20189. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20190. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20191. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20192. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20193. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20194. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20195. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20196. sleepBody(impostor: PhysicsImpostor): void;
  20197. wakeUpBody(impostor: PhysicsImpostor): void;
  20198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20200. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20202. getRadius(impostor: PhysicsImpostor): number;
  20203. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20204. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20205. dispose(): void;
  20206. }
  20207. /**
  20208. * Interface used to define a physics engine
  20209. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20210. */
  20211. export interface IPhysicsEngine {
  20212. /**
  20213. * Gets the gravity vector used by the simulation
  20214. */
  20215. gravity: Vector3;
  20216. /**
  20217. * Sets the gravity vector used by the simulation
  20218. * @param gravity defines the gravity vector to use
  20219. */
  20220. setGravity(gravity: Vector3): void;
  20221. /**
  20222. * Set the time step of the physics engine.
  20223. * Default is 1/60.
  20224. * To slow it down, enter 1/600 for example.
  20225. * To speed it up, 1/30
  20226. * @param newTimeStep the new timestep to apply to this world.
  20227. */
  20228. setTimeStep(newTimeStep: number): void;
  20229. /**
  20230. * Get the time step of the physics engine.
  20231. * @returns the current time step
  20232. */
  20233. getTimeStep(): number;
  20234. /**
  20235. * Release all resources
  20236. */
  20237. dispose(): void;
  20238. /**
  20239. * Gets the name of the current physics plugin
  20240. * @returns the name of the plugin
  20241. */
  20242. getPhysicsPluginName(): string;
  20243. /**
  20244. * Adding a new impostor for the impostor tracking.
  20245. * This will be done by the impostor itself.
  20246. * @param impostor the impostor to add
  20247. */
  20248. addImpostor(impostor: PhysicsImpostor): void;
  20249. /**
  20250. * Remove an impostor from the engine.
  20251. * This impostor and its mesh will not longer be updated by the physics engine.
  20252. * @param impostor the impostor to remove
  20253. */
  20254. removeImpostor(impostor: PhysicsImpostor): void;
  20255. /**
  20256. * Add a joint to the physics engine
  20257. * @param mainImpostor defines the main impostor to which the joint is added.
  20258. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20259. * @param joint defines the joint that will connect both impostors.
  20260. */
  20261. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20262. /**
  20263. * Removes a joint from the simulation
  20264. * @param mainImpostor defines the impostor used with the joint
  20265. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20266. * @param joint defines the joint to remove
  20267. */
  20268. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20269. /**
  20270. * Gets the current plugin used to run the simulation
  20271. * @returns current plugin
  20272. */
  20273. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20274. /**
  20275. * Gets the list of physic impostors
  20276. * @returns an array of PhysicsImpostor
  20277. */
  20278. getImpostors(): Array<PhysicsImpostor>;
  20279. /**
  20280. * Gets the impostor for a physics enabled object
  20281. * @param object defines the object impersonated by the impostor
  20282. * @returns the PhysicsImpostor or null if not found
  20283. */
  20284. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20285. /**
  20286. * Gets the impostor for a physics body object
  20287. * @param body defines physics body used by the impostor
  20288. * @returns the PhysicsImpostor or null if not found
  20289. */
  20290. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20291. /**
  20292. * Does a raycast in the physics world
  20293. * @param from when should the ray start?
  20294. * @param to when should the ray end?
  20295. * @returns PhysicsRaycastResult
  20296. */
  20297. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20298. /**
  20299. * Called by the scene. No need to call it.
  20300. * @param delta defines the timespam between frames
  20301. */
  20302. _step(delta: number): void;
  20303. }
  20304. }
  20305. declare module "babylonjs/Physics/physicsImpostor" {
  20306. import { Nullable, IndicesArray } from "babylonjs/types";
  20307. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20308. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20310. import { Scene } from "babylonjs/scene";
  20311. import { Bone } from "babylonjs/Bones/bone";
  20312. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20313. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20314. /**
  20315. * The interface for the physics imposter parameters
  20316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20317. */
  20318. export interface PhysicsImpostorParameters {
  20319. /**
  20320. * The mass of the physics imposter
  20321. */
  20322. mass: number;
  20323. /**
  20324. * The friction of the physics imposter
  20325. */
  20326. friction?: number;
  20327. /**
  20328. * The coefficient of restitution of the physics imposter
  20329. */
  20330. restitution?: number;
  20331. /**
  20332. * The native options of the physics imposter
  20333. */
  20334. nativeOptions?: any;
  20335. /**
  20336. * Specifies if the parent should be ignored
  20337. */
  20338. ignoreParent?: boolean;
  20339. /**
  20340. * Specifies if bi-directional transformations should be disabled
  20341. */
  20342. disableBidirectionalTransformation?: boolean;
  20343. /**
  20344. * The pressure inside the physics imposter, soft object only
  20345. */
  20346. pressure?: number;
  20347. /**
  20348. * The stiffness the physics imposter, soft object only
  20349. */
  20350. stiffness?: number;
  20351. /**
  20352. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20353. */
  20354. velocityIterations?: number;
  20355. /**
  20356. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20357. */
  20358. positionIterations?: number;
  20359. /**
  20360. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20361. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20362. * Add to fix multiple points
  20363. */
  20364. fixedPoints?: number;
  20365. /**
  20366. * The collision margin around a soft object
  20367. */
  20368. margin?: number;
  20369. /**
  20370. * The collision margin around a soft object
  20371. */
  20372. damping?: number;
  20373. /**
  20374. * The path for a rope based on an extrusion
  20375. */
  20376. path?: any;
  20377. /**
  20378. * The shape of an extrusion used for a rope based on an extrusion
  20379. */
  20380. shape?: any;
  20381. }
  20382. /**
  20383. * Interface for a physics-enabled object
  20384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20385. */
  20386. export interface IPhysicsEnabledObject {
  20387. /**
  20388. * The position of the physics-enabled object
  20389. */
  20390. position: Vector3;
  20391. /**
  20392. * The rotation of the physics-enabled object
  20393. */
  20394. rotationQuaternion: Nullable<Quaternion>;
  20395. /**
  20396. * The scale of the physics-enabled object
  20397. */
  20398. scaling: Vector3;
  20399. /**
  20400. * The rotation of the physics-enabled object
  20401. */
  20402. rotation?: Vector3;
  20403. /**
  20404. * The parent of the physics-enabled object
  20405. */
  20406. parent?: any;
  20407. /**
  20408. * The bounding info of the physics-enabled object
  20409. * @returns The bounding info of the physics-enabled object
  20410. */
  20411. getBoundingInfo(): BoundingInfo;
  20412. /**
  20413. * Computes the world matrix
  20414. * @param force Specifies if the world matrix should be computed by force
  20415. * @returns A world matrix
  20416. */
  20417. computeWorldMatrix(force: boolean): Matrix;
  20418. /**
  20419. * Gets the world matrix
  20420. * @returns A world matrix
  20421. */
  20422. getWorldMatrix?(): Matrix;
  20423. /**
  20424. * Gets the child meshes
  20425. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20426. * @returns An array of abstract meshes
  20427. */
  20428. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20429. /**
  20430. * Gets the vertex data
  20431. * @param kind The type of vertex data
  20432. * @returns A nullable array of numbers, or a float32 array
  20433. */
  20434. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20435. /**
  20436. * Gets the indices from the mesh
  20437. * @returns A nullable array of index arrays
  20438. */
  20439. getIndices?(): Nullable<IndicesArray>;
  20440. /**
  20441. * Gets the scene from the mesh
  20442. * @returns the indices array or null
  20443. */
  20444. getScene?(): Scene;
  20445. /**
  20446. * Gets the absolute position from the mesh
  20447. * @returns the absolute position
  20448. */
  20449. getAbsolutePosition(): Vector3;
  20450. /**
  20451. * Gets the absolute pivot point from the mesh
  20452. * @returns the absolute pivot point
  20453. */
  20454. getAbsolutePivotPoint(): Vector3;
  20455. /**
  20456. * Rotates the mesh
  20457. * @param axis The axis of rotation
  20458. * @param amount The amount of rotation
  20459. * @param space The space of the rotation
  20460. * @returns The rotation transform node
  20461. */
  20462. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20463. /**
  20464. * Translates the mesh
  20465. * @param axis The axis of translation
  20466. * @param distance The distance of translation
  20467. * @param space The space of the translation
  20468. * @returns The transform node
  20469. */
  20470. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20471. /**
  20472. * Sets the absolute position of the mesh
  20473. * @param absolutePosition The absolute position of the mesh
  20474. * @returns The transform node
  20475. */
  20476. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20477. /**
  20478. * Gets the class name of the mesh
  20479. * @returns The class name
  20480. */
  20481. getClassName(): string;
  20482. }
  20483. /**
  20484. * Represents a physics imposter
  20485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20486. */
  20487. export class PhysicsImpostor {
  20488. /**
  20489. * The physics-enabled object used as the physics imposter
  20490. */
  20491. object: IPhysicsEnabledObject;
  20492. /**
  20493. * The type of the physics imposter
  20494. */
  20495. type: number;
  20496. private _options;
  20497. private _scene?;
  20498. /**
  20499. * The default object size of the imposter
  20500. */
  20501. static DEFAULT_OBJECT_SIZE: Vector3;
  20502. /**
  20503. * The identity quaternion of the imposter
  20504. */
  20505. static IDENTITY_QUATERNION: Quaternion;
  20506. /** @hidden */
  20507. _pluginData: any;
  20508. private _physicsEngine;
  20509. private _physicsBody;
  20510. private _bodyUpdateRequired;
  20511. private _onBeforePhysicsStepCallbacks;
  20512. private _onAfterPhysicsStepCallbacks;
  20513. /** @hidden */
  20514. _onPhysicsCollideCallbacks: Array<{
  20515. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20516. otherImpostors: Array<PhysicsImpostor>;
  20517. }>;
  20518. private _deltaPosition;
  20519. private _deltaRotation;
  20520. private _deltaRotationConjugated;
  20521. /** hidden */
  20522. _isFromLine: boolean;
  20523. private _parent;
  20524. private _isDisposed;
  20525. private static _tmpVecs;
  20526. private static _tmpQuat;
  20527. /**
  20528. * Specifies if the physics imposter is disposed
  20529. */
  20530. readonly isDisposed: boolean;
  20531. /**
  20532. * Gets the mass of the physics imposter
  20533. */
  20534. mass: number;
  20535. /**
  20536. * Gets the coefficient of friction
  20537. */
  20538. /**
  20539. * Sets the coefficient of friction
  20540. */
  20541. friction: number;
  20542. /**
  20543. * Gets the coefficient of restitution
  20544. */
  20545. /**
  20546. * Sets the coefficient of restitution
  20547. */
  20548. restitution: number;
  20549. /**
  20550. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20551. */
  20552. /**
  20553. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20554. */
  20555. pressure: number;
  20556. /**
  20557. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20558. */
  20559. /**
  20560. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20561. */
  20562. stiffness: number;
  20563. /**
  20564. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20565. */
  20566. /**
  20567. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20568. */
  20569. velocityIterations: number;
  20570. /**
  20571. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20572. */
  20573. /**
  20574. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20575. */
  20576. positionIterations: number;
  20577. /**
  20578. * The unique id of the physics imposter
  20579. * set by the physics engine when adding this impostor to the array
  20580. */
  20581. uniqueId: number;
  20582. /**
  20583. * @hidden
  20584. */
  20585. soft: boolean;
  20586. /**
  20587. * @hidden
  20588. */
  20589. segments: number;
  20590. private _joints;
  20591. /**
  20592. * Initializes the physics imposter
  20593. * @param object The physics-enabled object used as the physics imposter
  20594. * @param type The type of the physics imposter
  20595. * @param _options The options for the physics imposter
  20596. * @param _scene The Babylon scene
  20597. */
  20598. constructor(
  20599. /**
  20600. * The physics-enabled object used as the physics imposter
  20601. */
  20602. object: IPhysicsEnabledObject,
  20603. /**
  20604. * The type of the physics imposter
  20605. */
  20606. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20607. /**
  20608. * This function will completly initialize this impostor.
  20609. * It will create a new body - but only if this mesh has no parent.
  20610. * If it has, this impostor will not be used other than to define the impostor
  20611. * of the child mesh.
  20612. * @hidden
  20613. */
  20614. _init(): void;
  20615. private _getPhysicsParent;
  20616. /**
  20617. * Should a new body be generated.
  20618. * @returns boolean specifying if body initialization is required
  20619. */
  20620. isBodyInitRequired(): boolean;
  20621. /**
  20622. * Sets the updated scaling
  20623. * @param updated Specifies if the scaling is updated
  20624. */
  20625. setScalingUpdated(): void;
  20626. /**
  20627. * Force a regeneration of this or the parent's impostor's body.
  20628. * Use under cautious - This will remove all joints already implemented.
  20629. */
  20630. forceUpdate(): void;
  20631. /**
  20632. * Gets the body that holds this impostor. Either its own, or its parent.
  20633. */
  20634. /**
  20635. * Set the physics body. Used mainly by the physics engine/plugin
  20636. */
  20637. physicsBody: any;
  20638. /**
  20639. * Get the parent of the physics imposter
  20640. * @returns Physics imposter or null
  20641. */
  20642. /**
  20643. * Sets the parent of the physics imposter
  20644. */
  20645. parent: Nullable<PhysicsImpostor>;
  20646. /**
  20647. * Resets the update flags
  20648. */
  20649. resetUpdateFlags(): void;
  20650. /**
  20651. * Gets the object extend size
  20652. * @returns the object extend size
  20653. */
  20654. getObjectExtendSize(): Vector3;
  20655. /**
  20656. * Gets the object center
  20657. * @returns The object center
  20658. */
  20659. getObjectCenter(): Vector3;
  20660. /**
  20661. * Get a specific parametes from the options parameter
  20662. * @param paramName The object parameter name
  20663. * @returns The object parameter
  20664. */
  20665. getParam(paramName: string): any;
  20666. /**
  20667. * Sets a specific parameter in the options given to the physics plugin
  20668. * @param paramName The parameter name
  20669. * @param value The value of the parameter
  20670. */
  20671. setParam(paramName: string, value: number): void;
  20672. /**
  20673. * Specifically change the body's mass option. Won't recreate the physics body object
  20674. * @param mass The mass of the physics imposter
  20675. */
  20676. setMass(mass: number): void;
  20677. /**
  20678. * Gets the linear velocity
  20679. * @returns linear velocity or null
  20680. */
  20681. getLinearVelocity(): Nullable<Vector3>;
  20682. /**
  20683. * Sets the linear velocity
  20684. * @param velocity linear velocity or null
  20685. */
  20686. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20687. /**
  20688. * Gets the angular velocity
  20689. * @returns angular velocity or null
  20690. */
  20691. getAngularVelocity(): Nullable<Vector3>;
  20692. /**
  20693. * Sets the angular velocity
  20694. * @param velocity The velocity or null
  20695. */
  20696. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20697. /**
  20698. * Execute a function with the physics plugin native code
  20699. * Provide a function the will have two variables - the world object and the physics body object
  20700. * @param func The function to execute with the physics plugin native code
  20701. */
  20702. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20703. /**
  20704. * Register a function that will be executed before the physics world is stepping forward
  20705. * @param func The function to execute before the physics world is stepped forward
  20706. */
  20707. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20708. /**
  20709. * Unregister a function that will be executed before the physics world is stepping forward
  20710. * @param func The function to execute before the physics world is stepped forward
  20711. */
  20712. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20713. /**
  20714. * Register a function that will be executed after the physics step
  20715. * @param func The function to execute after physics step
  20716. */
  20717. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20718. /**
  20719. * Unregisters a function that will be executed after the physics step
  20720. * @param func The function to execute after physics step
  20721. */
  20722. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20723. /**
  20724. * register a function that will be executed when this impostor collides against a different body
  20725. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20726. * @param func Callback that is executed on collision
  20727. */
  20728. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20729. /**
  20730. * Unregisters the physics imposter on contact
  20731. * @param collideAgainst The physics object to collide against
  20732. * @param func Callback to execute on collision
  20733. */
  20734. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20735. private _tmpQuat;
  20736. private _tmpQuat2;
  20737. /**
  20738. * Get the parent rotation
  20739. * @returns The parent rotation
  20740. */
  20741. getParentsRotation(): Quaternion;
  20742. /**
  20743. * this function is executed by the physics engine.
  20744. */
  20745. beforeStep: () => void;
  20746. /**
  20747. * this function is executed by the physics engine
  20748. */
  20749. afterStep: () => void;
  20750. /**
  20751. * Legacy collision detection event support
  20752. */
  20753. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20754. /**
  20755. * event and body object due to cannon's event-based architecture.
  20756. */
  20757. onCollide: (e: {
  20758. body: any;
  20759. }) => void;
  20760. /**
  20761. * Apply a force
  20762. * @param force The force to apply
  20763. * @param contactPoint The contact point for the force
  20764. * @returns The physics imposter
  20765. */
  20766. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20767. /**
  20768. * Apply an impulse
  20769. * @param force The impulse force
  20770. * @param contactPoint The contact point for the impulse force
  20771. * @returns The physics imposter
  20772. */
  20773. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20774. /**
  20775. * A help function to create a joint
  20776. * @param otherImpostor A physics imposter used to create a joint
  20777. * @param jointType The type of joint
  20778. * @param jointData The data for the joint
  20779. * @returns The physics imposter
  20780. */
  20781. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20782. /**
  20783. * Add a joint to this impostor with a different impostor
  20784. * @param otherImpostor A physics imposter used to add a joint
  20785. * @param joint The joint to add
  20786. * @returns The physics imposter
  20787. */
  20788. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20789. /**
  20790. * Add an anchor to a cloth impostor
  20791. * @param otherImpostor rigid impostor to anchor to
  20792. * @param width ratio across width from 0 to 1
  20793. * @param height ratio up height from 0 to 1
  20794. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20795. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20796. * @returns impostor the soft imposter
  20797. */
  20798. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20799. /**
  20800. * Add a hook to a rope impostor
  20801. * @param otherImpostor rigid impostor to anchor to
  20802. * @param length ratio across rope from 0 to 1
  20803. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20804. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20805. * @returns impostor the rope imposter
  20806. */
  20807. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20808. /**
  20809. * Will keep this body still, in a sleep mode.
  20810. * @returns the physics imposter
  20811. */
  20812. sleep(): PhysicsImpostor;
  20813. /**
  20814. * Wake the body up.
  20815. * @returns The physics imposter
  20816. */
  20817. wakeUp(): PhysicsImpostor;
  20818. /**
  20819. * Clones the physics imposter
  20820. * @param newObject The physics imposter clones to this physics-enabled object
  20821. * @returns A nullable physics imposter
  20822. */
  20823. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20824. /**
  20825. * Disposes the physics imposter
  20826. */
  20827. dispose(): void;
  20828. /**
  20829. * Sets the delta position
  20830. * @param position The delta position amount
  20831. */
  20832. setDeltaPosition(position: Vector3): void;
  20833. /**
  20834. * Sets the delta rotation
  20835. * @param rotation The delta rotation amount
  20836. */
  20837. setDeltaRotation(rotation: Quaternion): void;
  20838. /**
  20839. * Gets the box size of the physics imposter and stores the result in the input parameter
  20840. * @param result Stores the box size
  20841. * @returns The physics imposter
  20842. */
  20843. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20844. /**
  20845. * Gets the radius of the physics imposter
  20846. * @returns Radius of the physics imposter
  20847. */
  20848. getRadius(): number;
  20849. /**
  20850. * Sync a bone with this impostor
  20851. * @param bone The bone to sync to the impostor.
  20852. * @param boneMesh The mesh that the bone is influencing.
  20853. * @param jointPivot The pivot of the joint / bone in local space.
  20854. * @param distToJoint Optional distance from the impostor to the joint.
  20855. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20856. */
  20857. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20858. /**
  20859. * Sync impostor to a bone
  20860. * @param bone The bone that the impostor will be synced to.
  20861. * @param boneMesh The mesh that the bone is influencing.
  20862. * @param jointPivot The pivot of the joint / bone in local space.
  20863. * @param distToJoint Optional distance from the impostor to the joint.
  20864. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20865. * @param boneAxis Optional vector3 axis the bone is aligned with
  20866. */
  20867. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20868. /**
  20869. * No-Imposter type
  20870. */
  20871. static NoImpostor: number;
  20872. /**
  20873. * Sphere-Imposter type
  20874. */
  20875. static SphereImpostor: number;
  20876. /**
  20877. * Box-Imposter type
  20878. */
  20879. static BoxImpostor: number;
  20880. /**
  20881. * Plane-Imposter type
  20882. */
  20883. static PlaneImpostor: number;
  20884. /**
  20885. * Mesh-imposter type
  20886. */
  20887. static MeshImpostor: number;
  20888. /**
  20889. * Cylinder-Imposter type
  20890. */
  20891. static CylinderImpostor: number;
  20892. /**
  20893. * Particle-Imposter type
  20894. */
  20895. static ParticleImpostor: number;
  20896. /**
  20897. * Heightmap-Imposter type
  20898. */
  20899. static HeightmapImpostor: number;
  20900. /**
  20901. * ConvexHull-Impostor type (Ammo.js plugin only)
  20902. */
  20903. static ConvexHullImpostor: number;
  20904. /**
  20905. * Rope-Imposter type
  20906. */
  20907. static RopeImpostor: number;
  20908. /**
  20909. * Cloth-Imposter type
  20910. */
  20911. static ClothImpostor: number;
  20912. /**
  20913. * Softbody-Imposter type
  20914. */
  20915. static SoftbodyImpostor: number;
  20916. }
  20917. }
  20918. declare module "babylonjs/Meshes/mesh" {
  20919. import { Observable } from "babylonjs/Misc/observable";
  20920. import { IAnimatable } from "babylonjs/Misc/tools";
  20921. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20922. import { Camera } from "babylonjs/Cameras/camera";
  20923. import { Scene } from "babylonjs/scene";
  20924. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20925. import { Engine } from "babylonjs/Engines/engine";
  20926. import { Node } from "babylonjs/node";
  20927. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20928. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20929. import { Buffer } from "babylonjs/Meshes/buffer";
  20930. import { Geometry } from "babylonjs/Meshes/geometry";
  20931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20932. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20933. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20934. import { Effect } from "babylonjs/Materials/effect";
  20935. import { Material } from "babylonjs/Materials/material";
  20936. import { Skeleton } from "babylonjs/Bones/skeleton";
  20937. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20938. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20939. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20940. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20941. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20942. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20943. /**
  20944. * Class used to represent a specific level of detail of a mesh
  20945. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20946. */
  20947. export class MeshLODLevel {
  20948. /** Defines the distance where this level should star being displayed */
  20949. distance: number;
  20950. /** Defines the mesh to use to render this level */
  20951. mesh: Nullable<Mesh>;
  20952. /**
  20953. * Creates a new LOD level
  20954. * @param distance defines the distance where this level should star being displayed
  20955. * @param mesh defines the mesh to use to render this level
  20956. */
  20957. constructor(
  20958. /** Defines the distance where this level should star being displayed */
  20959. distance: number,
  20960. /** Defines the mesh to use to render this level */
  20961. mesh: Nullable<Mesh>);
  20962. }
  20963. /**
  20964. * @hidden
  20965. **/
  20966. export class _CreationDataStorage {
  20967. closePath?: boolean;
  20968. closeArray?: boolean;
  20969. idx: number[];
  20970. dashSize: number;
  20971. gapSize: number;
  20972. path3D: Path3D;
  20973. pathArray: Vector3[][];
  20974. arc: number;
  20975. radius: number;
  20976. cap: number;
  20977. tessellation: number;
  20978. }
  20979. /**
  20980. * @hidden
  20981. **/
  20982. class _InstanceDataStorage {
  20983. visibleInstances: any;
  20984. renderIdForInstances: number[];
  20985. batchCache: _InstancesBatch;
  20986. instancesBufferSize: number;
  20987. instancesBuffer: Nullable<Buffer>;
  20988. instancesData: Float32Array;
  20989. overridenInstanceCount: number;
  20990. }
  20991. /**
  20992. * @hidden
  20993. **/
  20994. export class _InstancesBatch {
  20995. mustReturn: boolean;
  20996. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20997. renderSelf: boolean[];
  20998. }
  20999. /**
  21000. * Class used to represent renderable models
  21001. */
  21002. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21003. /**
  21004. * Mesh side orientation : usually the external or front surface
  21005. */
  21006. static readonly FRONTSIDE: number;
  21007. /**
  21008. * Mesh side orientation : usually the internal or back surface
  21009. */
  21010. static readonly BACKSIDE: number;
  21011. /**
  21012. * Mesh side orientation : both internal and external or front and back surfaces
  21013. */
  21014. static readonly DOUBLESIDE: number;
  21015. /**
  21016. * Mesh side orientation : by default, `FRONTSIDE`
  21017. */
  21018. static readonly DEFAULTSIDE: number;
  21019. /**
  21020. * Mesh cap setting : no cap
  21021. */
  21022. static readonly NO_CAP: number;
  21023. /**
  21024. * Mesh cap setting : one cap at the beginning of the mesh
  21025. */
  21026. static readonly CAP_START: number;
  21027. /**
  21028. * Mesh cap setting : one cap at the end of the mesh
  21029. */
  21030. static readonly CAP_END: number;
  21031. /**
  21032. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21033. */
  21034. static readonly CAP_ALL: number;
  21035. /**
  21036. * Gets the default side orientation.
  21037. * @param orientation the orientation to value to attempt to get
  21038. * @returns the default orientation
  21039. * @hidden
  21040. */
  21041. static _GetDefaultSideOrientation(orientation?: number): number;
  21042. private _onBeforeRenderObservable;
  21043. private _onBeforeBindObservable;
  21044. private _onAfterRenderObservable;
  21045. private _onBeforeDrawObservable;
  21046. /**
  21047. * An event triggered before rendering the mesh
  21048. */
  21049. readonly onBeforeRenderObservable: Observable<Mesh>;
  21050. /**
  21051. * An event triggered before binding the mesh
  21052. */
  21053. readonly onBeforeBindObservable: Observable<Mesh>;
  21054. /**
  21055. * An event triggered after rendering the mesh
  21056. */
  21057. readonly onAfterRenderObservable: Observable<Mesh>;
  21058. /**
  21059. * An event triggered before drawing the mesh
  21060. */
  21061. readonly onBeforeDrawObservable: Observable<Mesh>;
  21062. private _onBeforeDrawObserver;
  21063. /**
  21064. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21065. */
  21066. onBeforeDraw: () => void;
  21067. /**
  21068. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21069. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21070. */
  21071. delayLoadState: number;
  21072. /**
  21073. * Gets the list of instances created from this mesh
  21074. * it is not supposed to be modified manually.
  21075. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21076. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21077. */
  21078. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21079. /**
  21080. * Gets the file containing delay loading data for this mesh
  21081. */
  21082. delayLoadingFile: string;
  21083. /** @hidden */
  21084. _binaryInfo: any;
  21085. private _LODLevels;
  21086. /**
  21087. * User defined function used to change how LOD level selection is done
  21088. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21089. */
  21090. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21091. private _morphTargetManager;
  21092. /**
  21093. * Gets or sets the morph target manager
  21094. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21095. */
  21096. morphTargetManager: Nullable<MorphTargetManager>;
  21097. /** @hidden */
  21098. _creationDataStorage: Nullable<_CreationDataStorage>;
  21099. /** @hidden */
  21100. _geometry: Nullable<Geometry>;
  21101. /** @hidden */
  21102. _delayInfo: Array<string>;
  21103. /** @hidden */
  21104. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21105. /** @hidden */
  21106. _instanceDataStorage: _InstanceDataStorage;
  21107. private _effectiveMaterial;
  21108. /** @hidden */
  21109. _shouldGenerateFlatShading: boolean;
  21110. private _preActivateId;
  21111. /** @hidden */
  21112. _originalBuilderSideOrientation: number;
  21113. /**
  21114. * Use this property to change the original side orientation defined at construction time
  21115. */
  21116. overrideMaterialSideOrientation: Nullable<number>;
  21117. private _areNormalsFrozen;
  21118. private _sourcePositions;
  21119. private _sourceNormals;
  21120. private _source;
  21121. private meshMap;
  21122. /**
  21123. * Gets the source mesh (the one used to clone this one from)
  21124. */
  21125. readonly source: Nullable<Mesh>;
  21126. /**
  21127. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21128. */
  21129. isUnIndexed: boolean;
  21130. /**
  21131. * @constructor
  21132. * @param name The value used by scene.getMeshByName() to do a lookup.
  21133. * @param scene The scene to add this mesh to.
  21134. * @param parent The parent of this mesh, if it has one
  21135. * @param source An optional Mesh from which geometry is shared, cloned.
  21136. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21137. * When false, achieved by calling a clone(), also passing False.
  21138. * This will make creation of children, recursive.
  21139. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21140. */
  21141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21142. /**
  21143. * Gets the class name
  21144. * @returns the string "Mesh".
  21145. */
  21146. getClassName(): string;
  21147. /** @hidden */
  21148. readonly _isMesh: boolean;
  21149. /**
  21150. * Returns a description of this mesh
  21151. * @param fullDetails define if full details about this mesh must be used
  21152. * @returns a descriptive string representing this mesh
  21153. */
  21154. toString(fullDetails?: boolean): string;
  21155. /** @hidden */
  21156. _unBindEffect(): void;
  21157. /**
  21158. * Gets a boolean indicating if this mesh has LOD
  21159. */
  21160. readonly hasLODLevels: boolean;
  21161. /**
  21162. * Gets the list of MeshLODLevel associated with the current mesh
  21163. * @returns an array of MeshLODLevel
  21164. */
  21165. getLODLevels(): MeshLODLevel[];
  21166. private _sortLODLevels;
  21167. /**
  21168. * Add a mesh as LOD level triggered at the given distance.
  21169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21170. * @param distance The distance from the center of the object to show this level
  21171. * @param mesh The mesh to be added as LOD level (can be null)
  21172. * @return This mesh (for chaining)
  21173. */
  21174. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21175. /**
  21176. * Returns the LOD level mesh at the passed distance or null if not found.
  21177. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21178. * @param distance The distance from the center of the object to show this level
  21179. * @returns a Mesh or `null`
  21180. */
  21181. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21182. /**
  21183. * Remove a mesh from the LOD array
  21184. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21185. * @param mesh defines the mesh to be removed
  21186. * @return This mesh (for chaining)
  21187. */
  21188. removeLODLevel(mesh: Mesh): Mesh;
  21189. /**
  21190. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21192. * @param camera defines the camera to use to compute distance
  21193. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21194. * @return This mesh (for chaining)
  21195. */
  21196. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21197. /**
  21198. * Gets the mesh internal Geometry object
  21199. */
  21200. readonly geometry: Nullable<Geometry>;
  21201. /**
  21202. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21203. * @returns the total number of vertices
  21204. */
  21205. getTotalVertices(): number;
  21206. /**
  21207. * Returns the content of an associated vertex buffer
  21208. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21209. * - VertexBuffer.PositionKind
  21210. * - VertexBuffer.UVKind
  21211. * - VertexBuffer.UV2Kind
  21212. * - VertexBuffer.UV3Kind
  21213. * - VertexBuffer.UV4Kind
  21214. * - VertexBuffer.UV5Kind
  21215. * - VertexBuffer.UV6Kind
  21216. * - VertexBuffer.ColorKind
  21217. * - VertexBuffer.MatricesIndicesKind
  21218. * - VertexBuffer.MatricesIndicesExtraKind
  21219. * - VertexBuffer.MatricesWeightsKind
  21220. * - VertexBuffer.MatricesWeightsExtraKind
  21221. * @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
  21222. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21223. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21224. */
  21225. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21226. /**
  21227. * Returns the mesh VertexBuffer object from the requested `kind`
  21228. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21229. * - VertexBuffer.PositionKind
  21230. * - VertexBuffer.UVKind
  21231. * - VertexBuffer.UV2Kind
  21232. * - VertexBuffer.UV3Kind
  21233. * - VertexBuffer.UV4Kind
  21234. * - VertexBuffer.UV5Kind
  21235. * - VertexBuffer.UV6Kind
  21236. * - VertexBuffer.ColorKind
  21237. * - VertexBuffer.MatricesIndicesKind
  21238. * - VertexBuffer.MatricesIndicesExtraKind
  21239. * - VertexBuffer.MatricesWeightsKind
  21240. * - VertexBuffer.MatricesWeightsExtraKind
  21241. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21242. */
  21243. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21244. /**
  21245. * Tests if a specific vertex buffer is associated with this mesh
  21246. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21247. * - VertexBuffer.PositionKind
  21248. * - VertexBuffer.UVKind
  21249. * - VertexBuffer.UV2Kind
  21250. * - VertexBuffer.UV3Kind
  21251. * - VertexBuffer.UV4Kind
  21252. * - VertexBuffer.UV5Kind
  21253. * - VertexBuffer.UV6Kind
  21254. * - VertexBuffer.ColorKind
  21255. * - VertexBuffer.MatricesIndicesKind
  21256. * - VertexBuffer.MatricesIndicesExtraKind
  21257. * - VertexBuffer.MatricesWeightsKind
  21258. * - VertexBuffer.MatricesWeightsExtraKind
  21259. * @returns a boolean
  21260. */
  21261. isVerticesDataPresent(kind: string): boolean;
  21262. /**
  21263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21265. * - VertexBuffer.PositionKind
  21266. * - VertexBuffer.UVKind
  21267. * - VertexBuffer.UV2Kind
  21268. * - VertexBuffer.UV3Kind
  21269. * - VertexBuffer.UV4Kind
  21270. * - VertexBuffer.UV5Kind
  21271. * - VertexBuffer.UV6Kind
  21272. * - VertexBuffer.ColorKind
  21273. * - VertexBuffer.MatricesIndicesKind
  21274. * - VertexBuffer.MatricesIndicesExtraKind
  21275. * - VertexBuffer.MatricesWeightsKind
  21276. * - VertexBuffer.MatricesWeightsExtraKind
  21277. * @returns a boolean
  21278. */
  21279. isVertexBufferUpdatable(kind: string): boolean;
  21280. /**
  21281. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21282. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21283. * - VertexBuffer.PositionKind
  21284. * - VertexBuffer.UVKind
  21285. * - VertexBuffer.UV2Kind
  21286. * - VertexBuffer.UV3Kind
  21287. * - VertexBuffer.UV4Kind
  21288. * - VertexBuffer.UV5Kind
  21289. * - VertexBuffer.UV6Kind
  21290. * - VertexBuffer.ColorKind
  21291. * - VertexBuffer.MatricesIndicesKind
  21292. * - VertexBuffer.MatricesIndicesExtraKind
  21293. * - VertexBuffer.MatricesWeightsKind
  21294. * - VertexBuffer.MatricesWeightsExtraKind
  21295. * @returns an array of strings
  21296. */
  21297. getVerticesDataKinds(): string[];
  21298. /**
  21299. * Returns a positive integer : the total number of indices in this mesh geometry.
  21300. * @returns the numner of indices or zero if the mesh has no geometry.
  21301. */
  21302. getTotalIndices(): number;
  21303. /**
  21304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21305. * @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.
  21306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21307. * @returns the indices array or an empty array if the mesh has no geometry
  21308. */
  21309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21310. readonly isBlocked: boolean;
  21311. /**
  21312. * Determine if the current mesh is ready to be rendered
  21313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21314. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21315. * @returns true if all associated assets are ready (material, textures, shaders)
  21316. */
  21317. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21318. /**
  21319. * 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.
  21320. */
  21321. readonly areNormalsFrozen: boolean;
  21322. /**
  21323. * 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.
  21324. * @returns the current mesh
  21325. */
  21326. freezeNormals(): Mesh;
  21327. /**
  21328. * 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
  21329. * @returns the current mesh
  21330. */
  21331. unfreezeNormals(): Mesh;
  21332. /**
  21333. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21334. */
  21335. overridenInstanceCount: number;
  21336. /** @hidden */
  21337. _preActivate(): Mesh;
  21338. /** @hidden */
  21339. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21340. /** @hidden */
  21341. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21342. /**
  21343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21344. * This means the mesh underlying bounding box and sphere are recomputed.
  21345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21346. * @returns the current mesh
  21347. */
  21348. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21349. /** @hidden */
  21350. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21351. /**
  21352. * This function will subdivide the mesh into multiple submeshes
  21353. * @param count defines the expected number of submeshes
  21354. */
  21355. subdivide(count: number): void;
  21356. /**
  21357. * Copy a FloatArray into a specific associated vertex buffer
  21358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21359. * - VertexBuffer.PositionKind
  21360. * - VertexBuffer.UVKind
  21361. * - VertexBuffer.UV2Kind
  21362. * - VertexBuffer.UV3Kind
  21363. * - VertexBuffer.UV4Kind
  21364. * - VertexBuffer.UV5Kind
  21365. * - VertexBuffer.UV6Kind
  21366. * - VertexBuffer.ColorKind
  21367. * - VertexBuffer.MatricesIndicesKind
  21368. * - VertexBuffer.MatricesIndicesExtraKind
  21369. * - VertexBuffer.MatricesWeightsKind
  21370. * - VertexBuffer.MatricesWeightsExtraKind
  21371. * @param data defines the data source
  21372. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21373. * @param stride defines the data stride size (can be null)
  21374. * @returns the current mesh
  21375. */
  21376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21377. /**
  21378. * Flags an associated vertex buffer as updatable
  21379. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21380. * - VertexBuffer.PositionKind
  21381. * - VertexBuffer.UVKind
  21382. * - VertexBuffer.UV2Kind
  21383. * - VertexBuffer.UV3Kind
  21384. * - VertexBuffer.UV4Kind
  21385. * - VertexBuffer.UV5Kind
  21386. * - VertexBuffer.UV6Kind
  21387. * - VertexBuffer.ColorKind
  21388. * - VertexBuffer.MatricesIndicesKind
  21389. * - VertexBuffer.MatricesIndicesExtraKind
  21390. * - VertexBuffer.MatricesWeightsKind
  21391. * - VertexBuffer.MatricesWeightsExtraKind
  21392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21393. */
  21394. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21395. /**
  21396. * Sets the mesh global Vertex Buffer
  21397. * @param buffer defines the buffer to use
  21398. * @returns the current mesh
  21399. */
  21400. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21401. /**
  21402. * Update a specific associated vertex buffer
  21403. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21404. * - VertexBuffer.PositionKind
  21405. * - VertexBuffer.UVKind
  21406. * - VertexBuffer.UV2Kind
  21407. * - VertexBuffer.UV3Kind
  21408. * - VertexBuffer.UV4Kind
  21409. * - VertexBuffer.UV5Kind
  21410. * - VertexBuffer.UV6Kind
  21411. * - VertexBuffer.ColorKind
  21412. * - VertexBuffer.MatricesIndicesKind
  21413. * - VertexBuffer.MatricesIndicesExtraKind
  21414. * - VertexBuffer.MatricesWeightsKind
  21415. * - VertexBuffer.MatricesWeightsExtraKind
  21416. * @param data defines the data source
  21417. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21418. * @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)
  21419. * @returns the current mesh
  21420. */
  21421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21422. /**
  21423. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21424. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21425. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21426. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21427. * @returns the current mesh
  21428. */
  21429. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21430. /**
  21431. * Creates a un-shared specific occurence of the geometry for the mesh.
  21432. * @returns the current mesh
  21433. */
  21434. makeGeometryUnique(): Mesh;
  21435. /**
  21436. * Set the index buffer of this mesh
  21437. * @param indices defines the source data
  21438. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21439. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21440. * @returns the current mesh
  21441. */
  21442. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21443. /**
  21444. * Update the current index buffer
  21445. * @param indices defines the source data
  21446. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21447. * @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)
  21448. * @returns the current mesh
  21449. */
  21450. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21451. /**
  21452. * Invert the geometry to move from a right handed system to a left handed one.
  21453. * @returns the current mesh
  21454. */
  21455. toLeftHanded(): Mesh;
  21456. /** @hidden */
  21457. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21458. /** @hidden */
  21459. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21460. /**
  21461. * Registers for this mesh a javascript function called just before the rendering process
  21462. * @param func defines the function to call before rendering this mesh
  21463. * @returns the current mesh
  21464. */
  21465. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21466. /**
  21467. * Disposes a previously registered javascript function called before the rendering
  21468. * @param func defines the function to remove
  21469. * @returns the current mesh
  21470. */
  21471. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21472. /**
  21473. * Registers for this mesh a javascript function called just after the rendering is complete
  21474. * @param func defines the function to call after rendering this mesh
  21475. * @returns the current mesh
  21476. */
  21477. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21478. /**
  21479. * Disposes a previously registered javascript function called after the rendering.
  21480. * @param func defines the function to remove
  21481. * @returns the current mesh
  21482. */
  21483. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21484. /** @hidden */
  21485. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21486. /** @hidden */
  21487. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21488. /** @hidden */
  21489. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21490. /**
  21491. * 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
  21492. * @param subMesh defines the subMesh to render
  21493. * @param enableAlphaMode defines if alpha mode can be changed
  21494. * @returns the current mesh
  21495. */
  21496. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21497. private _onBeforeDraw;
  21498. /**
  21499. * Renormalize the mesh and patch it up if there are no weights
  21500. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21501. * However in the case of zero weights then we set just a single influence to 1.
  21502. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21503. */
  21504. cleanMatrixWeights(): void;
  21505. private normalizeSkinFourWeights;
  21506. private normalizeSkinWeightsAndExtra;
  21507. /**
  21508. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21509. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21510. * the user know there was an issue with importing the mesh
  21511. * @returns a validation object with skinned, valid and report string
  21512. */
  21513. validateSkinning(): {
  21514. skinned: boolean;
  21515. valid: boolean;
  21516. report: string;
  21517. };
  21518. /** @hidden */
  21519. _checkDelayState(): Mesh;
  21520. private _queueLoad;
  21521. /**
  21522. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21523. * A mesh is in the frustum if its bounding box intersects the frustum
  21524. * @param frustumPlanes defines the frustum to test
  21525. * @returns true if the mesh is in the frustum planes
  21526. */
  21527. isInFrustum(frustumPlanes: Plane[]): boolean;
  21528. /**
  21529. * Sets the mesh material by the material or multiMaterial `id` property
  21530. * @param id is a string identifying the material or the multiMaterial
  21531. * @returns the current mesh
  21532. */
  21533. setMaterialByID(id: string): Mesh;
  21534. /**
  21535. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21536. * @returns an array of IAnimatable
  21537. */
  21538. getAnimatables(): IAnimatable[];
  21539. /**
  21540. * Modifies the mesh geometry according to the passed transformation matrix.
  21541. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21542. * The mesh normals are modified using the same transformation.
  21543. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21544. * @param transform defines the transform matrix to use
  21545. * @see http://doc.babylonjs.com/resources/baking_transformations
  21546. * @returns the current mesh
  21547. */
  21548. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21549. /**
  21550. * Modifies the mesh geometry according to its own current World Matrix.
  21551. * The mesh World Matrix is then reset.
  21552. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21553. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21554. * @see http://doc.babylonjs.com/resources/baking_transformations
  21555. * @returns the current mesh
  21556. */
  21557. bakeCurrentTransformIntoVertices(): Mesh;
  21558. /** @hidden */
  21559. readonly _positions: Nullable<Vector3[]>;
  21560. /** @hidden */
  21561. _resetPointsArrayCache(): Mesh;
  21562. /** @hidden */
  21563. _generatePointsArray(): boolean;
  21564. /**
  21565. * Returns a new Mesh object generated from the current mesh properties.
  21566. * This method must not get confused with createInstance()
  21567. * @param name is a string, the name given to the new mesh
  21568. * @param newParent can be any Node object (default `null`)
  21569. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21570. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21571. * @returns a new mesh
  21572. */
  21573. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21574. /**
  21575. * Releases resources associated with this mesh.
  21576. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21577. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21578. */
  21579. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21580. /**
  21581. * Modifies the mesh geometry according to a displacement map.
  21582. * 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.
  21583. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21584. * @param url is a string, the URL from the image file is to be downloaded.
  21585. * @param minHeight is the lower limit of the displacement.
  21586. * @param maxHeight is the upper limit of the displacement.
  21587. * @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.
  21588. * @param uvOffset is an optional vector2 used to offset UV.
  21589. * @param uvScale is an optional vector2 used to scale UV.
  21590. * @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.
  21591. * @returns the Mesh.
  21592. */
  21593. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21594. /**
  21595. * Modifies the mesh geometry according to a displacementMap buffer.
  21596. * 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.
  21597. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21598. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21599. * @param heightMapWidth is the width of the buffer image.
  21600. * @param heightMapHeight is the height of the buffer image.
  21601. * @param minHeight is the lower limit of the displacement.
  21602. * @param maxHeight is the upper limit of the displacement.
  21603. * @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.
  21604. * @param uvOffset is an optional vector2 used to offset UV.
  21605. * @param uvScale is an optional vector2 used to scale UV.
  21606. * @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.
  21607. * @returns the Mesh.
  21608. */
  21609. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21610. /**
  21611. * Modify the mesh to get a flat shading rendering.
  21612. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21613. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21614. * @returns current mesh
  21615. */
  21616. convertToFlatShadedMesh(): Mesh;
  21617. /**
  21618. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21619. * In other words, more vertices, no more indices and a single bigger VBO.
  21620. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21621. * @returns current mesh
  21622. */
  21623. convertToUnIndexedMesh(): Mesh;
  21624. /**
  21625. * Inverses facet orientations.
  21626. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21627. * @param flipNormals will also inverts the normals
  21628. * @returns current mesh
  21629. */
  21630. flipFaces(flipNormals?: boolean): Mesh;
  21631. /**
  21632. * Increase the number of facets and hence vertices in a mesh
  21633. * Vertex normals are interpolated from existing vertex normals
  21634. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21635. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21636. */
  21637. increaseVertices(numberPerEdge: number): void;
  21638. /**
  21639. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21640. * This will undo any application of covertToFlatShadedMesh
  21641. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21642. */
  21643. forceSharedVertices(): void;
  21644. /** @hidden */
  21645. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21646. /** @hidden */
  21647. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21648. /**
  21649. * Creates a new InstancedMesh object from the mesh model.
  21650. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21651. * @param name defines the name of the new instance
  21652. * @returns a new InstancedMesh
  21653. */
  21654. createInstance(name: string): InstancedMesh;
  21655. /**
  21656. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21657. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21658. * @returns the current mesh
  21659. */
  21660. synchronizeInstances(): Mesh;
  21661. /**
  21662. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21663. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21664. * This should be used together with the simplification to avoid disappearing triangles.
  21665. * @param successCallback an optional success callback to be called after the optimization finished.
  21666. * @returns the current mesh
  21667. */
  21668. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21669. /**
  21670. * Serialize current mesh
  21671. * @param serializationObject defines the object which will receive the serialization data
  21672. */
  21673. serialize(serializationObject: any): void;
  21674. /** @hidden */
  21675. _syncGeometryWithMorphTargetManager(): void;
  21676. /** @hidden */
  21677. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21678. /**
  21679. * Returns a new Mesh object parsed from the source provided.
  21680. * @param parsedMesh is the source
  21681. * @param scene defines the hosting scene
  21682. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21683. * @returns a new Mesh
  21684. */
  21685. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21686. /**
  21687. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21688. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21689. * @param name defines the name of the mesh to create
  21690. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21691. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21692. * @param closePath creates a seam between the first and the last points of each path of the path array
  21693. * @param offset is taken in account only if the `pathArray` is containing a single path
  21694. * @param scene defines the hosting scene
  21695. * @param updatable defines if the mesh must be flagged as updatable
  21696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21697. * @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)
  21698. * @returns a new Mesh
  21699. */
  21700. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21701. /**
  21702. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21703. * @param name defines the name of the mesh to create
  21704. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21705. * @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
  21706. * @param scene defines the hosting scene
  21707. * @param updatable defines if the mesh must be flagged as updatable
  21708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21709. * @returns a new Mesh
  21710. */
  21711. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21712. /**
  21713. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21714. * @param name defines the name of the mesh to create
  21715. * @param size sets the size (float) of each box side (default 1)
  21716. * @param scene defines the hosting scene
  21717. * @param updatable defines if the mesh must be flagged as updatable
  21718. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21719. * @returns a new Mesh
  21720. */
  21721. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21722. /**
  21723. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21724. * @param name defines the name of the mesh to create
  21725. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21726. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21727. * @param scene defines the hosting scene
  21728. * @param updatable defines if the mesh must be flagged as updatable
  21729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21730. * @returns a new Mesh
  21731. */
  21732. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21733. /**
  21734. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21735. * @param name defines the name of the mesh to create
  21736. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21737. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21738. * @param scene defines the hosting scene
  21739. * @returns a new Mesh
  21740. */
  21741. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21742. /**
  21743. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  21746. * @param diameterTop set the top cap diameter (floats, default 1)
  21747. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21748. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21749. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21750. * @param scene defines the hosting scene
  21751. * @param updatable defines if the mesh must be flagged as updatable
  21752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21753. * @returns a new Mesh
  21754. */
  21755. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21756. /**
  21757. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21758. * @param name defines the name of the mesh to create
  21759. * @param diameter sets the diameter size (float) of the torus (default 1)
  21760. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21761. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21762. * @param scene defines the hosting scene
  21763. * @param updatable defines if the mesh must be flagged as updatable
  21764. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21765. * @returns a new Mesh
  21766. */
  21767. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21768. /**
  21769. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21770. * @param name defines the name of the mesh to create
  21771. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21772. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21773. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21774. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21775. * @param p the number of windings on X axis (positive integers, default 2)
  21776. * @param q the number of windings on Y axis (positive integers, default 3)
  21777. * @param scene defines the hosting scene
  21778. * @param updatable defines if the mesh must be flagged as updatable
  21779. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21780. * @returns a new Mesh
  21781. */
  21782. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21783. /**
  21784. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21785. * @param name defines the name of the mesh to create
  21786. * @param points is an array successive Vector3
  21787. * @param scene defines the hosting scene
  21788. * @param updatable defines if the mesh must be flagged as updatable
  21789. * @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).
  21790. * @returns a new Mesh
  21791. */
  21792. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21793. /**
  21794. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21795. * @param name defines the name of the mesh to create
  21796. * @param points is an array successive Vector3
  21797. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21798. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21799. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21800. * @param scene defines the hosting scene
  21801. * @param updatable defines if the mesh must be flagged as updatable
  21802. * @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)
  21803. * @returns a new Mesh
  21804. */
  21805. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21806. /**
  21807. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21808. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21809. * 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.
  21810. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21811. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21812. * Remember you can only change the shape positions, not their number when updating a polygon.
  21813. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21814. * @param name defines the name of the mesh to create
  21815. * @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
  21816. * @param scene defines the hosting scene
  21817. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21818. * @param updatable defines if the mesh must be flagged as updatable
  21819. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21820. * @param earcutInjection can be used to inject your own earcut reference
  21821. * @returns a new Mesh
  21822. */
  21823. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21824. /**
  21825. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21826. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21827. * @param name defines the name of the mesh to create
  21828. * @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
  21829. * @param depth defines the height of extrusion
  21830. * @param scene defines the hosting scene
  21831. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21832. * @param updatable defines if the mesh must be flagged as updatable
  21833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21834. * @param earcutInjection can be used to inject your own earcut reference
  21835. * @returns a new Mesh
  21836. */
  21837. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21838. /**
  21839. * Creates an extruded shape mesh.
  21840. * 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
  21841. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21842. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21843. * @param name defines the name of the mesh to create
  21844. * @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
  21845. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21846. * @param scale is the value to scale the shape
  21847. * @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
  21848. * @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
  21849. * @param scene defines the hosting scene
  21850. * @param updatable defines if the mesh must be flagged as updatable
  21851. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21852. * @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)
  21853. * @returns a new Mesh
  21854. */
  21855. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21856. /**
  21857. * Creates an custom extruded shape mesh.
  21858. * The custom extrusion is a parametric shape.
  21859. * It has no predefined shape. Its final shape will depend on the input parameters.
  21860. * Please consider using the same method from the MeshBuilder class instead
  21861. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21862. * @param name defines the name of the mesh to create
  21863. * @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
  21864. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21865. * @param scaleFunction is a custom Javascript function called on each path point
  21866. * @param rotationFunction is a custom Javascript function called on each path point
  21867. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21868. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21869. * @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
  21870. * @param scene defines the hosting scene
  21871. * @param updatable defines if the mesh must be flagged as updatable
  21872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21873. * @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)
  21874. * @returns a new Mesh
  21875. */
  21876. 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;
  21877. /**
  21878. * Creates lathe mesh.
  21879. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21880. * Please consider using the same method from the MeshBuilder class instead
  21881. * @param name defines the name of the mesh to create
  21882. * @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
  21883. * @param radius is the radius value of the lathe
  21884. * @param tessellation is the side number of the lathe.
  21885. * @param scene defines the hosting scene
  21886. * @param updatable defines if the mesh must be flagged as updatable
  21887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21888. * @returns a new Mesh
  21889. */
  21890. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21891. /**
  21892. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21893. * @param name defines the name of the mesh to create
  21894. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21895. * @param scene defines the hosting scene
  21896. * @param updatable defines if the mesh must be flagged as updatable
  21897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21898. * @returns a new Mesh
  21899. */
  21900. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21901. /**
  21902. * Creates a ground mesh.
  21903. * Please consider using the same method from the MeshBuilder class instead
  21904. * @param name defines the name of the mesh to create
  21905. * @param width set the width of the ground
  21906. * @param height set the height of the ground
  21907. * @param subdivisions sets the number of subdivisions per side
  21908. * @param scene defines the hosting scene
  21909. * @param updatable defines if the mesh must be flagged as updatable
  21910. * @returns a new Mesh
  21911. */
  21912. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21913. /**
  21914. * Creates a tiled ground mesh.
  21915. * Please consider using the same method from the MeshBuilder class instead
  21916. * @param name defines the name of the mesh to create
  21917. * @param xmin set the ground minimum X coordinate
  21918. * @param zmin set the ground minimum Y coordinate
  21919. * @param xmax set the ground maximum X coordinate
  21920. * @param zmax set the ground maximum Z coordinate
  21921. * @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
  21922. * @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
  21923. * @param scene defines the hosting scene
  21924. * @param updatable defines if the mesh must be flagged as updatable
  21925. * @returns a new Mesh
  21926. */
  21927. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21928. w: number;
  21929. h: number;
  21930. }, precision: {
  21931. w: number;
  21932. h: number;
  21933. }, scene: Scene, updatable?: boolean): Mesh;
  21934. /**
  21935. * Creates a ground mesh from a height map.
  21936. * Please consider using the same method from the MeshBuilder class instead
  21937. * @see http://doc.babylonjs.com/babylon101/height_map
  21938. * @param name defines the name of the mesh to create
  21939. * @param url sets the URL of the height map image resource
  21940. * @param width set the ground width size
  21941. * @param height set the ground height size
  21942. * @param subdivisions sets the number of subdivision per side
  21943. * @param minHeight is the minimum altitude on the ground
  21944. * @param maxHeight is the maximum altitude on the ground
  21945. * @param scene defines the hosting scene
  21946. * @param updatable defines if the mesh must be flagged as updatable
  21947. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21948. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21949. * @returns a new Mesh
  21950. */
  21951. 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;
  21952. /**
  21953. * Creates a tube mesh.
  21954. * The tube is a parametric shape.
  21955. * It has no predefined shape. Its final shape will depend on the input parameters.
  21956. * Please consider using the same method from the MeshBuilder class instead
  21957. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21958. * @param name defines the name of the mesh to create
  21959. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21960. * @param radius sets the tube radius size
  21961. * @param tessellation is the number of sides on the tubular surface
  21962. * @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
  21963. * @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
  21964. * @param scene defines the hosting scene
  21965. * @param updatable defines if the mesh must be flagged as updatable
  21966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21967. * @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)
  21968. * @returns a new Mesh
  21969. */
  21970. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21971. (i: number, distance: number): number;
  21972. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21973. /**
  21974. * Creates a polyhedron mesh.
  21975. * Please consider using the same method from the MeshBuilder class instead.
  21976. * * 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
  21977. * * The parameter `size` (positive float, default 1) sets the polygon size
  21978. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21979. * * 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`
  21980. * * 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
  21981. * * 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)`)
  21982. * * 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
  21983. * * 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
  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 to create
  21988. * @param options defines the options used to create the mesh
  21989. * @param scene defines the hosting scene
  21990. * @returns a new Mesh
  21991. */
  21992. static CreatePolyhedron(name: string, options: {
  21993. type?: number;
  21994. size?: number;
  21995. sizeX?: number;
  21996. sizeY?: number;
  21997. sizeZ?: number;
  21998. custom?: any;
  21999. faceUV?: Vector4[];
  22000. faceColors?: Color4[];
  22001. updatable?: boolean;
  22002. sideOrientation?: number;
  22003. }, scene: Scene): Mesh;
  22004. /**
  22005. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22006. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22007. * * 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`)
  22008. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22009. * * 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
  22010. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22011. * * If you create a double-sided mesh, you can choose what parts of 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
  22012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22013. * @param name defines the name of the mesh
  22014. * @param options defines the options used to create the mesh
  22015. * @param scene defines the hosting scene
  22016. * @returns a new Mesh
  22017. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22018. */
  22019. static CreateIcoSphere(name: string, options: {
  22020. radius?: number;
  22021. flat?: boolean;
  22022. subdivisions?: number;
  22023. sideOrientation?: number;
  22024. updatable?: boolean;
  22025. }, scene: Scene): Mesh;
  22026. /**
  22027. * Creates a decal mesh.
  22028. * Please consider using the same method from the MeshBuilder class instead.
  22029. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22030. * @param name defines the name of the mesh
  22031. * @param sourceMesh defines the mesh receiving the decal
  22032. * @param position sets the position of the decal in world coordinates
  22033. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22034. * @param size sets the decal scaling
  22035. * @param angle sets the angle to rotate the decal
  22036. * @returns a new Mesh
  22037. */
  22038. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22039. /**
  22040. * Prepare internal position array for software CPU skinning
  22041. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22042. */
  22043. setPositionsForCPUSkinning(): Float32Array;
  22044. /**
  22045. * Prepare internal normal array for software CPU skinning
  22046. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22047. */
  22048. setNormalsForCPUSkinning(): Float32Array;
  22049. /**
  22050. * Updates the vertex buffer by applying transformation from the bones
  22051. * @param skeleton defines the skeleton to apply to current mesh
  22052. * @returns the current mesh
  22053. */
  22054. applySkeleton(skeleton: Skeleton): Mesh;
  22055. /**
  22056. * 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
  22057. * @param meshes defines the list of meshes to scan
  22058. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22059. */
  22060. static MinMax(meshes: AbstractMesh[]): {
  22061. min: Vector3;
  22062. max: Vector3;
  22063. };
  22064. /**
  22065. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22066. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22067. * @returns a vector3
  22068. */
  22069. static Center(meshesOrMinMaxVector: {
  22070. min: Vector3;
  22071. max: Vector3;
  22072. } | AbstractMesh[]): Vector3;
  22073. /**
  22074. * Merge the array of meshes into a single mesh for performance reasons.
  22075. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22076. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22077. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22078. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22079. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22080. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22081. * @returns a new mesh
  22082. */
  22083. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22084. /** @hidden */
  22085. addInstance(instance: InstancedMesh): void;
  22086. /** @hidden */
  22087. removeInstance(instance: InstancedMesh): void;
  22088. }
  22089. }
  22090. declare module "babylonjs/Materials/material" {
  22091. import { IAnimatable } from "babylonjs/Misc/tools";
  22092. import { SmartArray } from "babylonjs/Misc/smartArray";
  22093. import { Observable } from "babylonjs/Misc/observable";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { Scene } from "babylonjs/scene";
  22096. import { Matrix } from "babylonjs/Maths/math";
  22097. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22099. import { Mesh } from "babylonjs/Meshes/mesh";
  22100. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22101. import { Effect } from "babylonjs/Materials/effect";
  22102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22103. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22104. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22105. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22106. import { Animation } from "babylonjs/Animations/animation";
  22107. /**
  22108. * Base class for the main features of a material in Babylon.js
  22109. */
  22110. export class Material implements IAnimatable {
  22111. /**
  22112. * Returns the triangle fill mode
  22113. */
  22114. static readonly TriangleFillMode: number;
  22115. /**
  22116. * Returns the wireframe mode
  22117. */
  22118. static readonly WireFrameFillMode: number;
  22119. /**
  22120. * Returns the point fill mode
  22121. */
  22122. static readonly PointFillMode: number;
  22123. /**
  22124. * Returns the point list draw mode
  22125. */
  22126. static readonly PointListDrawMode: number;
  22127. /**
  22128. * Returns the line list draw mode
  22129. */
  22130. static readonly LineListDrawMode: number;
  22131. /**
  22132. * Returns the line loop draw mode
  22133. */
  22134. static readonly LineLoopDrawMode: number;
  22135. /**
  22136. * Returns the line strip draw mode
  22137. */
  22138. static readonly LineStripDrawMode: number;
  22139. /**
  22140. * Returns the triangle strip draw mode
  22141. */
  22142. static readonly TriangleStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle fan draw mode
  22145. */
  22146. static readonly TriangleFanDrawMode: number;
  22147. /**
  22148. * Stores the clock-wise side orientation
  22149. */
  22150. static readonly ClockWiseSideOrientation: number;
  22151. /**
  22152. * Stores the counter clock-wise side orientation
  22153. */
  22154. static readonly CounterClockWiseSideOrientation: number;
  22155. /**
  22156. * The dirty texture flag value
  22157. */
  22158. static readonly TextureDirtyFlag: number;
  22159. /**
  22160. * The dirty light flag value
  22161. */
  22162. static readonly LightDirtyFlag: number;
  22163. /**
  22164. * The dirty fresnel flag value
  22165. */
  22166. static readonly FresnelDirtyFlag: number;
  22167. /**
  22168. * The dirty attribute flag value
  22169. */
  22170. static readonly AttributesDirtyFlag: number;
  22171. /**
  22172. * The dirty misc flag value
  22173. */
  22174. static readonly MiscDirtyFlag: number;
  22175. /**
  22176. * The all dirty flag value
  22177. */
  22178. static readonly AllDirtyFlag: number;
  22179. /**
  22180. * The ID of the material
  22181. */
  22182. id: string;
  22183. /**
  22184. * Gets or sets the unique id of the material
  22185. */
  22186. uniqueId: number;
  22187. /**
  22188. * The name of the material
  22189. */
  22190. name: string;
  22191. /**
  22192. * Gets or sets user defined metadata
  22193. */
  22194. metadata: any;
  22195. /**
  22196. * For internal use only. Please do not use.
  22197. */
  22198. reservedDataStore: any;
  22199. /**
  22200. * Specifies if the ready state should be checked on each call
  22201. */
  22202. checkReadyOnEveryCall: boolean;
  22203. /**
  22204. * Specifies if the ready state should be checked once
  22205. */
  22206. checkReadyOnlyOnce: boolean;
  22207. /**
  22208. * The state of the material
  22209. */
  22210. state: string;
  22211. /**
  22212. * The alpha value of the material
  22213. */
  22214. protected _alpha: number;
  22215. /**
  22216. * List of inspectable custom properties (used by the Inspector)
  22217. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22218. */
  22219. inspectableCustomProperties: IInspectable[];
  22220. /**
  22221. * Sets the alpha value of the material
  22222. */
  22223. /**
  22224. * Gets the alpha value of the material
  22225. */
  22226. alpha: number;
  22227. /**
  22228. * Specifies if back face culling is enabled
  22229. */
  22230. protected _backFaceCulling: boolean;
  22231. /**
  22232. * Sets the back-face culling state
  22233. */
  22234. /**
  22235. * Gets the back-face culling state
  22236. */
  22237. backFaceCulling: boolean;
  22238. /**
  22239. * Stores the value for side orientation
  22240. */
  22241. sideOrientation: number;
  22242. /**
  22243. * Callback triggered when the material is compiled
  22244. */
  22245. onCompiled: (effect: Effect) => void;
  22246. /**
  22247. * Callback triggered when an error occurs
  22248. */
  22249. onError: (effect: Effect, errors: string) => void;
  22250. /**
  22251. * Callback triggered to get the render target textures
  22252. */
  22253. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22254. /**
  22255. * Gets a boolean indicating that current material needs to register RTT
  22256. */
  22257. readonly hasRenderTargetTextures: boolean;
  22258. /**
  22259. * Specifies if the material should be serialized
  22260. */
  22261. doNotSerialize: boolean;
  22262. /**
  22263. * @hidden
  22264. */
  22265. _storeEffectOnSubMeshes: boolean;
  22266. /**
  22267. * Stores the animations for the material
  22268. */
  22269. animations: Array<Animation>;
  22270. /**
  22271. * An event triggered when the material is disposed
  22272. */
  22273. onDisposeObservable: Observable<Material>;
  22274. /**
  22275. * An observer which watches for dispose events
  22276. */
  22277. private _onDisposeObserver;
  22278. private _onUnBindObservable;
  22279. /**
  22280. * Called during a dispose event
  22281. */
  22282. onDispose: () => void;
  22283. private _onBindObservable;
  22284. /**
  22285. * An event triggered when the material is bound
  22286. */
  22287. readonly onBindObservable: Observable<AbstractMesh>;
  22288. /**
  22289. * An observer which watches for bind events
  22290. */
  22291. private _onBindObserver;
  22292. /**
  22293. * Called during a bind event
  22294. */
  22295. onBind: (Mesh: AbstractMesh) => void;
  22296. /**
  22297. * An event triggered when the material is unbound
  22298. */
  22299. readonly onUnBindObservable: Observable<Material>;
  22300. /**
  22301. * Stores the value of the alpha mode
  22302. */
  22303. private _alphaMode;
  22304. /**
  22305. * Sets the value of the alpha mode.
  22306. *
  22307. * | Value | Type | Description |
  22308. * | --- | --- | --- |
  22309. * | 0 | ALPHA_DISABLE | |
  22310. * | 1 | ALPHA_ADD | |
  22311. * | 2 | ALPHA_COMBINE | |
  22312. * | 3 | ALPHA_SUBTRACT | |
  22313. * | 4 | ALPHA_MULTIPLY | |
  22314. * | 5 | ALPHA_MAXIMIZED | |
  22315. * | 6 | ALPHA_ONEONE | |
  22316. * | 7 | ALPHA_PREMULTIPLIED | |
  22317. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22318. * | 9 | ALPHA_INTERPOLATE | |
  22319. * | 10 | ALPHA_SCREENMODE | |
  22320. *
  22321. */
  22322. /**
  22323. * Gets the value of the alpha mode
  22324. */
  22325. alphaMode: number;
  22326. /**
  22327. * Stores the state of the need depth pre-pass value
  22328. */
  22329. private _needDepthPrePass;
  22330. /**
  22331. * Sets the need depth pre-pass value
  22332. */
  22333. /**
  22334. * Gets the depth pre-pass value
  22335. */
  22336. needDepthPrePass: boolean;
  22337. /**
  22338. * Specifies if depth writing should be disabled
  22339. */
  22340. disableDepthWrite: boolean;
  22341. /**
  22342. * Specifies if depth writing should be forced
  22343. */
  22344. forceDepthWrite: boolean;
  22345. /**
  22346. * Specifies if there should be a separate pass for culling
  22347. */
  22348. separateCullingPass: boolean;
  22349. /**
  22350. * Stores the state specifing if fog should be enabled
  22351. */
  22352. private _fogEnabled;
  22353. /**
  22354. * Sets the state for enabling fog
  22355. */
  22356. /**
  22357. * Gets the value of the fog enabled state
  22358. */
  22359. fogEnabled: boolean;
  22360. /**
  22361. * Stores the size of points
  22362. */
  22363. pointSize: number;
  22364. /**
  22365. * Stores the z offset value
  22366. */
  22367. zOffset: number;
  22368. /**
  22369. * Gets a value specifying if wireframe mode is enabled
  22370. */
  22371. /**
  22372. * Sets the state of wireframe mode
  22373. */
  22374. wireframe: boolean;
  22375. /**
  22376. * Gets the value specifying if point clouds are enabled
  22377. */
  22378. /**
  22379. * Sets the state of point cloud mode
  22380. */
  22381. pointsCloud: boolean;
  22382. /**
  22383. * Gets the material fill mode
  22384. */
  22385. /**
  22386. * Sets the material fill mode
  22387. */
  22388. fillMode: number;
  22389. /**
  22390. * @hidden
  22391. * Stores the effects for the material
  22392. */
  22393. _effect: Nullable<Effect>;
  22394. /**
  22395. * @hidden
  22396. * Specifies if the material was previously ready
  22397. */
  22398. _wasPreviouslyReady: boolean;
  22399. /**
  22400. * Specifies if uniform buffers should be used
  22401. */
  22402. private _useUBO;
  22403. /**
  22404. * Stores a reference to the scene
  22405. */
  22406. private _scene;
  22407. /**
  22408. * Stores the fill mode state
  22409. */
  22410. private _fillMode;
  22411. /**
  22412. * Specifies if the depth write state should be cached
  22413. */
  22414. private _cachedDepthWriteState;
  22415. /**
  22416. * Stores the uniform buffer
  22417. */
  22418. protected _uniformBuffer: UniformBuffer;
  22419. /** @hidden */
  22420. _indexInSceneMaterialArray: number;
  22421. /** @hidden */
  22422. meshMap: Nullable<{
  22423. [id: string]: AbstractMesh | undefined;
  22424. }>;
  22425. /**
  22426. * Creates a material instance
  22427. * @param name defines the name of the material
  22428. * @param scene defines the scene to reference
  22429. * @param doNotAdd specifies if the material should be added to the scene
  22430. */
  22431. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22432. /**
  22433. * Returns a string representation of the current material
  22434. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22435. * @returns a string with material information
  22436. */
  22437. toString(fullDetails?: boolean): string;
  22438. /**
  22439. * Gets the class name of the material
  22440. * @returns a string with the class name of the material
  22441. */
  22442. getClassName(): string;
  22443. /**
  22444. * Specifies if updates for the material been locked
  22445. */
  22446. readonly isFrozen: boolean;
  22447. /**
  22448. * Locks updates for the material
  22449. */
  22450. freeze(): void;
  22451. /**
  22452. * Unlocks updates for the material
  22453. */
  22454. unfreeze(): void;
  22455. /**
  22456. * Specifies if the material is ready to be used
  22457. * @param mesh defines the mesh to check
  22458. * @param useInstances specifies if instances should be used
  22459. * @returns a boolean indicating if the material is ready to be used
  22460. */
  22461. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22462. /**
  22463. * Specifies that the submesh is ready to be used
  22464. * @param mesh defines the mesh to check
  22465. * @param subMesh defines which submesh to check
  22466. * @param useInstances specifies that instances should be used
  22467. * @returns a boolean indicating that the submesh is ready or not
  22468. */
  22469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22470. /**
  22471. * Returns the material effect
  22472. * @returns the effect associated with the material
  22473. */
  22474. getEffect(): Nullable<Effect>;
  22475. /**
  22476. * Returns the current scene
  22477. * @returns a Scene
  22478. */
  22479. getScene(): Scene;
  22480. /**
  22481. * Specifies if the material will require alpha blending
  22482. * @returns a boolean specifying if alpha blending is needed
  22483. */
  22484. needAlphaBlending(): boolean;
  22485. /**
  22486. * Specifies if the mesh will require alpha blending
  22487. * @param mesh defines the mesh to check
  22488. * @returns a boolean specifying if alpha blending is needed for the mesh
  22489. */
  22490. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22491. /**
  22492. * Specifies if this material should be rendered in alpha test mode
  22493. * @returns a boolean specifying if an alpha test is needed.
  22494. */
  22495. needAlphaTesting(): boolean;
  22496. /**
  22497. * Gets the texture used for the alpha test
  22498. * @returns the texture to use for alpha testing
  22499. */
  22500. getAlphaTestTexture(): Nullable<BaseTexture>;
  22501. /**
  22502. * Marks the material to indicate that it needs to be re-calculated
  22503. */
  22504. markDirty(): void;
  22505. /** @hidden */
  22506. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22507. /**
  22508. * Binds the material to the mesh
  22509. * @param world defines the world transformation matrix
  22510. * @param mesh defines the mesh to bind the material to
  22511. */
  22512. bind(world: Matrix, mesh?: Mesh): void;
  22513. /**
  22514. * Binds the submesh to the material
  22515. * @param world defines the world transformation matrix
  22516. * @param mesh defines the mesh containing the submesh
  22517. * @param subMesh defines the submesh to bind the material to
  22518. */
  22519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22520. /**
  22521. * Binds the world matrix to the material
  22522. * @param world defines the world transformation matrix
  22523. */
  22524. bindOnlyWorldMatrix(world: Matrix): void;
  22525. /**
  22526. * Binds the scene's uniform buffer to the effect.
  22527. * @param effect defines the effect to bind to the scene uniform buffer
  22528. * @param sceneUbo defines the uniform buffer storing scene data
  22529. */
  22530. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22531. /**
  22532. * Binds the view matrix to the effect
  22533. * @param effect defines the effect to bind the view matrix to
  22534. */
  22535. bindView(effect: Effect): void;
  22536. /**
  22537. * Binds the view projection matrix to the effect
  22538. * @param effect defines the effect to bind the view projection matrix to
  22539. */
  22540. bindViewProjection(effect: Effect): void;
  22541. /**
  22542. * Specifies if material alpha testing should be turned on for the mesh
  22543. * @param mesh defines the mesh to check
  22544. */
  22545. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22546. /**
  22547. * Processes to execute after binding the material to a mesh
  22548. * @param mesh defines the rendered mesh
  22549. */
  22550. protected _afterBind(mesh?: Mesh): void;
  22551. /**
  22552. * Unbinds the material from the mesh
  22553. */
  22554. unbind(): void;
  22555. /**
  22556. * Gets the active textures from the material
  22557. * @returns an array of textures
  22558. */
  22559. getActiveTextures(): BaseTexture[];
  22560. /**
  22561. * Specifies if the material uses a texture
  22562. * @param texture defines the texture to check against the material
  22563. * @returns a boolean specifying if the material uses the texture
  22564. */
  22565. hasTexture(texture: BaseTexture): boolean;
  22566. /**
  22567. * Makes a duplicate of the material, and gives it a new name
  22568. * @param name defines the new name for the duplicated material
  22569. * @returns the cloned material
  22570. */
  22571. clone(name: string): Nullable<Material>;
  22572. /**
  22573. * Gets the meshes bound to the material
  22574. * @returns an array of meshes bound to the material
  22575. */
  22576. getBindedMeshes(): AbstractMesh[];
  22577. /**
  22578. * Force shader compilation
  22579. * @param mesh defines the mesh associated with this material
  22580. * @param onCompiled defines a function to execute once the material is compiled
  22581. * @param options defines the options to configure the compilation
  22582. */
  22583. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22584. clipPlane: boolean;
  22585. }>): void;
  22586. /**
  22587. * Force shader compilation
  22588. * @param mesh defines the mesh that will use this material
  22589. * @param options defines additional options for compiling the shaders
  22590. * @returns a promise that resolves when the compilation completes
  22591. */
  22592. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22593. clipPlane: boolean;
  22594. }>): Promise<void>;
  22595. private static readonly _ImageProcessingDirtyCallBack;
  22596. private static readonly _TextureDirtyCallBack;
  22597. private static readonly _FresnelDirtyCallBack;
  22598. private static readonly _MiscDirtyCallBack;
  22599. private static readonly _LightsDirtyCallBack;
  22600. private static readonly _AttributeDirtyCallBack;
  22601. private static _FresnelAndMiscDirtyCallBack;
  22602. private static _TextureAndMiscDirtyCallBack;
  22603. private static readonly _DirtyCallbackArray;
  22604. private static readonly _RunDirtyCallBacks;
  22605. /**
  22606. * Marks a define in the material to indicate that it needs to be re-computed
  22607. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22608. */
  22609. markAsDirty(flag: number): void;
  22610. /**
  22611. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22612. * @param func defines a function which checks material defines against the submeshes
  22613. */
  22614. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22615. /**
  22616. * Indicates that image processing needs to be re-calculated for all submeshes
  22617. */
  22618. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22619. /**
  22620. * Indicates that textures need to be re-calculated for all submeshes
  22621. */
  22622. protected _markAllSubMeshesAsTexturesDirty(): void;
  22623. /**
  22624. * Indicates that fresnel needs to be re-calculated for all submeshes
  22625. */
  22626. protected _markAllSubMeshesAsFresnelDirty(): void;
  22627. /**
  22628. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22629. */
  22630. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22631. /**
  22632. * Indicates that lights need to be re-calculated for all submeshes
  22633. */
  22634. protected _markAllSubMeshesAsLightsDirty(): void;
  22635. /**
  22636. * Indicates that attributes need to be re-calculated for all submeshes
  22637. */
  22638. protected _markAllSubMeshesAsAttributesDirty(): void;
  22639. /**
  22640. * Indicates that misc needs to be re-calculated for all submeshes
  22641. */
  22642. protected _markAllSubMeshesAsMiscDirty(): void;
  22643. /**
  22644. * Indicates that textures and misc need to be re-calculated for all submeshes
  22645. */
  22646. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22647. /**
  22648. * Disposes the material
  22649. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22650. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22651. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22652. */
  22653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22654. /** @hidden */
  22655. private releaseVertexArrayObject;
  22656. /**
  22657. * Serializes this material
  22658. * @returns the serialized material object
  22659. */
  22660. serialize(): any;
  22661. /**
  22662. * Creates a material from parsed material data
  22663. * @param parsedMaterial defines parsed material data
  22664. * @param scene defines the hosting scene
  22665. * @param rootUrl defines the root URL to use to load textures
  22666. * @returns a new material
  22667. */
  22668. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22669. }
  22670. }
  22671. declare module "babylonjs/Meshes/subMesh" {
  22672. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22673. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22674. import { Engine } from "babylonjs/Engines/engine";
  22675. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22676. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22677. import { Effect } from "babylonjs/Materials/effect";
  22678. import { Collider } from "babylonjs/Collisions/collider";
  22679. import { Material } from "babylonjs/Materials/material";
  22680. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22682. import { Mesh } from "babylonjs/Meshes/mesh";
  22683. import { Ray } from "babylonjs/Culling/ray";
  22684. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22685. /**
  22686. * Base class for submeshes
  22687. */
  22688. export class BaseSubMesh {
  22689. /** @hidden */
  22690. _materialDefines: Nullable<MaterialDefines>;
  22691. /** @hidden */
  22692. _materialEffect: Nullable<Effect>;
  22693. /**
  22694. * Gets associated effect
  22695. */
  22696. readonly effect: Nullable<Effect>;
  22697. /**
  22698. * Sets associated effect (effect used to render this submesh)
  22699. * @param effect defines the effect to associate with
  22700. * @param defines defines the set of defines used to compile this effect
  22701. */
  22702. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22703. }
  22704. /**
  22705. * Defines a subdivision inside a mesh
  22706. */
  22707. export class SubMesh extends BaseSubMesh implements ICullable {
  22708. /** the material index to use */
  22709. materialIndex: number;
  22710. /** vertex index start */
  22711. verticesStart: number;
  22712. /** vertices count */
  22713. verticesCount: number;
  22714. /** index start */
  22715. indexStart: number;
  22716. /** indices count */
  22717. indexCount: number;
  22718. /** @hidden */
  22719. _linesIndexCount: number;
  22720. private _mesh;
  22721. private _renderingMesh;
  22722. private _boundingInfo;
  22723. private _linesIndexBuffer;
  22724. /** @hidden */
  22725. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22726. /** @hidden */
  22727. _trianglePlanes: Plane[];
  22728. /** @hidden */
  22729. _lastColliderTransformMatrix: Matrix;
  22730. /** @hidden */
  22731. _renderId: number;
  22732. /** @hidden */
  22733. _alphaIndex: number;
  22734. /** @hidden */
  22735. _distanceToCamera: number;
  22736. /** @hidden */
  22737. _id: number;
  22738. private _currentMaterial;
  22739. /**
  22740. * Add a new submesh to a mesh
  22741. * @param materialIndex defines the material index to use
  22742. * @param verticesStart defines vertex index start
  22743. * @param verticesCount defines vertices count
  22744. * @param indexStart defines index start
  22745. * @param indexCount defines indices count
  22746. * @param mesh defines the parent mesh
  22747. * @param renderingMesh defines an optional rendering mesh
  22748. * @param createBoundingBox defines if bounding box should be created for this submesh
  22749. * @returns the new submesh
  22750. */
  22751. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22752. /**
  22753. * Creates a new submesh
  22754. * @param materialIndex defines the material index to use
  22755. * @param verticesStart defines vertex index start
  22756. * @param verticesCount defines vertices count
  22757. * @param indexStart defines index start
  22758. * @param indexCount defines indices count
  22759. * @param mesh defines the parent mesh
  22760. * @param renderingMesh defines an optional rendering mesh
  22761. * @param createBoundingBox defines if bounding box should be created for this submesh
  22762. */
  22763. constructor(
  22764. /** the material index to use */
  22765. materialIndex: number,
  22766. /** vertex index start */
  22767. verticesStart: number,
  22768. /** vertices count */
  22769. verticesCount: number,
  22770. /** index start */
  22771. indexStart: number,
  22772. /** indices count */
  22773. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22774. /**
  22775. * Returns true if this submesh covers the entire parent mesh
  22776. * @ignorenaming
  22777. */
  22778. readonly IsGlobal: boolean;
  22779. /**
  22780. * Returns the submesh BoudingInfo object
  22781. * @returns current bounding info (or mesh's one if the submesh is global)
  22782. */
  22783. getBoundingInfo(): BoundingInfo;
  22784. /**
  22785. * Sets the submesh BoundingInfo
  22786. * @param boundingInfo defines the new bounding info to use
  22787. * @returns the SubMesh
  22788. */
  22789. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22790. /**
  22791. * Returns the mesh of the current submesh
  22792. * @return the parent mesh
  22793. */
  22794. getMesh(): AbstractMesh;
  22795. /**
  22796. * Returns the rendering mesh of the submesh
  22797. * @returns the rendering mesh (could be different from parent mesh)
  22798. */
  22799. getRenderingMesh(): Mesh;
  22800. /**
  22801. * Returns the submesh material
  22802. * @returns null or the current material
  22803. */
  22804. getMaterial(): Nullable<Material>;
  22805. /**
  22806. * Sets a new updated BoundingInfo object to the submesh
  22807. * @returns the SubMesh
  22808. */
  22809. refreshBoundingInfo(): SubMesh;
  22810. /** @hidden */
  22811. _checkCollision(collider: Collider): boolean;
  22812. /**
  22813. * Updates the submesh BoundingInfo
  22814. * @param world defines the world matrix to use to update the bounding info
  22815. * @returns the submesh
  22816. */
  22817. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22818. /**
  22819. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22820. * @param frustumPlanes defines the frustum planes
  22821. * @returns true if the submesh is intersecting with the frustum
  22822. */
  22823. isInFrustum(frustumPlanes: Plane[]): boolean;
  22824. /**
  22825. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22826. * @param frustumPlanes defines the frustum planes
  22827. * @returns true if the submesh is inside the frustum
  22828. */
  22829. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22830. /**
  22831. * Renders the submesh
  22832. * @param enableAlphaMode defines if alpha needs to be used
  22833. * @returns the submesh
  22834. */
  22835. render(enableAlphaMode: boolean): SubMesh;
  22836. /**
  22837. * @hidden
  22838. */
  22839. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22840. /**
  22841. * Checks if the submesh intersects with a ray
  22842. * @param ray defines the ray to test
  22843. * @returns true is the passed ray intersects the submesh bounding box
  22844. */
  22845. canIntersects(ray: Ray): boolean;
  22846. /**
  22847. * Intersects current submesh with a ray
  22848. * @param ray defines the ray to test
  22849. * @param positions defines mesh's positions array
  22850. * @param indices defines mesh's indices array
  22851. * @param fastCheck defines if only bounding info should be used
  22852. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22853. * @returns intersection info or null if no intersection
  22854. */
  22855. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22856. /** @hidden */
  22857. private _intersectLines;
  22858. /** @hidden */
  22859. private _intersectTriangles;
  22860. /** @hidden */
  22861. _rebuild(): void;
  22862. /**
  22863. * Creates a new submesh from the passed mesh
  22864. * @param newMesh defines the new hosting mesh
  22865. * @param newRenderingMesh defines an optional rendering mesh
  22866. * @returns the new submesh
  22867. */
  22868. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22869. /**
  22870. * Release associated resources
  22871. */
  22872. dispose(): void;
  22873. /**
  22874. * Gets the class name
  22875. * @returns the string "SubMesh".
  22876. */
  22877. getClassName(): string;
  22878. /**
  22879. * Creates a new submesh from indices data
  22880. * @param materialIndex the index of the main mesh material
  22881. * @param startIndex the index where to start the copy in the mesh indices array
  22882. * @param indexCount the number of indices to copy then from the startIndex
  22883. * @param mesh the main mesh to create the submesh from
  22884. * @param renderingMesh the optional rendering mesh
  22885. * @returns a new submesh
  22886. */
  22887. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22888. }
  22889. }
  22890. declare module "babylonjs/Meshes/geometry" {
  22891. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22892. import { Scene } from "babylonjs/scene";
  22893. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22894. import { Engine } from "babylonjs/Engines/engine";
  22895. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22896. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22897. import { Effect } from "babylonjs/Materials/effect";
  22898. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22899. import { Mesh } from "babylonjs/Meshes/mesh";
  22900. /**
  22901. * Class used to store geometry data (vertex buffers + index buffer)
  22902. */
  22903. export class Geometry implements IGetSetVerticesData {
  22904. /**
  22905. * Gets or sets the ID of the geometry
  22906. */
  22907. id: string;
  22908. /**
  22909. * Gets or sets the unique ID of the geometry
  22910. */
  22911. uniqueId: number;
  22912. /**
  22913. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22914. */
  22915. delayLoadState: number;
  22916. /**
  22917. * Gets the file containing the data to load when running in delay load state
  22918. */
  22919. delayLoadingFile: Nullable<string>;
  22920. /**
  22921. * Callback called when the geometry is updated
  22922. */
  22923. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22924. private _scene;
  22925. private _engine;
  22926. private _meshes;
  22927. private _totalVertices;
  22928. /** @hidden */
  22929. _indices: IndicesArray;
  22930. /** @hidden */
  22931. _vertexBuffers: {
  22932. [key: string]: VertexBuffer;
  22933. };
  22934. private _isDisposed;
  22935. private _extend;
  22936. private _boundingBias;
  22937. /** @hidden */
  22938. _delayInfo: Array<string>;
  22939. private _indexBuffer;
  22940. private _indexBufferIsUpdatable;
  22941. /** @hidden */
  22942. _boundingInfo: Nullable<BoundingInfo>;
  22943. /** @hidden */
  22944. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22945. /** @hidden */
  22946. _softwareSkinningFrameId: number;
  22947. private _vertexArrayObjects;
  22948. private _updatable;
  22949. /** @hidden */
  22950. _positions: Nullable<Vector3[]>;
  22951. /**
  22952. * 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
  22953. */
  22954. /**
  22955. * 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
  22956. */
  22957. boundingBias: Vector2;
  22958. /**
  22959. * Static function used to attach a new empty geometry to a mesh
  22960. * @param mesh defines the mesh to attach the geometry to
  22961. * @returns the new Geometry
  22962. */
  22963. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22964. /**
  22965. * Creates a new geometry
  22966. * @param id defines the unique ID
  22967. * @param scene defines the hosting scene
  22968. * @param vertexData defines the VertexData used to get geometry data
  22969. * @param updatable defines if geometry must be updatable (false by default)
  22970. * @param mesh defines the mesh that will be associated with the geometry
  22971. */
  22972. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22973. /**
  22974. * Gets the current extend of the geometry
  22975. */
  22976. readonly extend: {
  22977. minimum: Vector3;
  22978. maximum: Vector3;
  22979. };
  22980. /**
  22981. * Gets the hosting scene
  22982. * @returns the hosting Scene
  22983. */
  22984. getScene(): Scene;
  22985. /**
  22986. * Gets the hosting engine
  22987. * @returns the hosting Engine
  22988. */
  22989. getEngine(): Engine;
  22990. /**
  22991. * Defines if the geometry is ready to use
  22992. * @returns true if the geometry is ready to be used
  22993. */
  22994. isReady(): boolean;
  22995. /**
  22996. * Gets a value indicating that the geometry should not be serialized
  22997. */
  22998. readonly doNotSerialize: boolean;
  22999. /** @hidden */
  23000. _rebuild(): void;
  23001. /**
  23002. * Affects all geometry data in one call
  23003. * @param vertexData defines the geometry data
  23004. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23005. */
  23006. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23007. /**
  23008. * Set specific vertex data
  23009. * @param kind defines the data kind (Position, normal, etc...)
  23010. * @param data defines the vertex data to use
  23011. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23012. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23013. */
  23014. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23015. /**
  23016. * Removes a specific vertex data
  23017. * @param kind defines the data kind (Position, normal, etc...)
  23018. */
  23019. removeVerticesData(kind: string): void;
  23020. /**
  23021. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23022. * @param buffer defines the vertex buffer to use
  23023. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23024. */
  23025. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23026. /**
  23027. * Update a specific vertex buffer
  23028. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23029. * It will do nothing if the buffer is not updatable
  23030. * @param kind defines the data kind (Position, normal, etc...)
  23031. * @param data defines the data to use
  23032. * @param offset defines the offset in the target buffer where to store the data
  23033. * @param useBytes set to true if the offset is in bytes
  23034. */
  23035. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23036. /**
  23037. * Update a specific vertex buffer
  23038. * This function will create a new buffer if the current one is not updatable
  23039. * @param kind defines the data kind (Position, normal, etc...)
  23040. * @param data defines the data to use
  23041. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23042. */
  23043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23044. private _updateBoundingInfo;
  23045. /** @hidden */
  23046. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23047. /**
  23048. * Gets total number of vertices
  23049. * @returns the total number of vertices
  23050. */
  23051. getTotalVertices(): number;
  23052. /**
  23053. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23054. * @param kind defines the data kind (Position, normal, etc...)
  23055. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23056. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23057. * @returns a float array containing vertex data
  23058. */
  23059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23060. /**
  23061. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23062. * @param kind defines the data kind (Position, normal, etc...)
  23063. * @returns true if the vertex buffer with the specified kind is updatable
  23064. */
  23065. isVertexBufferUpdatable(kind: string): boolean;
  23066. /**
  23067. * Gets a specific vertex buffer
  23068. * @param kind defines the data kind (Position, normal, etc...)
  23069. * @returns a VertexBuffer
  23070. */
  23071. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23072. /**
  23073. * Returns all vertex buffers
  23074. * @return an object holding all vertex buffers indexed by kind
  23075. */
  23076. getVertexBuffers(): Nullable<{
  23077. [key: string]: VertexBuffer;
  23078. }>;
  23079. /**
  23080. * Gets a boolean indicating if specific vertex buffer is present
  23081. * @param kind defines the data kind (Position, normal, etc...)
  23082. * @returns true if data is present
  23083. */
  23084. isVerticesDataPresent(kind: string): boolean;
  23085. /**
  23086. * Gets a list of all attached data kinds (Position, normal, etc...)
  23087. * @returns a list of string containing all kinds
  23088. */
  23089. getVerticesDataKinds(): string[];
  23090. /**
  23091. * Update index buffer
  23092. * @param indices defines the indices to store in the index buffer
  23093. * @param offset defines the offset in the target buffer where to store the data
  23094. * @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)
  23095. */
  23096. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23097. /**
  23098. * Creates a new index buffer
  23099. * @param indices defines the indices to store in the index buffer
  23100. * @param totalVertices defines the total number of vertices (could be null)
  23101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23102. */
  23103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23104. /**
  23105. * Return the total number of indices
  23106. * @returns the total number of indices
  23107. */
  23108. getTotalIndices(): number;
  23109. /**
  23110. * Gets the index buffer array
  23111. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23113. * @returns the index buffer array
  23114. */
  23115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23116. /**
  23117. * Gets the index buffer
  23118. * @return the index buffer
  23119. */
  23120. getIndexBuffer(): Nullable<WebGLBuffer>;
  23121. /** @hidden */
  23122. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23123. /**
  23124. * Release the associated resources for a specific mesh
  23125. * @param mesh defines the source mesh
  23126. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23127. */
  23128. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23129. /**
  23130. * Apply current geometry to a given mesh
  23131. * @param mesh defines the mesh to apply geometry to
  23132. */
  23133. applyToMesh(mesh: Mesh): void;
  23134. private _updateExtend;
  23135. private _applyToMesh;
  23136. private notifyUpdate;
  23137. /**
  23138. * Load the geometry if it was flagged as delay loaded
  23139. * @param scene defines the hosting scene
  23140. * @param onLoaded defines a callback called when the geometry is loaded
  23141. */
  23142. load(scene: Scene, onLoaded?: () => void): void;
  23143. private _queueLoad;
  23144. /**
  23145. * Invert the geometry to move from a right handed system to a left handed one.
  23146. */
  23147. toLeftHanded(): void;
  23148. /** @hidden */
  23149. _resetPointsArrayCache(): void;
  23150. /** @hidden */
  23151. _generatePointsArray(): boolean;
  23152. /**
  23153. * Gets a value indicating if the geometry is disposed
  23154. * @returns true if the geometry was disposed
  23155. */
  23156. isDisposed(): boolean;
  23157. private _disposeVertexArrayObjects;
  23158. /**
  23159. * Free all associated resources
  23160. */
  23161. dispose(): void;
  23162. /**
  23163. * Clone the current geometry into a new geometry
  23164. * @param id defines the unique ID of the new geometry
  23165. * @returns a new geometry object
  23166. */
  23167. copy(id: string): Geometry;
  23168. /**
  23169. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23170. * @return a JSON representation of the current geometry data (without the vertices data)
  23171. */
  23172. serialize(): any;
  23173. private toNumberArray;
  23174. /**
  23175. * Serialize all vertices data into a JSON oject
  23176. * @returns a JSON representation of the current geometry data
  23177. */
  23178. serializeVerticeData(): any;
  23179. /**
  23180. * Extracts a clone of a mesh geometry
  23181. * @param mesh defines the source mesh
  23182. * @param id defines the unique ID of the new geometry object
  23183. * @returns the new geometry object
  23184. */
  23185. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23186. /**
  23187. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23188. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23189. * Be aware Math.random() could cause collisions, but:
  23190. * "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"
  23191. * @returns a string containing a new GUID
  23192. */
  23193. static RandomId(): string;
  23194. /** @hidden */
  23195. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23196. private static _CleanMatricesWeights;
  23197. /**
  23198. * Create a new geometry from persisted data (Using .babylon file format)
  23199. * @param parsedVertexData defines the persisted data
  23200. * @param scene defines the hosting scene
  23201. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23202. * @returns the new geometry object
  23203. */
  23204. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23205. }
  23206. }
  23207. declare module "babylonjs/Meshes/mesh.vertexData" {
  23208. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23209. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23210. import { Geometry } from "babylonjs/Meshes/geometry";
  23211. import { Mesh } from "babylonjs/Meshes/mesh";
  23212. /**
  23213. * Define an interface for all classes that will get and set the data on vertices
  23214. */
  23215. export interface IGetSetVerticesData {
  23216. /**
  23217. * Gets a boolean indicating if specific vertex data is present
  23218. * @param kind defines the vertex data kind to use
  23219. * @returns true is data kind is present
  23220. */
  23221. isVerticesDataPresent(kind: string): boolean;
  23222. /**
  23223. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23224. * @param kind defines the data kind (Position, normal, etc...)
  23225. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23227. * @returns a float array containing vertex data
  23228. */
  23229. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23230. /**
  23231. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23232. * @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.
  23233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23234. * @returns the indices array or an empty array if the mesh has no geometry
  23235. */
  23236. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23237. /**
  23238. * Set specific vertex data
  23239. * @param kind defines the data kind (Position, normal, etc...)
  23240. * @param data defines the vertex data to use
  23241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23243. */
  23244. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23245. /**
  23246. * Update a specific associated vertex buffer
  23247. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23248. * - VertexBuffer.PositionKind
  23249. * - VertexBuffer.UVKind
  23250. * - VertexBuffer.UV2Kind
  23251. * - VertexBuffer.UV3Kind
  23252. * - VertexBuffer.UV4Kind
  23253. * - VertexBuffer.UV5Kind
  23254. * - VertexBuffer.UV6Kind
  23255. * - VertexBuffer.ColorKind
  23256. * - VertexBuffer.MatricesIndicesKind
  23257. * - VertexBuffer.MatricesIndicesExtraKind
  23258. * - VertexBuffer.MatricesWeightsKind
  23259. * - VertexBuffer.MatricesWeightsExtraKind
  23260. * @param data defines the data source
  23261. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23262. * @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)
  23263. */
  23264. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23265. /**
  23266. * Creates a new index buffer
  23267. * @param indices defines the indices to store in the index buffer
  23268. * @param totalVertices defines the total number of vertices (could be null)
  23269. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23270. */
  23271. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23272. }
  23273. /**
  23274. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23275. */
  23276. export class VertexData {
  23277. /**
  23278. * Mesh side orientation : usually the external or front surface
  23279. */
  23280. static readonly FRONTSIDE: number;
  23281. /**
  23282. * Mesh side orientation : usually the internal or back surface
  23283. */
  23284. static readonly BACKSIDE: number;
  23285. /**
  23286. * Mesh side orientation : both internal and external or front and back surfaces
  23287. */
  23288. static readonly DOUBLESIDE: number;
  23289. /**
  23290. * Mesh side orientation : by default, `FRONTSIDE`
  23291. */
  23292. static readonly DEFAULTSIDE: number;
  23293. /**
  23294. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23295. */
  23296. positions: Nullable<FloatArray>;
  23297. /**
  23298. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23299. */
  23300. normals: Nullable<FloatArray>;
  23301. /**
  23302. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23303. */
  23304. tangents: Nullable<FloatArray>;
  23305. /**
  23306. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23307. */
  23308. uvs: Nullable<FloatArray>;
  23309. /**
  23310. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs2: Nullable<FloatArray>;
  23313. /**
  23314. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23315. */
  23316. uvs3: Nullable<FloatArray>;
  23317. /**
  23318. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23319. */
  23320. uvs4: Nullable<FloatArray>;
  23321. /**
  23322. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23323. */
  23324. uvs5: Nullable<FloatArray>;
  23325. /**
  23326. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23327. */
  23328. uvs6: Nullable<FloatArray>;
  23329. /**
  23330. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23331. */
  23332. colors: Nullable<FloatArray>;
  23333. /**
  23334. * 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).
  23335. */
  23336. matricesIndices: Nullable<FloatArray>;
  23337. /**
  23338. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23339. */
  23340. matricesWeights: Nullable<FloatArray>;
  23341. /**
  23342. * An array extending the number of possible indices
  23343. */
  23344. matricesIndicesExtra: Nullable<FloatArray>;
  23345. /**
  23346. * An array extending the number of possible weights when the number of indices is extended
  23347. */
  23348. matricesWeightsExtra: Nullable<FloatArray>;
  23349. /**
  23350. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23351. */
  23352. indices: Nullable<IndicesArray>;
  23353. /**
  23354. * Uses the passed data array to set the set the values for the specified kind of data
  23355. * @param data a linear array of floating numbers
  23356. * @param kind the type of data that is being set, eg positions, colors etc
  23357. */
  23358. set(data: FloatArray, kind: string): void;
  23359. /**
  23360. * Associates the vertexData to the passed Mesh.
  23361. * Sets it as updatable or not (default `false`)
  23362. * @param mesh the mesh the vertexData is applied to
  23363. * @param updatable when used and having the value true allows new data to update the vertexData
  23364. * @returns the VertexData
  23365. */
  23366. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23367. /**
  23368. * Associates the vertexData to the passed Geometry.
  23369. * Sets it as updatable or not (default `false`)
  23370. * @param geometry the geometry the vertexData is applied to
  23371. * @param updatable when used and having the value true allows new data to update the vertexData
  23372. * @returns VertexData
  23373. */
  23374. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23375. /**
  23376. * Updates the associated mesh
  23377. * @param mesh the mesh to be updated
  23378. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23379. * @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
  23380. * @returns VertexData
  23381. */
  23382. updateMesh(mesh: Mesh): VertexData;
  23383. /**
  23384. * Updates the associated geometry
  23385. * @param geometry the geometry to be updated
  23386. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23387. * @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
  23388. * @returns VertexData.
  23389. */
  23390. updateGeometry(geometry: Geometry): VertexData;
  23391. private _applyTo;
  23392. private _update;
  23393. /**
  23394. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23395. * @param matrix the transforming matrix
  23396. * @returns the VertexData
  23397. */
  23398. transform(matrix: Matrix): VertexData;
  23399. /**
  23400. * Merges the passed VertexData into the current one
  23401. * @param other the VertexData to be merged into the current one
  23402. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23403. * @returns the modified VertexData
  23404. */
  23405. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23406. private _mergeElement;
  23407. private _validate;
  23408. /**
  23409. * Serializes the VertexData
  23410. * @returns a serialized object
  23411. */
  23412. serialize(): any;
  23413. /**
  23414. * Extracts the vertexData from a mesh
  23415. * @param mesh the mesh from which to extract the VertexData
  23416. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23417. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23418. * @returns the object VertexData associated to the passed mesh
  23419. */
  23420. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23421. /**
  23422. * Extracts the vertexData from the geometry
  23423. * @param geometry the geometry from which to extract the VertexData
  23424. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23426. * @returns the object VertexData associated to the passed mesh
  23427. */
  23428. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23429. private static _ExtractFrom;
  23430. /**
  23431. * Creates the VertexData for a Ribbon
  23432. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23433. * * pathArray array of paths, each of which an array of successive Vector3
  23434. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23435. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23436. * * 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
  23437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23438. * * 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)
  23439. * * 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)
  23440. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23441. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23442. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23443. * @returns the VertexData of the ribbon
  23444. */
  23445. static CreateRibbon(options: {
  23446. pathArray: Vector3[][];
  23447. closeArray?: boolean;
  23448. closePath?: boolean;
  23449. offset?: number;
  23450. sideOrientation?: number;
  23451. frontUVs?: Vector4;
  23452. backUVs?: Vector4;
  23453. invertUV?: boolean;
  23454. uvs?: Vector2[];
  23455. colors?: Color4[];
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData for a box
  23459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23460. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23461. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23462. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23463. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23464. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23465. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  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 box
  23470. */
  23471. static CreateBox(options: {
  23472. size?: number;
  23473. width?: number;
  23474. height?: number;
  23475. depth?: number;
  23476. faceUV?: Vector4[];
  23477. faceColors?: Color4[];
  23478. sideOrientation?: number;
  23479. frontUVs?: Vector4;
  23480. backUVs?: Vector4;
  23481. }): VertexData;
  23482. /**
  23483. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23485. * * segments sets the number of horizontal strips optional, default 32
  23486. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23487. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23488. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23489. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23490. * * 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
  23491. * * 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
  23492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23493. * * 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)
  23494. * * 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)
  23495. * @returns the VertexData of the ellipsoid
  23496. */
  23497. static CreateSphere(options: {
  23498. segments?: number;
  23499. diameter?: number;
  23500. diameterX?: number;
  23501. diameterY?: number;
  23502. diameterZ?: number;
  23503. arc?: number;
  23504. slice?: number;
  23505. sideOrientation?: number;
  23506. frontUVs?: Vector4;
  23507. backUVs?: Vector4;
  23508. }): VertexData;
  23509. /**
  23510. * Creates the VertexData for a cylinder, cone or prism
  23511. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23512. * * height sets the height (y direction) of the cylinder, optional, default 2
  23513. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23514. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23515. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23516. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23517. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23518. * * 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
  23519. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23520. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23521. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23522. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23524. * * 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)
  23525. * * 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)
  23526. * @returns the VertexData of the cylinder, cone or prism
  23527. */
  23528. static CreateCylinder(options: {
  23529. height?: number;
  23530. diameterTop?: number;
  23531. diameterBottom?: number;
  23532. diameter?: number;
  23533. tessellation?: number;
  23534. subdivisions?: number;
  23535. arc?: number;
  23536. faceColors?: Color4[];
  23537. faceUV?: Vector4[];
  23538. hasRings?: boolean;
  23539. enclose?: boolean;
  23540. sideOrientation?: number;
  23541. frontUVs?: Vector4;
  23542. backUVs?: Vector4;
  23543. }): VertexData;
  23544. /**
  23545. * Creates the VertexData for a torus
  23546. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23547. * * diameter the diameter of the torus, optional default 1
  23548. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23549. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23551. * * 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)
  23552. * * 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)
  23553. * @returns the VertexData of the torus
  23554. */
  23555. static CreateTorus(options: {
  23556. diameter?: number;
  23557. thickness?: number;
  23558. tessellation?: number;
  23559. sideOrientation?: number;
  23560. frontUVs?: Vector4;
  23561. backUVs?: Vector4;
  23562. }): VertexData;
  23563. /**
  23564. * Creates the VertexData of the LineSystem
  23565. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23566. * - lines an array of lines, each line being an array of successive Vector3
  23567. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23568. * @returns the VertexData of the LineSystem
  23569. */
  23570. static CreateLineSystem(options: {
  23571. lines: Vector3[][];
  23572. colors?: Nullable<Color4[][]>;
  23573. }): VertexData;
  23574. /**
  23575. * Create the VertexData for a DashedLines
  23576. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23577. * - points an array successive Vector3
  23578. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23579. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23580. * - dashNb the intended total number of dashes, optional, default 200
  23581. * @returns the VertexData for the DashedLines
  23582. */
  23583. static CreateDashedLines(options: {
  23584. points: Vector3[];
  23585. dashSize?: number;
  23586. gapSize?: number;
  23587. dashNb?: number;
  23588. }): VertexData;
  23589. /**
  23590. * Creates the VertexData for a Ground
  23591. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23592. * - width the width (x direction) of the ground, optional, default 1
  23593. * - height the height (z direction) of the ground, optional, default 1
  23594. * - subdivisions the number of subdivisions per side, optional, default 1
  23595. * @returns the VertexData of the Ground
  23596. */
  23597. static CreateGround(options: {
  23598. width?: number;
  23599. height?: number;
  23600. subdivisions?: number;
  23601. subdivisionsX?: number;
  23602. subdivisionsY?: number;
  23603. }): VertexData;
  23604. /**
  23605. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23606. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23607. * * xmin the ground minimum X coordinate, optional, default -1
  23608. * * zmin the ground minimum Z coordinate, optional, default -1
  23609. * * xmax the ground maximum X coordinate, optional, default 1
  23610. * * zmax the ground maximum Z coordinate, optional, default 1
  23611. * * 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}
  23612. * * 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}
  23613. * @returns the VertexData of the TiledGround
  23614. */
  23615. static CreateTiledGround(options: {
  23616. xmin: number;
  23617. zmin: number;
  23618. xmax: number;
  23619. zmax: number;
  23620. subdivisions?: {
  23621. w: number;
  23622. h: number;
  23623. };
  23624. precision?: {
  23625. w: number;
  23626. h: number;
  23627. };
  23628. }): VertexData;
  23629. /**
  23630. * Creates the VertexData of the Ground designed from a heightmap
  23631. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23632. * * width the width (x direction) of the ground
  23633. * * height the height (z direction) of the ground
  23634. * * subdivisions the number of subdivisions per side
  23635. * * minHeight the minimum altitude on the ground, optional, default 0
  23636. * * maxHeight the maximum altitude on the ground, optional default 1
  23637. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23638. * * buffer the array holding the image color data
  23639. * * bufferWidth the width of image
  23640. * * bufferHeight the height of image
  23641. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23642. * @returns the VertexData of the Ground designed from a heightmap
  23643. */
  23644. static CreateGroundFromHeightMap(options: {
  23645. width: number;
  23646. height: number;
  23647. subdivisions: number;
  23648. minHeight: number;
  23649. maxHeight: number;
  23650. colorFilter: Color3;
  23651. buffer: Uint8Array;
  23652. bufferWidth: number;
  23653. bufferHeight: number;
  23654. alphaFilter: number;
  23655. }): VertexData;
  23656. /**
  23657. * Creates the VertexData for a Plane
  23658. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23659. * * size sets the width and height of the plane to the value of size, optional default 1
  23660. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23661. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23663. * * 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)
  23664. * * 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)
  23665. * @returns the VertexData of the box
  23666. */
  23667. static CreatePlane(options: {
  23668. size?: number;
  23669. width?: number;
  23670. height?: number;
  23671. sideOrientation?: number;
  23672. frontUVs?: Vector4;
  23673. backUVs?: Vector4;
  23674. }): VertexData;
  23675. /**
  23676. * Creates the VertexData of the Disc or regular Polygon
  23677. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23678. * * radius the radius of the disc, optional default 0.5
  23679. * * tessellation the number of polygon sides, optional, default 64
  23680. * * 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
  23681. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23682. * * 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)
  23683. * * 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)
  23684. * @returns the VertexData of the box
  23685. */
  23686. static CreateDisc(options: {
  23687. radius?: number;
  23688. tessellation?: number;
  23689. arc?: number;
  23690. sideOrientation?: number;
  23691. frontUVs?: Vector4;
  23692. backUVs?: Vector4;
  23693. }): VertexData;
  23694. /**
  23695. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23696. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23697. * @param polygon a mesh built from polygonTriangulation.build()
  23698. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23699. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23700. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23701. * @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)
  23702. * @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)
  23703. * @returns the VertexData of the Polygon
  23704. */
  23705. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23706. /**
  23707. * Creates the VertexData of the IcoSphere
  23708. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23709. * * radius the radius of the IcoSphere, optional default 1
  23710. * * radiusX allows stretching in the x direction, optional, default radius
  23711. * * radiusY allows stretching in the y direction, optional, default radius
  23712. * * radiusZ allows stretching in the z direction, optional, default radius
  23713. * * flat when true creates a flat shaded mesh, optional, default true
  23714. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23715. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23716. * * 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)
  23717. * * 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)
  23718. * @returns the VertexData of the IcoSphere
  23719. */
  23720. static CreateIcoSphere(options: {
  23721. radius?: number;
  23722. radiusX?: number;
  23723. radiusY?: number;
  23724. radiusZ?: number;
  23725. flat?: boolean;
  23726. subdivisions?: number;
  23727. sideOrientation?: number;
  23728. frontUVs?: Vector4;
  23729. backUVs?: Vector4;
  23730. }): VertexData;
  23731. /**
  23732. * Creates the VertexData for a Polyhedron
  23733. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23734. * * type provided types are:
  23735. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23736. * * 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)
  23737. * * size the size of the IcoSphere, optional default 1
  23738. * * sizeX allows stretching in the x direction, optional, default size
  23739. * * sizeY allows stretching in the y direction, optional, default size
  23740. * * sizeZ allows stretching in the z direction, optional, default size
  23741. * * 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
  23742. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23743. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23744. * * flat when true creates a flat shaded mesh, optional, default true
  23745. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23747. * * 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)
  23748. * * 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)
  23749. * @returns the VertexData of the Polyhedron
  23750. */
  23751. static CreatePolyhedron(options: {
  23752. type?: number;
  23753. size?: number;
  23754. sizeX?: number;
  23755. sizeY?: number;
  23756. sizeZ?: number;
  23757. custom?: any;
  23758. faceUV?: Vector4[];
  23759. faceColors?: Color4[];
  23760. flat?: boolean;
  23761. sideOrientation?: number;
  23762. frontUVs?: Vector4;
  23763. backUVs?: Vector4;
  23764. }): VertexData;
  23765. /**
  23766. * Creates the VertexData for a TorusKnot
  23767. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23768. * * radius the radius of the torus knot, optional, default 2
  23769. * * tube the thickness of the tube, optional, default 0.5
  23770. * * radialSegments the number of sides on each tube segments, optional, default 32
  23771. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23772. * * p the number of windings around the z axis, optional, default 2
  23773. * * q the number of windings around the x axis, optional, default 3
  23774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23775. * * 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)
  23776. * * 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)
  23777. * @returns the VertexData of the Torus Knot
  23778. */
  23779. static CreateTorusKnot(options: {
  23780. radius?: number;
  23781. tube?: number;
  23782. radialSegments?: number;
  23783. tubularSegments?: number;
  23784. p?: number;
  23785. q?: number;
  23786. sideOrientation?: number;
  23787. frontUVs?: Vector4;
  23788. backUVs?: Vector4;
  23789. }): VertexData;
  23790. /**
  23791. * Compute normals for given positions and indices
  23792. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23793. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23794. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23795. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23796. * * facetNormals : optional array of facet normals (vector3)
  23797. * * facetPositions : optional array of facet positions (vector3)
  23798. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23799. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23800. * * bInfo : optional bounding info, required for facetPartitioning computation
  23801. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23802. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23803. * * useRightHandedSystem: optional boolean to for right handed system computation
  23804. * * depthSort : optional boolean to enable the facet depth sort computation
  23805. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23806. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23807. */
  23808. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23809. facetNormals?: any;
  23810. facetPositions?: any;
  23811. facetPartitioning?: any;
  23812. ratio?: number;
  23813. bInfo?: any;
  23814. bbSize?: Vector3;
  23815. subDiv?: any;
  23816. useRightHandedSystem?: boolean;
  23817. depthSort?: boolean;
  23818. distanceTo?: Vector3;
  23819. depthSortedFacets?: any;
  23820. }): void;
  23821. /** @hidden */
  23822. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23823. /**
  23824. * Applies VertexData created from the imported parameters to the geometry
  23825. * @param parsedVertexData the parsed data from an imported file
  23826. * @param geometry the geometry to apply the VertexData to
  23827. */
  23828. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23829. }
  23830. }
  23831. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23832. import { Nullable } from "babylonjs/types";
  23833. import { Scene } from "babylonjs/scene";
  23834. import { Vector4 } from "babylonjs/Maths/math";
  23835. import { Mesh } from "babylonjs/Meshes/mesh";
  23836. /**
  23837. * Class containing static functions to help procedurally build meshes
  23838. */
  23839. export class DiscBuilder {
  23840. /**
  23841. * Creates a plane polygonal mesh. By default, this is a disc
  23842. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23843. * * 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
  23844. * * 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
  23845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23848. * @param name defines the name of the mesh
  23849. * @param options defines the options used to create the mesh
  23850. * @param scene defines the hosting scene
  23851. * @returns the plane polygonal mesh
  23852. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23853. */
  23854. static CreateDisc(name: string, options: {
  23855. radius?: number;
  23856. tessellation?: number;
  23857. arc?: number;
  23858. updatable?: boolean;
  23859. sideOrientation?: number;
  23860. frontUVs?: Vector4;
  23861. backUVs?: Vector4;
  23862. }, scene?: Nullable<Scene>): Mesh;
  23863. }
  23864. }
  23865. declare module "babylonjs/Particles/solidParticleSystem" {
  23866. import { Vector3 } from "babylonjs/Maths/math";
  23867. import { Mesh } from "babylonjs/Meshes/mesh";
  23868. import { Scene, IDisposable } from "babylonjs/scene";
  23869. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23870. /**
  23871. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23872. *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.
  23873. * The SPS is also a particle system. It provides some methods to manage the particles.
  23874. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23875. *
  23876. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23877. */
  23878. export class SolidParticleSystem implements IDisposable {
  23879. /**
  23880. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23881. * Example : var p = SPS.particles[i];
  23882. */
  23883. particles: SolidParticle[];
  23884. /**
  23885. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23886. */
  23887. nbParticles: number;
  23888. /**
  23889. * If the particles must ever face the camera (default false). Useful for planar particles.
  23890. */
  23891. billboard: boolean;
  23892. /**
  23893. * Recompute normals when adding a shape
  23894. */
  23895. recomputeNormals: boolean;
  23896. /**
  23897. * This a counter ofr your own usage. It's not set by any SPS functions.
  23898. */
  23899. counter: number;
  23900. /**
  23901. * The SPS name. This name is also given to the underlying mesh.
  23902. */
  23903. name: string;
  23904. /**
  23905. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23906. */
  23907. mesh: Mesh;
  23908. /**
  23909. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23910. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23911. */
  23912. vars: any;
  23913. /**
  23914. * This array is populated when the SPS is set as 'pickable'.
  23915. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23916. * Each element of this array is an object `{idx: int, faceId: int}`.
  23917. * `idx` is the picked particle index in the `SPS.particles` array
  23918. * `faceId` is the picked face index counted within this particle.
  23919. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23920. */
  23921. pickedParticles: {
  23922. idx: number;
  23923. faceId: number;
  23924. }[];
  23925. /**
  23926. * This array is populated when `enableDepthSort` is set to true.
  23927. * Each element of this array is an instance of the class DepthSortedParticle.
  23928. */
  23929. depthSortedParticles: DepthSortedParticle[];
  23930. /**
  23931. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23932. * @hidden
  23933. */
  23934. _bSphereOnly: boolean;
  23935. /**
  23936. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23937. * @hidden
  23938. */
  23939. _bSphereRadiusFactor: number;
  23940. private _scene;
  23941. private _positions;
  23942. private _indices;
  23943. private _normals;
  23944. private _colors;
  23945. private _uvs;
  23946. private _indices32;
  23947. private _positions32;
  23948. private _normals32;
  23949. private _fixedNormal32;
  23950. private _colors32;
  23951. private _uvs32;
  23952. private _index;
  23953. private _updatable;
  23954. private _pickable;
  23955. private _isVisibilityBoxLocked;
  23956. private _alwaysVisible;
  23957. private _depthSort;
  23958. private _shapeCounter;
  23959. private _copy;
  23960. private _color;
  23961. private _computeParticleColor;
  23962. private _computeParticleTexture;
  23963. private _computeParticleRotation;
  23964. private _computeParticleVertex;
  23965. private _computeBoundingBox;
  23966. private _depthSortParticles;
  23967. private _camera;
  23968. private _mustUnrotateFixedNormals;
  23969. private _particlesIntersect;
  23970. private _needs32Bits;
  23971. /**
  23972. * Creates a SPS (Solid Particle System) object.
  23973. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23974. * @param scene (Scene) is the scene in which the SPS is added.
  23975. * @param options defines the options of the sps e.g.
  23976. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23977. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23978. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23979. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23980. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23981. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23982. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23983. */
  23984. constructor(name: string, scene: Scene, options?: {
  23985. updatable?: boolean;
  23986. isPickable?: boolean;
  23987. enableDepthSort?: boolean;
  23988. particleIntersection?: boolean;
  23989. boundingSphereOnly?: boolean;
  23990. bSphereRadiusFactor?: number;
  23991. });
  23992. /**
  23993. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23994. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23995. * @returns the created mesh
  23996. */
  23997. buildMesh(): Mesh;
  23998. /**
  23999. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24000. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24001. * Thus the particles generated from `digest()` have their property `position` set yet.
  24002. * @param mesh ( Mesh ) is the mesh to be digested
  24003. * @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
  24004. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24005. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24006. * @returns the current SPS
  24007. */
  24008. digest(mesh: Mesh, options?: {
  24009. facetNb?: number;
  24010. number?: number;
  24011. delta?: number;
  24012. }): SolidParticleSystem;
  24013. private _unrotateFixedNormals;
  24014. private _resetCopy;
  24015. private _meshBuilder;
  24016. private _posToShape;
  24017. private _uvsToShapeUV;
  24018. private _addParticle;
  24019. /**
  24020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24021. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24023. * @param nb (positive integer) the number of particles to be created from this model
  24024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24026. * @returns the number of shapes in the system
  24027. */
  24028. addShape(mesh: Mesh, nb: number, options?: {
  24029. positionFunction?: any;
  24030. vertexFunction?: any;
  24031. }): number;
  24032. private _rebuildParticle;
  24033. /**
  24034. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24035. * @returns the SPS.
  24036. */
  24037. rebuildMesh(): SolidParticleSystem;
  24038. /**
  24039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24040. * This method calls `updateParticle()` for each particle of the SPS.
  24041. * For an animated SPS, it is usually called within the render loop.
  24042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24045. * @returns the SPS.
  24046. */
  24047. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24048. /**
  24049. * Disposes the SPS.
  24050. */
  24051. dispose(): void;
  24052. /**
  24053. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24054. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24055. * @returns the SPS.
  24056. */
  24057. refreshVisibleSize(): SolidParticleSystem;
  24058. /**
  24059. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24060. * @param size the size (float) of the visibility box
  24061. * note : this doesn't lock the SPS mesh bounding box.
  24062. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24063. */
  24064. setVisibilityBox(size: number): void;
  24065. /**
  24066. * Gets whether the SPS as always visible or not
  24067. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24068. */
  24069. /**
  24070. * Sets the SPS as always visible or not
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. isAlwaysVisible: boolean;
  24074. /**
  24075. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24076. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24077. */
  24078. /**
  24079. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. isVisibilityBoxLocked: boolean;
  24083. /**
  24084. * Tells to `setParticles()` to compute the particle rotations or not.
  24085. * Default value : true. The SPS is faster when it's set to false.
  24086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24087. */
  24088. /**
  24089. * Gets if `setParticles()` computes the particle rotations or not.
  24090. * Default value : true. The SPS is faster when it's set to false.
  24091. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24092. */
  24093. computeParticleRotation: boolean;
  24094. /**
  24095. * Tells to `setParticles()` to compute the particle colors or not.
  24096. * Default value : true. The SPS is faster when it's set to false.
  24097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24098. */
  24099. /**
  24100. * Gets if `setParticles()` computes the particle colors or not.
  24101. * Default value : true. The SPS is faster when it's set to false.
  24102. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24103. */
  24104. computeParticleColor: boolean;
  24105. /**
  24106. * Gets if `setParticles()` computes the particle textures or not.
  24107. * Default value : true. The SPS is faster when it's set to false.
  24108. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24109. */
  24110. computeParticleTexture: boolean;
  24111. /**
  24112. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24113. * Default value : false. The SPS is faster when it's set to false.
  24114. * Note : the particle custom vertex positions aren't stored values.
  24115. */
  24116. /**
  24117. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24118. * Default value : false. The SPS is faster when it's set to false.
  24119. * Note : the particle custom vertex positions aren't stored values.
  24120. */
  24121. computeParticleVertex: boolean;
  24122. /**
  24123. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24124. */
  24125. /**
  24126. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24127. */
  24128. computeBoundingBox: boolean;
  24129. /**
  24130. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24132. * Default : `true`
  24133. */
  24134. /**
  24135. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24136. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24137. * Default : `true`
  24138. */
  24139. depthSortParticles: boolean;
  24140. /**
  24141. * This function does nothing. It may be overwritten to set all the particle first values.
  24142. * The SPS doesn't call this function, you may have to call it by your own.
  24143. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24144. */
  24145. initParticles(): void;
  24146. /**
  24147. * This function does nothing. It may be overwritten to recycle a particle.
  24148. * The SPS doesn't call this function, you may have to call it by your own.
  24149. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24150. * @param particle The particle to recycle
  24151. * @returns the recycled particle
  24152. */
  24153. recycleParticle(particle: SolidParticle): SolidParticle;
  24154. /**
  24155. * Updates a particle : this function should be overwritten by the user.
  24156. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24157. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24158. * @example : just set a particle position or velocity and recycle conditions
  24159. * @param particle The particle to update
  24160. * @returns the updated particle
  24161. */
  24162. updateParticle(particle: SolidParticle): SolidParticle;
  24163. /**
  24164. * Updates a vertex of a particle : it can be overwritten by the user.
  24165. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24166. * @param particle the current particle
  24167. * @param vertex the current index of the current particle
  24168. * @param pt the index of the current vertex in the particle shape
  24169. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24170. * @example : just set a vertex particle position
  24171. * @returns the updated vertex
  24172. */
  24173. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24174. /**
  24175. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24176. * This does nothing and may be overwritten by the user.
  24177. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24178. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24179. * @param update the boolean update value actually passed to setParticles()
  24180. */
  24181. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24182. /**
  24183. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24184. * This will be passed three parameters.
  24185. * This does nothing and may be overwritten by the user.
  24186. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24187. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24188. * @param update the boolean update value actually passed to setParticles()
  24189. */
  24190. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24191. }
  24192. }
  24193. declare module "babylonjs/Particles/solidParticle" {
  24194. import { Nullable } from "babylonjs/types";
  24195. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24196. import { Mesh } from "babylonjs/Meshes/mesh";
  24197. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24198. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24199. /**
  24200. * Represents one particle of a solid particle system.
  24201. */
  24202. export class SolidParticle {
  24203. /**
  24204. * particle global index
  24205. */
  24206. idx: number;
  24207. /**
  24208. * The color of the particle
  24209. */
  24210. color: Nullable<Color4>;
  24211. /**
  24212. * The world space position of the particle.
  24213. */
  24214. position: Vector3;
  24215. /**
  24216. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24217. */
  24218. rotation: Vector3;
  24219. /**
  24220. * The world space rotation quaternion of the particle.
  24221. */
  24222. rotationQuaternion: Nullable<Quaternion>;
  24223. /**
  24224. * The scaling of the particle.
  24225. */
  24226. scaling: Vector3;
  24227. /**
  24228. * The uvs of the particle.
  24229. */
  24230. uvs: Vector4;
  24231. /**
  24232. * The current speed of the particle.
  24233. */
  24234. velocity: Vector3;
  24235. /**
  24236. * The pivot point in the particle local space.
  24237. */
  24238. pivot: Vector3;
  24239. /**
  24240. * Must the particle be translated from its pivot point in its local space ?
  24241. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24242. * Default : false
  24243. */
  24244. translateFromPivot: boolean;
  24245. /**
  24246. * Is the particle active or not ?
  24247. */
  24248. alive: boolean;
  24249. /**
  24250. * Is the particle visible or not ?
  24251. */
  24252. isVisible: boolean;
  24253. /**
  24254. * Index of this particle in the global "positions" array (Internal use)
  24255. * @hidden
  24256. */
  24257. _pos: number;
  24258. /**
  24259. * @hidden Index of this particle in the global "indices" array (Internal use)
  24260. */
  24261. _ind: number;
  24262. /**
  24263. * @hidden ModelShape of this particle (Internal use)
  24264. */
  24265. _model: ModelShape;
  24266. /**
  24267. * ModelShape id of this particle
  24268. */
  24269. shapeId: number;
  24270. /**
  24271. * Index of the particle in its shape id (Internal use)
  24272. */
  24273. idxInShape: number;
  24274. /**
  24275. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24276. */
  24277. _modelBoundingInfo: BoundingInfo;
  24278. /**
  24279. * @hidden Particle BoundingInfo object (Internal use)
  24280. */
  24281. _boundingInfo: BoundingInfo;
  24282. /**
  24283. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24284. */
  24285. _sps: SolidParticleSystem;
  24286. /**
  24287. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24288. */
  24289. _stillInvisible: boolean;
  24290. /**
  24291. * @hidden Last computed particle rotation matrix
  24292. */
  24293. _rotationMatrix: number[];
  24294. /**
  24295. * Parent particle Id, if any.
  24296. * Default null.
  24297. */
  24298. parentId: Nullable<number>;
  24299. /**
  24300. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24301. * The possible values are :
  24302. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24303. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24304. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24306. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24307. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24308. * */
  24309. cullingStrategy: number;
  24310. /**
  24311. * @hidden Internal global position in the SPS.
  24312. */
  24313. _globalPosition: Vector3;
  24314. /**
  24315. * Creates a Solid Particle object.
  24316. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24317. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24318. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24319. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24320. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24321. * @param shapeId (integer) is the model shape identifier in the SPS.
  24322. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24323. * @param sps defines the sps it is associated to
  24324. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24325. */
  24326. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24327. /**
  24328. * Legacy support, changed scale to scaling
  24329. */
  24330. /**
  24331. * Legacy support, changed scale to scaling
  24332. */
  24333. scale: Vector3;
  24334. /**
  24335. * Legacy support, changed quaternion to rotationQuaternion
  24336. */
  24337. /**
  24338. * Legacy support, changed quaternion to rotationQuaternion
  24339. */
  24340. quaternion: Nullable<Quaternion>;
  24341. /**
  24342. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24343. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24344. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24345. * @returns true if it intersects
  24346. */
  24347. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24348. /**
  24349. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24350. * A particle is in the frustum if its bounding box intersects the frustum
  24351. * @param frustumPlanes defines the frustum to test
  24352. * @returns true if the particle is in the frustum planes
  24353. */
  24354. isInFrustum(frustumPlanes: Plane[]): boolean;
  24355. /**
  24356. * get the rotation matrix of the particle
  24357. * @hidden
  24358. */
  24359. getRotationMatrix(m: Matrix): void;
  24360. }
  24361. /**
  24362. * Represents the shape of the model used by one particle of a solid particle system.
  24363. * SPS internal tool, don't use it manually.
  24364. */
  24365. export class ModelShape {
  24366. /**
  24367. * The shape id
  24368. * @hidden
  24369. */
  24370. shapeID: number;
  24371. /**
  24372. * flat array of model positions (internal use)
  24373. * @hidden
  24374. */
  24375. _shape: Vector3[];
  24376. /**
  24377. * flat array of model UVs (internal use)
  24378. * @hidden
  24379. */
  24380. _shapeUV: number[];
  24381. /**
  24382. * length of the shape in the model indices array (internal use)
  24383. * @hidden
  24384. */
  24385. _indicesLength: number;
  24386. /**
  24387. * Custom position function (internal use)
  24388. * @hidden
  24389. */
  24390. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24391. /**
  24392. * Custom vertex function (internal use)
  24393. * @hidden
  24394. */
  24395. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24396. /**
  24397. * 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.
  24398. * SPS internal tool, don't use it manually.
  24399. * @hidden
  24400. */
  24401. 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>);
  24402. }
  24403. /**
  24404. * Represents a Depth Sorted Particle in the solid particle system.
  24405. */
  24406. export class DepthSortedParticle {
  24407. /**
  24408. * Index of the particle in the "indices" array
  24409. */
  24410. ind: number;
  24411. /**
  24412. * Length of the particle shape in the "indices" array
  24413. */
  24414. indicesLength: number;
  24415. /**
  24416. * Squared distance from the particle to the camera
  24417. */
  24418. sqDistance: number;
  24419. }
  24420. }
  24421. declare module "babylonjs/Meshes/abstractMesh" {
  24422. import { Observable } from "babylonjs/Misc/observable";
  24423. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24424. import { Camera } from "babylonjs/Cameras/camera";
  24425. import { Scene, IDisposable } from "babylonjs/scene";
  24426. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24427. import { Node } from "babylonjs/node";
  24428. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24430. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24431. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24432. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24433. import { Material } from "babylonjs/Materials/material";
  24434. import { Light } from "babylonjs/Lights/light";
  24435. import { Skeleton } from "babylonjs/Bones/skeleton";
  24436. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24437. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24438. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24439. import { Ray } from "babylonjs/Culling/ray";
  24440. import { Collider } from "babylonjs/Collisions/collider";
  24441. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24442. /**
  24443. * Class used to store all common mesh properties
  24444. */
  24445. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24446. /** No occlusion */
  24447. static OCCLUSION_TYPE_NONE: number;
  24448. /** Occlusion set to optimisitic */
  24449. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24450. /** Occlusion set to strict */
  24451. static OCCLUSION_TYPE_STRICT: number;
  24452. /** Use an accurante occlusion algorithm */
  24453. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24454. /** Use a conservative occlusion algorithm */
  24455. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24456. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24457. * Test order :
  24458. * Is the bounding sphere outside the frustum ?
  24459. * If not, are the bounding box vertices outside the frustum ?
  24460. * It not, then the cullable object is in the frustum.
  24461. */
  24462. static readonly CULLINGSTRATEGY_STANDARD: number;
  24463. /** Culling strategy : Bounding Sphere Only.
  24464. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24465. * It's also less accurate than the standard because some not visible objects can still be selected.
  24466. * Test : is the bounding sphere outside the frustum ?
  24467. * If not, then the cullable object is in the frustum.
  24468. */
  24469. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24470. /** Culling strategy : Optimistic Inclusion.
  24471. * This in an inclusion test first, then the standard exclusion test.
  24472. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24473. * 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.
  24474. * Anyway, it's as accurate as the standard strategy.
  24475. * Test :
  24476. * Is the cullable object bounding sphere center in the frustum ?
  24477. * If not, apply the default culling strategy.
  24478. */
  24479. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24480. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24481. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24482. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24483. * 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.
  24484. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24485. * Test :
  24486. * Is the cullable object bounding sphere center in the frustum ?
  24487. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24488. */
  24489. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24490. /**
  24491. * No billboard
  24492. */
  24493. static readonly BILLBOARDMODE_NONE: number;
  24494. /** Billboard on X axis */
  24495. static readonly BILLBOARDMODE_X: number;
  24496. /** Billboard on Y axis */
  24497. static readonly BILLBOARDMODE_Y: number;
  24498. /** Billboard on Z axis */
  24499. static readonly BILLBOARDMODE_Z: number;
  24500. /** Billboard on all axes */
  24501. static readonly BILLBOARDMODE_ALL: number;
  24502. private _facetData;
  24503. /**
  24504. * The culling strategy to use to check whether the mesh must be rendered or not.
  24505. * This value can be changed at any time and will be used on the next render mesh selection.
  24506. * The possible values are :
  24507. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24508. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24509. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24510. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24511. * Please read each static variable documentation to get details about the culling process.
  24512. * */
  24513. cullingStrategy: number;
  24514. /**
  24515. * Gets the number of facets in the mesh
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24517. */
  24518. readonly facetNb: number;
  24519. /**
  24520. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24522. */
  24523. partitioningSubdivisions: number;
  24524. /**
  24525. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24526. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24528. */
  24529. partitioningBBoxRatio: number;
  24530. /**
  24531. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24532. * Works only for updatable meshes.
  24533. * Doesn't work with multi-materials
  24534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24535. */
  24536. mustDepthSortFacets: boolean;
  24537. /**
  24538. * The location (Vector3) where the facet depth sort must be computed from.
  24539. * By default, the active camera position.
  24540. * Used only when facet depth sort is enabled
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24542. */
  24543. facetDepthSortFrom: Vector3;
  24544. /**
  24545. * gets a boolean indicating if facetData is enabled
  24546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24547. */
  24548. readonly isFacetDataEnabled: boolean;
  24549. /** @hidden */
  24550. _updateNonUniformScalingState(value: boolean): boolean;
  24551. /**
  24552. * An event triggered when this mesh collides with another one
  24553. */
  24554. onCollideObservable: Observable<AbstractMesh>;
  24555. private _onCollideObserver;
  24556. /** Set a function to call when this mesh collides with another one */
  24557. onCollide: () => void;
  24558. /**
  24559. * An event triggered when the collision's position changes
  24560. */
  24561. onCollisionPositionChangeObservable: Observable<Vector3>;
  24562. private _onCollisionPositionChangeObserver;
  24563. /** Set a function to call when the collision's position changes */
  24564. onCollisionPositionChange: () => void;
  24565. /**
  24566. * An event triggered when material is changed
  24567. */
  24568. onMaterialChangedObservable: Observable<AbstractMesh>;
  24569. /**
  24570. * Gets or sets the orientation for POV movement & rotation
  24571. */
  24572. definedFacingForward: boolean;
  24573. /** @hidden */
  24574. _occlusionQuery: Nullable<WebGLQuery>;
  24575. private _visibility;
  24576. /**
  24577. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24578. */
  24579. /**
  24580. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24581. */
  24582. visibility: number;
  24583. /** Gets or sets the alpha index used to sort transparent meshes
  24584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24585. */
  24586. alphaIndex: number;
  24587. /**
  24588. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24589. */
  24590. isVisible: boolean;
  24591. /**
  24592. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24593. */
  24594. isPickable: boolean;
  24595. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24596. showSubMeshesBoundingBox: boolean;
  24597. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24599. */
  24600. isBlocker: boolean;
  24601. /**
  24602. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24603. */
  24604. enablePointerMoveEvents: boolean;
  24605. /**
  24606. * Specifies the rendering group id for this mesh (0 by default)
  24607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24608. */
  24609. renderingGroupId: number;
  24610. private _material;
  24611. /** Gets or sets current material */
  24612. material: Nullable<Material>;
  24613. private _receiveShadows;
  24614. /**
  24615. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24616. * @see http://doc.babylonjs.com/babylon101/shadows
  24617. */
  24618. receiveShadows: boolean;
  24619. /** Defines color to use when rendering outline */
  24620. outlineColor: Color3;
  24621. /** Define width to use when rendering outline */
  24622. outlineWidth: number;
  24623. /** Defines color to use when rendering overlay */
  24624. overlayColor: Color3;
  24625. /** Defines alpha to use when rendering overlay */
  24626. overlayAlpha: number;
  24627. private _hasVertexAlpha;
  24628. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24629. hasVertexAlpha: boolean;
  24630. private _useVertexColors;
  24631. /** 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) */
  24632. useVertexColors: boolean;
  24633. private _computeBonesUsingShaders;
  24634. /**
  24635. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24636. */
  24637. computeBonesUsingShaders: boolean;
  24638. private _numBoneInfluencers;
  24639. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24640. numBoneInfluencers: number;
  24641. private _applyFog;
  24642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24643. applyFog: boolean;
  24644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24645. useOctreeForRenderingSelection: boolean;
  24646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24647. useOctreeForPicking: boolean;
  24648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24649. useOctreeForCollisions: boolean;
  24650. private _layerMask;
  24651. /**
  24652. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24653. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24654. */
  24655. layerMask: number;
  24656. /**
  24657. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24658. */
  24659. alwaysSelectAsActiveMesh: boolean;
  24660. /**
  24661. * Gets or sets the current action manager
  24662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24663. */
  24664. actionManager: Nullable<AbstractActionManager>;
  24665. private _checkCollisions;
  24666. private _collisionMask;
  24667. private _collisionGroup;
  24668. /**
  24669. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24671. */
  24672. ellipsoid: Vector3;
  24673. /**
  24674. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24675. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24676. */
  24677. ellipsoidOffset: Vector3;
  24678. private _collider;
  24679. private _oldPositionForCollisions;
  24680. private _diffPositionForCollisions;
  24681. /**
  24682. * Gets or sets a collision mask used to mask collisions (default is -1).
  24683. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24684. */
  24685. collisionMask: number;
  24686. /**
  24687. * Gets or sets the current collision group mask (-1 by default).
  24688. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24689. */
  24690. collisionGroup: number;
  24691. /**
  24692. * Defines edge width used when edgesRenderer is enabled
  24693. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24694. */
  24695. edgesWidth: number;
  24696. /**
  24697. * Defines edge color used when edgesRenderer is enabled
  24698. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24699. */
  24700. edgesColor: Color4;
  24701. /** @hidden */
  24702. _edgesRenderer: Nullable<IEdgesRenderer>;
  24703. /** @hidden */
  24704. _masterMesh: Nullable<AbstractMesh>;
  24705. /** @hidden */
  24706. _boundingInfo: Nullable<BoundingInfo>;
  24707. /** @hidden */
  24708. _renderId: number;
  24709. /**
  24710. * Gets or sets the list of subMeshes
  24711. * @see http://doc.babylonjs.com/how_to/multi_materials
  24712. */
  24713. subMeshes: SubMesh[];
  24714. /** @hidden */
  24715. _intersectionsInProgress: AbstractMesh[];
  24716. /** @hidden */
  24717. _unIndexed: boolean;
  24718. /** @hidden */
  24719. _lightSources: Light[];
  24720. /** @hidden */
  24721. readonly _positions: Nullable<Vector3[]>;
  24722. /** @hidden */
  24723. _waitingActions: any;
  24724. /** @hidden */
  24725. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24726. private _skeleton;
  24727. /** @hidden */
  24728. _bonesTransformMatrices: Nullable<Float32Array>;
  24729. /**
  24730. * Gets or sets a skeleton to apply skining transformations
  24731. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24732. */
  24733. skeleton: Nullable<Skeleton>;
  24734. /**
  24735. * An event triggered when the mesh is rebuilt.
  24736. */
  24737. onRebuildObservable: Observable<AbstractMesh>;
  24738. /**
  24739. * Creates a new AbstractMesh
  24740. * @param name defines the name of the mesh
  24741. * @param scene defines the hosting scene
  24742. */
  24743. constructor(name: string, scene?: Nullable<Scene>);
  24744. /**
  24745. * Returns the string "AbstractMesh"
  24746. * @returns "AbstractMesh"
  24747. */
  24748. getClassName(): string;
  24749. /**
  24750. * Gets a string representation of the current mesh
  24751. * @param fullDetails defines a boolean indicating if full details must be included
  24752. * @returns a string representation of the current mesh
  24753. */
  24754. toString(fullDetails?: boolean): string;
  24755. /** @hidden */
  24756. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24757. /** @hidden */
  24758. _rebuild(): void;
  24759. /** @hidden */
  24760. _resyncLightSources(): void;
  24761. /** @hidden */
  24762. _resyncLighSource(light: Light): void;
  24763. /** @hidden */
  24764. _unBindEffect(): void;
  24765. /** @hidden */
  24766. _removeLightSource(light: Light): void;
  24767. private _markSubMeshesAsDirty;
  24768. /** @hidden */
  24769. _markSubMeshesAsLightDirty(): void;
  24770. /** @hidden */
  24771. _markSubMeshesAsAttributesDirty(): void;
  24772. /** @hidden */
  24773. _markSubMeshesAsMiscDirty(): void;
  24774. /**
  24775. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24776. */
  24777. scaling: Vector3;
  24778. /**
  24779. * Returns true if the mesh is blocked. Implemented by child classes
  24780. */
  24781. readonly isBlocked: boolean;
  24782. /**
  24783. * Returns the mesh itself by default. Implemented by child classes
  24784. * @param camera defines the camera to use to pick the right LOD level
  24785. * @returns the currentAbstractMesh
  24786. */
  24787. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24788. /**
  24789. * Returns 0 by default. Implemented by child classes
  24790. * @returns an integer
  24791. */
  24792. getTotalVertices(): number;
  24793. /**
  24794. * Returns a positive integer : the total number of indices in this mesh geometry.
  24795. * @returns the numner of indices or zero if the mesh has no geometry.
  24796. */
  24797. getTotalIndices(): number;
  24798. /**
  24799. * Returns null by default. Implemented by child classes
  24800. * @returns null
  24801. */
  24802. getIndices(): Nullable<IndicesArray>;
  24803. /**
  24804. * Returns the array of the requested vertex data kind. Implemented by child classes
  24805. * @param kind defines the vertex data kind to use
  24806. * @returns null
  24807. */
  24808. getVerticesData(kind: string): Nullable<FloatArray>;
  24809. /**
  24810. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24811. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24812. * Note that a new underlying VertexBuffer object is created each call.
  24813. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24814. * @param kind defines vertex data kind:
  24815. * * VertexBuffer.PositionKind
  24816. * * VertexBuffer.UVKind
  24817. * * VertexBuffer.UV2Kind
  24818. * * VertexBuffer.UV3Kind
  24819. * * VertexBuffer.UV4Kind
  24820. * * VertexBuffer.UV5Kind
  24821. * * VertexBuffer.UV6Kind
  24822. * * VertexBuffer.ColorKind
  24823. * * VertexBuffer.MatricesIndicesKind
  24824. * * VertexBuffer.MatricesIndicesExtraKind
  24825. * * VertexBuffer.MatricesWeightsKind
  24826. * * VertexBuffer.MatricesWeightsExtraKind
  24827. * @param data defines the data source
  24828. * @param updatable defines if the data must be flagged as updatable (or static)
  24829. * @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
  24830. * @returns the current mesh
  24831. */
  24832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24833. /**
  24834. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24835. * If the mesh has no geometry, it is simply returned as it is.
  24836. * @param kind defines vertex data kind:
  24837. * * VertexBuffer.PositionKind
  24838. * * VertexBuffer.UVKind
  24839. * * VertexBuffer.UV2Kind
  24840. * * VertexBuffer.UV3Kind
  24841. * * VertexBuffer.UV4Kind
  24842. * * VertexBuffer.UV5Kind
  24843. * * VertexBuffer.UV6Kind
  24844. * * VertexBuffer.ColorKind
  24845. * * VertexBuffer.MatricesIndicesKind
  24846. * * VertexBuffer.MatricesIndicesExtraKind
  24847. * * VertexBuffer.MatricesWeightsKind
  24848. * * VertexBuffer.MatricesWeightsExtraKind
  24849. * @param data defines the data source
  24850. * @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
  24851. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24852. * @returns the current mesh
  24853. */
  24854. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24855. /**
  24856. * Sets the mesh indices,
  24857. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24858. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24859. * @param totalVertices Defines the total number of vertices
  24860. * @returns the current mesh
  24861. */
  24862. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24863. /**
  24864. * Gets a boolean indicating if specific vertex data is present
  24865. * @param kind defines the vertex data kind to use
  24866. * @returns true is data kind is present
  24867. */
  24868. isVerticesDataPresent(kind: string): boolean;
  24869. /**
  24870. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24871. * @returns a BoundingInfo
  24872. */
  24873. getBoundingInfo(): BoundingInfo;
  24874. /**
  24875. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24876. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24877. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24878. * @returns the current mesh
  24879. */
  24880. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24881. /**
  24882. * Overwrite the current bounding info
  24883. * @param boundingInfo defines the new bounding info
  24884. * @returns the current mesh
  24885. */
  24886. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24887. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24888. readonly useBones: boolean;
  24889. /** @hidden */
  24890. _preActivate(): void;
  24891. /** @hidden */
  24892. _preActivateForIntermediateRendering(renderId: number): void;
  24893. /** @hidden */
  24894. _activate(renderId: number): void;
  24895. /**
  24896. * Gets the current world matrix
  24897. * @returns a Matrix
  24898. */
  24899. getWorldMatrix(): Matrix;
  24900. /** @hidden */
  24901. _getWorldMatrixDeterminant(): number;
  24902. /**
  24903. * Perform relative position change from the point of view of behind the front of the mesh.
  24904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24905. * Supports definition of mesh facing forward or backward
  24906. * @param amountRight defines the distance on the right axis
  24907. * @param amountUp defines the distance on the up axis
  24908. * @param amountForward defines the distance on the forward axis
  24909. * @returns the current mesh
  24910. */
  24911. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24912. /**
  24913. * Calculate relative position change from the point of view of behind the front of the mesh.
  24914. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24915. * Supports definition of mesh facing forward or backward
  24916. * @param amountRight defines the distance on the right axis
  24917. * @param amountUp defines the distance on the up axis
  24918. * @param amountForward defines the distance on the forward axis
  24919. * @returns the new displacement vector
  24920. */
  24921. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24922. /**
  24923. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24924. * Supports definition of mesh facing forward or backward
  24925. * @param flipBack defines the flip
  24926. * @param twirlClockwise defines the twirl
  24927. * @param tiltRight defines the tilt
  24928. * @returns the current mesh
  24929. */
  24930. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24931. /**
  24932. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24933. * Supports definition of mesh facing forward or backward.
  24934. * @param flipBack defines the flip
  24935. * @param twirlClockwise defines the twirl
  24936. * @param tiltRight defines the tilt
  24937. * @returns the new rotation vector
  24938. */
  24939. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24940. /**
  24941. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24942. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24943. * @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
  24944. * @returns the new bounding vectors
  24945. */
  24946. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24947. min: Vector3;
  24948. max: Vector3;
  24949. };
  24950. /**
  24951. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24952. * This means the mesh underlying bounding box and sphere are recomputed.
  24953. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24954. * @returns the current mesh
  24955. */
  24956. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24957. /** @hidden */
  24958. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24959. /** @hidden */
  24960. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24961. /** @hidden */
  24962. _updateBoundingInfo(): AbstractMesh;
  24963. /** @hidden */
  24964. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24965. /** @hidden */
  24966. protected _afterComputeWorldMatrix(): void;
  24967. /** @hidden */
  24968. readonly _effectiveMesh: AbstractMesh;
  24969. /**
  24970. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24971. * A mesh is in the frustum if its bounding box intersects the frustum
  24972. * @param frustumPlanes defines the frustum to test
  24973. * @returns true if the mesh is in the frustum planes
  24974. */
  24975. isInFrustum(frustumPlanes: Plane[]): boolean;
  24976. /**
  24977. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24978. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24979. * @param frustumPlanes defines the frustum to test
  24980. * @returns true if the mesh is completely in the frustum planes
  24981. */
  24982. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24983. /**
  24984. * True if the mesh intersects another mesh or a SolidParticle object
  24985. * @param mesh defines a target mesh or SolidParticle to test
  24986. * @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)
  24987. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24988. * @returns true if there is an intersection
  24989. */
  24990. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24991. /**
  24992. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24993. * @param point defines the point to test
  24994. * @returns true if there is an intersection
  24995. */
  24996. intersectsPoint(point: Vector3): boolean;
  24997. /**
  24998. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25000. */
  25001. checkCollisions: boolean;
  25002. /**
  25003. * Gets Collider object used to compute collisions (not physics)
  25004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25005. */
  25006. readonly collider: Collider;
  25007. /**
  25008. * Move the mesh using collision engine
  25009. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25010. * @param displacement defines the requested displacement vector
  25011. * @returns the current mesh
  25012. */
  25013. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25014. private _onCollisionPositionChange;
  25015. /** @hidden */
  25016. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25017. /** @hidden */
  25018. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25019. /** @hidden */
  25020. _checkCollision(collider: Collider): AbstractMesh;
  25021. /** @hidden */
  25022. _generatePointsArray(): boolean;
  25023. /**
  25024. * Checks if the passed Ray intersects with the mesh
  25025. * @param ray defines the ray to use
  25026. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25027. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25028. * @returns the picking info
  25029. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25030. */
  25031. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25032. /**
  25033. * Clones the current mesh
  25034. * @param name defines the mesh name
  25035. * @param newParent defines the new mesh parent
  25036. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25037. * @returns the new mesh
  25038. */
  25039. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25040. /**
  25041. * Disposes all the submeshes of the current meshnp
  25042. * @returns the current mesh
  25043. */
  25044. releaseSubMeshes(): AbstractMesh;
  25045. /**
  25046. * Releases resources associated with this abstract mesh.
  25047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25049. */
  25050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25051. /**
  25052. * Adds the passed mesh as a child to the current mesh
  25053. * @param mesh defines the child mesh
  25054. * @returns the current mesh
  25055. */
  25056. addChild(mesh: AbstractMesh): AbstractMesh;
  25057. /**
  25058. * Removes the passed mesh from the current mesh children list
  25059. * @param mesh defines the child mesh
  25060. * @returns the current mesh
  25061. */
  25062. removeChild(mesh: AbstractMesh): AbstractMesh;
  25063. /** @hidden */
  25064. private _initFacetData;
  25065. /**
  25066. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25067. * This method can be called within the render loop.
  25068. * 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
  25069. * @returns the current mesh
  25070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25071. */
  25072. updateFacetData(): AbstractMesh;
  25073. /**
  25074. * Returns the facetLocalNormals array.
  25075. * The normals are expressed in the mesh local spac
  25076. * @returns an array of Vector3
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25078. */
  25079. getFacetLocalNormals(): Vector3[];
  25080. /**
  25081. * Returns the facetLocalPositions array.
  25082. * The facet positions are expressed in the mesh local space
  25083. * @returns an array of Vector3
  25084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25085. */
  25086. getFacetLocalPositions(): Vector3[];
  25087. /**
  25088. * Returns the facetLocalPartioning array
  25089. * @returns an array of array of numbers
  25090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25091. */
  25092. getFacetLocalPartitioning(): number[][];
  25093. /**
  25094. * Returns the i-th facet position in the world system.
  25095. * This method allocates a new Vector3 per call
  25096. * @param i defines the facet index
  25097. * @returns a new Vector3
  25098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25099. */
  25100. getFacetPosition(i: number): Vector3;
  25101. /**
  25102. * Sets the reference Vector3 with the i-th facet position in the world system
  25103. * @param i defines the facet index
  25104. * @param ref defines the target vector
  25105. * @returns the current mesh
  25106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25107. */
  25108. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25109. /**
  25110. * Returns the i-th facet normal in the world system.
  25111. * This method allocates a new Vector3 per call
  25112. * @param i defines the facet index
  25113. * @returns a new Vector3
  25114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25115. */
  25116. getFacetNormal(i: number): Vector3;
  25117. /**
  25118. * Sets the reference Vector3 with the i-th facet normal in the world system
  25119. * @param i defines the facet index
  25120. * @param ref defines the target vector
  25121. * @returns the current mesh
  25122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25123. */
  25124. getFacetNormalToRef(i: number, ref: Vector3): this;
  25125. /**
  25126. * 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)
  25127. * @param x defines x coordinate
  25128. * @param y defines y coordinate
  25129. * @param z defines z coordinate
  25130. * @returns the array of facet indexes
  25131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25132. */
  25133. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25134. /**
  25135. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25136. * @param projected sets as the (x,y,z) world projection on the facet
  25137. * @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
  25138. * @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
  25139. * @param x defines x coordinate
  25140. * @param y defines y coordinate
  25141. * @param z defines z coordinate
  25142. * @returns the face index if found (or null instead)
  25143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25144. */
  25145. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25146. /**
  25147. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25148. * @param projected sets as the (x,y,z) local projection on the facet
  25149. * @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
  25150. * @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
  25151. * @param x defines x coordinate
  25152. * @param y defines y coordinate
  25153. * @param z defines z coordinate
  25154. * @returns the face index if found (or null instead)
  25155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25156. */
  25157. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25158. /**
  25159. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25160. * @returns the parameters
  25161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25162. */
  25163. getFacetDataParameters(): any;
  25164. /**
  25165. * Disables the feature FacetData and frees the related memory
  25166. * @returns the current mesh
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25168. */
  25169. disableFacetData(): AbstractMesh;
  25170. /**
  25171. * Updates the AbstractMesh indices array
  25172. * @param indices defines the data source
  25173. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25174. * @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)
  25175. * @returns the current mesh
  25176. */
  25177. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25178. /**
  25179. * Creates new normals data for the mesh
  25180. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25181. * @returns the current mesh
  25182. */
  25183. createNormals(updatable: boolean): AbstractMesh;
  25184. /**
  25185. * Align the mesh with a normal
  25186. * @param normal defines the normal to use
  25187. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25188. * @returns the current mesh
  25189. */
  25190. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25191. /** @hidden */
  25192. _checkOcclusionQuery(): boolean;
  25193. }
  25194. }
  25195. declare module "babylonjs/Actions/actionEvent" {
  25196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25197. import { Nullable } from "babylonjs/types";
  25198. import { Sprite } from "babylonjs/Sprites/sprite";
  25199. import { Scene } from "babylonjs/scene";
  25200. import { Vector2 } from "babylonjs/Maths/math";
  25201. /**
  25202. * Interface used to define ActionEvent
  25203. */
  25204. export interface IActionEvent {
  25205. /** The mesh or sprite that triggered the action */
  25206. source: any;
  25207. /** The X mouse cursor position at the time of the event */
  25208. pointerX: number;
  25209. /** The Y mouse cursor position at the time of the event */
  25210. pointerY: number;
  25211. /** The mesh that is currently pointed at (can be null) */
  25212. meshUnderPointer: Nullable<AbstractMesh>;
  25213. /** the original (browser) event that triggered the ActionEvent */
  25214. sourceEvent?: any;
  25215. /** additional data for the event */
  25216. additionalData?: any;
  25217. }
  25218. /**
  25219. * ActionEvent is the event being sent when an action is triggered.
  25220. */
  25221. export class ActionEvent implements IActionEvent {
  25222. /** The mesh or sprite that triggered the action */
  25223. source: any;
  25224. /** The X mouse cursor position at the time of the event */
  25225. pointerX: number;
  25226. /** The Y mouse cursor position at the time of the event */
  25227. pointerY: number;
  25228. /** The mesh that is currently pointed at (can be null) */
  25229. meshUnderPointer: Nullable<AbstractMesh>;
  25230. /** the original (browser) event that triggered the ActionEvent */
  25231. sourceEvent?: any;
  25232. /** additional data for the event */
  25233. additionalData?: any;
  25234. /**
  25235. * Creates a new ActionEvent
  25236. * @param source The mesh or sprite that triggered the action
  25237. * @param pointerX The X mouse cursor position at the time of the event
  25238. * @param pointerY The Y mouse cursor position at the time of the event
  25239. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25240. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25241. * @param additionalData additional data for the event
  25242. */
  25243. constructor(
  25244. /** The mesh or sprite that triggered the action */
  25245. source: any,
  25246. /** The X mouse cursor position at the time of the event */
  25247. pointerX: number,
  25248. /** The Y mouse cursor position at the time of the event */
  25249. pointerY: number,
  25250. /** The mesh that is currently pointed at (can be null) */
  25251. meshUnderPointer: Nullable<AbstractMesh>,
  25252. /** the original (browser) event that triggered the ActionEvent */
  25253. sourceEvent?: any,
  25254. /** additional data for the event */
  25255. additionalData?: any);
  25256. /**
  25257. * Helper function to auto-create an ActionEvent from a source mesh.
  25258. * @param source The source mesh that triggered the event
  25259. * @param evt The original (browser) event
  25260. * @param additionalData additional data for the event
  25261. * @returns the new ActionEvent
  25262. */
  25263. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25264. /**
  25265. * Helper function to auto-create an ActionEvent from a source sprite
  25266. * @param source The source sprite that triggered the event
  25267. * @param scene Scene associated with the sprite
  25268. * @param evt The original (browser) event
  25269. * @param additionalData additional data for the event
  25270. * @returns the new ActionEvent
  25271. */
  25272. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25273. /**
  25274. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25275. * @param scene the scene where the event occurred
  25276. * @param evt The original (browser) event
  25277. * @returns the new ActionEvent
  25278. */
  25279. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25280. /**
  25281. * Helper function to auto-create an ActionEvent from a primitive
  25282. * @param prim defines the target primitive
  25283. * @param pointerPos defines the pointer position
  25284. * @param evt The original (browser) event
  25285. * @param additionalData additional data for the event
  25286. * @returns the new ActionEvent
  25287. */
  25288. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25289. }
  25290. }
  25291. declare module "babylonjs/Actions/abstractActionManager" {
  25292. import { IDisposable } from "babylonjs/scene";
  25293. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25294. import { IAction } from "babylonjs/Actions/action";
  25295. import { Nullable } from "babylonjs/types";
  25296. /**
  25297. * Abstract class used to decouple action Manager from scene and meshes.
  25298. * Do not instantiate.
  25299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25300. */
  25301. export abstract class AbstractActionManager implements IDisposable {
  25302. /** Gets the list of active triggers */
  25303. static Triggers: {
  25304. [key: string]: number;
  25305. };
  25306. /** Gets the cursor to use when hovering items */
  25307. hoverCursor: string;
  25308. /** Gets the list of actions */
  25309. actions: IAction[];
  25310. /**
  25311. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25312. */
  25313. isRecursive: boolean;
  25314. /**
  25315. * Releases all associated resources
  25316. */
  25317. abstract dispose(): void;
  25318. /**
  25319. * Does this action manager has pointer triggers
  25320. */
  25321. abstract readonly hasPointerTriggers: boolean;
  25322. /**
  25323. * Does this action manager has pick triggers
  25324. */
  25325. abstract readonly hasPickTriggers: boolean;
  25326. /**
  25327. * Process a specific trigger
  25328. * @param trigger defines the trigger to process
  25329. * @param evt defines the event details to be processed
  25330. */
  25331. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25332. /**
  25333. * Does this action manager handles actions of any of the given triggers
  25334. * @param triggers defines the triggers to be tested
  25335. * @return a boolean indicating whether one (or more) of the triggers is handled
  25336. */
  25337. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25338. /**
  25339. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25340. * speed.
  25341. * @param triggerA defines the trigger to be tested
  25342. * @param triggerB defines the trigger to be tested
  25343. * @return a boolean indicating whether one (or more) of the triggers is handled
  25344. */
  25345. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25346. /**
  25347. * Does this action manager handles actions of a given trigger
  25348. * @param trigger defines the trigger to be tested
  25349. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25350. * @return whether the trigger is handled
  25351. */
  25352. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25353. /**
  25354. * Serialize this manager to a JSON object
  25355. * @param name defines the property name to store this manager
  25356. * @returns a JSON representation of this manager
  25357. */
  25358. abstract serialize(name: string): any;
  25359. /**
  25360. * Registers an action to this action manager
  25361. * @param action defines the action to be registered
  25362. * @return the action amended (prepared) after registration
  25363. */
  25364. abstract registerAction(action: IAction): Nullable<IAction>;
  25365. /**
  25366. * Unregisters an action to this action manager
  25367. * @param action defines the action to be unregistered
  25368. * @return a boolean indicating whether the action has been unregistered
  25369. */
  25370. abstract unregisterAction(action: IAction): Boolean;
  25371. /**
  25372. * Does exist one action manager with at least one trigger
  25373. **/
  25374. static readonly HasTriggers: boolean;
  25375. /**
  25376. * Does exist one action manager with at least one pick trigger
  25377. **/
  25378. static readonly HasPickTriggers: boolean;
  25379. /**
  25380. * Does exist one action manager that handles actions of a given trigger
  25381. * @param trigger defines the trigger to be tested
  25382. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25383. **/
  25384. static HasSpecificTrigger(trigger: number): boolean;
  25385. }
  25386. }
  25387. declare module "babylonjs/node" {
  25388. import { Scene } from "babylonjs/scene";
  25389. import { Nullable } from "babylonjs/types";
  25390. import { Matrix } from "babylonjs/Maths/math";
  25391. import { Engine } from "babylonjs/Engines/engine";
  25392. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25393. import { Observable } from "babylonjs/Misc/observable";
  25394. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25395. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25396. import { Animatable } from "babylonjs/Animations/animatable";
  25397. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25398. import { Animation } from "babylonjs/Animations/animation";
  25399. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25401. /**
  25402. * Defines how a node can be built from a string name.
  25403. */
  25404. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25405. /**
  25406. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25407. */
  25408. export class Node implements IBehaviorAware<Node> {
  25409. /** @hidden */
  25410. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25411. private static _NodeConstructors;
  25412. /**
  25413. * Add a new node constructor
  25414. * @param type defines the type name of the node to construct
  25415. * @param constructorFunc defines the constructor function
  25416. */
  25417. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25418. /**
  25419. * Returns a node constructor based on type name
  25420. * @param type defines the type name
  25421. * @param name defines the new node name
  25422. * @param scene defines the hosting scene
  25423. * @param options defines optional options to transmit to constructors
  25424. * @returns the new constructor or null
  25425. */
  25426. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25427. /**
  25428. * Gets or sets the name of the node
  25429. */
  25430. name: string;
  25431. /**
  25432. * Gets or sets the id of the node
  25433. */
  25434. id: string;
  25435. /**
  25436. * Gets or sets the unique id of the node
  25437. */
  25438. uniqueId: number;
  25439. /**
  25440. * Gets or sets a string used to store user defined state for the node
  25441. */
  25442. state: string;
  25443. /**
  25444. * Gets or sets an object used to store user defined information for the node
  25445. */
  25446. metadata: any;
  25447. /**
  25448. * For internal use only. Please do not use.
  25449. */
  25450. reservedDataStore: any;
  25451. /**
  25452. * List of inspectable custom properties (used by the Inspector)
  25453. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25454. */
  25455. inspectableCustomProperties: IInspectable[];
  25456. /**
  25457. * Gets or sets a boolean used to define if the node must be serialized
  25458. */
  25459. doNotSerialize: boolean;
  25460. /** @hidden */
  25461. _isDisposed: boolean;
  25462. /**
  25463. * Gets a list of Animations associated with the node
  25464. */
  25465. animations: import("babylonjs/Animations/animation").Animation[];
  25466. protected _ranges: {
  25467. [name: string]: Nullable<AnimationRange>;
  25468. };
  25469. /**
  25470. * Callback raised when the node is ready to be used
  25471. */
  25472. onReady: (node: Node) => void;
  25473. private _isEnabled;
  25474. private _isParentEnabled;
  25475. private _isReady;
  25476. /** @hidden */
  25477. _currentRenderId: number;
  25478. private _parentUpdateId;
  25479. protected _childUpdateId: number;
  25480. /** @hidden */
  25481. _waitingParentId: Nullable<string>;
  25482. /** @hidden */
  25483. _scene: Scene;
  25484. /** @hidden */
  25485. _cache: any;
  25486. private _parentNode;
  25487. private _children;
  25488. /** @hidden */
  25489. _worldMatrix: Matrix;
  25490. /** @hidden */
  25491. _worldMatrixDeterminant: number;
  25492. /** @hidden */
  25493. private _sceneRootNodesIndex;
  25494. /**
  25495. * Gets a boolean indicating if the node has been disposed
  25496. * @returns true if the node was disposed
  25497. */
  25498. isDisposed(): boolean;
  25499. /**
  25500. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25501. * @see https://doc.babylonjs.com/how_to/parenting
  25502. */
  25503. parent: Nullable<Node>;
  25504. private addToSceneRootNodes;
  25505. private removeFromSceneRootNodes;
  25506. private _animationPropertiesOverride;
  25507. /**
  25508. * Gets or sets the animation properties override
  25509. */
  25510. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25511. /**
  25512. * Gets a string idenfifying the name of the class
  25513. * @returns "Node" string
  25514. */
  25515. getClassName(): string;
  25516. /** @hidden */
  25517. readonly _isNode: boolean;
  25518. /**
  25519. * An event triggered when the mesh is disposed
  25520. */
  25521. onDisposeObservable: Observable<Node>;
  25522. private _onDisposeObserver;
  25523. /**
  25524. * Sets a callback that will be raised when the node will be disposed
  25525. */
  25526. onDispose: () => void;
  25527. /**
  25528. * Creates a new Node
  25529. * @param name the name and id to be given to this node
  25530. * @param scene the scene this node will be added to
  25531. * @param addToRootNodes the node will be added to scene.rootNodes
  25532. */
  25533. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25534. /**
  25535. * Gets the scene of the node
  25536. * @returns a scene
  25537. */
  25538. getScene(): Scene;
  25539. /**
  25540. * Gets the engine of the node
  25541. * @returns a Engine
  25542. */
  25543. getEngine(): Engine;
  25544. private _behaviors;
  25545. /**
  25546. * Attach a behavior to the node
  25547. * @see http://doc.babylonjs.com/features/behaviour
  25548. * @param behavior defines the behavior to attach
  25549. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25550. * @returns the current Node
  25551. */
  25552. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25553. /**
  25554. * Remove an attached behavior
  25555. * @see http://doc.babylonjs.com/features/behaviour
  25556. * @param behavior defines the behavior to attach
  25557. * @returns the current Node
  25558. */
  25559. removeBehavior(behavior: Behavior<Node>): Node;
  25560. /**
  25561. * Gets the list of attached behaviors
  25562. * @see http://doc.babylonjs.com/features/behaviour
  25563. */
  25564. readonly behaviors: Behavior<Node>[];
  25565. /**
  25566. * Gets an attached behavior by name
  25567. * @param name defines the name of the behavior to look for
  25568. * @see http://doc.babylonjs.com/features/behaviour
  25569. * @returns null if behavior was not found else the requested behavior
  25570. */
  25571. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25572. /**
  25573. * Returns the latest update of the World matrix
  25574. * @returns a Matrix
  25575. */
  25576. getWorldMatrix(): Matrix;
  25577. /** @hidden */
  25578. _getWorldMatrixDeterminant(): number;
  25579. /**
  25580. * Returns directly the latest state of the mesh World matrix.
  25581. * A Matrix is returned.
  25582. */
  25583. readonly worldMatrixFromCache: Matrix;
  25584. /** @hidden */
  25585. _initCache(): void;
  25586. /** @hidden */
  25587. updateCache(force?: boolean): void;
  25588. /** @hidden */
  25589. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25590. /** @hidden */
  25591. _updateCache(ignoreParentClass?: boolean): void;
  25592. /** @hidden */
  25593. _isSynchronized(): boolean;
  25594. /** @hidden */
  25595. _markSyncedWithParent(): void;
  25596. /** @hidden */
  25597. isSynchronizedWithParent(): boolean;
  25598. /** @hidden */
  25599. isSynchronized(): boolean;
  25600. /**
  25601. * Is this node ready to be used/rendered
  25602. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25603. * @return true if the node is ready
  25604. */
  25605. isReady(completeCheck?: boolean): boolean;
  25606. /**
  25607. * Is this node enabled?
  25608. * 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
  25609. * @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
  25610. * @return whether this node (and its parent) is enabled
  25611. */
  25612. isEnabled(checkAncestors?: boolean): boolean;
  25613. /** @hidden */
  25614. protected _syncParentEnabledState(): void;
  25615. /**
  25616. * Set the enabled state of this node
  25617. * @param value defines the new enabled state
  25618. */
  25619. setEnabled(value: boolean): void;
  25620. /**
  25621. * Is this node a descendant of the given node?
  25622. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25623. * @param ancestor defines the parent node to inspect
  25624. * @returns a boolean indicating if this node is a descendant of the given node
  25625. */
  25626. isDescendantOf(ancestor: Node): boolean;
  25627. /** @hidden */
  25628. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25629. /**
  25630. * Will return all nodes that have this node as ascendant
  25631. * @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
  25632. * @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
  25633. * @return all children nodes of all types
  25634. */
  25635. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25636. /**
  25637. * Get all child-meshes of this node
  25638. * @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)
  25639. * @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
  25640. * @returns an array of AbstractMesh
  25641. */
  25642. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25643. /**
  25644. * Get all direct children of this node
  25645. * @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
  25646. * @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)
  25647. * @returns an array of Node
  25648. */
  25649. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25650. /** @hidden */
  25651. _setReady(state: boolean): void;
  25652. /**
  25653. * Get an animation by name
  25654. * @param name defines the name of the animation to look for
  25655. * @returns null if not found else the requested animation
  25656. */
  25657. getAnimationByName(name: string): Nullable<Animation>;
  25658. /**
  25659. * Creates an animation range for this node
  25660. * @param name defines the name of the range
  25661. * @param from defines the starting key
  25662. * @param to defines the end key
  25663. */
  25664. createAnimationRange(name: string, from: number, to: number): void;
  25665. /**
  25666. * Delete a specific animation range
  25667. * @param name defines the name of the range to delete
  25668. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25669. */
  25670. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25671. /**
  25672. * Get an animation range by name
  25673. * @param name defines the name of the animation range to look for
  25674. * @returns null if not found else the requested animation range
  25675. */
  25676. getAnimationRange(name: string): Nullable<AnimationRange>;
  25677. /**
  25678. * Gets the list of all animation ranges defined on this node
  25679. * @returns an array
  25680. */
  25681. getAnimationRanges(): Nullable<AnimationRange>[];
  25682. /**
  25683. * Will start the animation sequence
  25684. * @param name defines the range frames for animation sequence
  25685. * @param loop defines if the animation should loop (false by default)
  25686. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25687. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25688. * @returns the object created for this animation. If range does not exist, it will return null
  25689. */
  25690. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25691. /**
  25692. * Serialize animation ranges into a JSON compatible object
  25693. * @returns serialization object
  25694. */
  25695. serializeAnimationRanges(): any;
  25696. /**
  25697. * Computes the world matrix of the node
  25698. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25699. * @returns the world matrix
  25700. */
  25701. computeWorldMatrix(force?: boolean): Matrix;
  25702. /**
  25703. * Releases resources associated with this node.
  25704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25706. */
  25707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25708. /**
  25709. * Parse animation range data from a serialization object and store them into a given node
  25710. * @param node defines where to store the animation ranges
  25711. * @param parsedNode defines the serialization object to read data from
  25712. * @param scene defines the hosting scene
  25713. */
  25714. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25715. }
  25716. }
  25717. declare module "babylonjs/Animations/animation" {
  25718. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25719. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25720. import { Nullable } from "babylonjs/types";
  25721. import { Scene } from "babylonjs/scene";
  25722. import { IAnimatable } from "babylonjs/Misc/tools";
  25723. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25724. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25725. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25726. import { Node } from "babylonjs/node";
  25727. import { Animatable } from "babylonjs/Animations/animatable";
  25728. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25729. /**
  25730. * Class used to store any kind of animation
  25731. */
  25732. export class Animation {
  25733. /**Name of the animation */
  25734. name: string;
  25735. /**Property to animate */
  25736. targetProperty: string;
  25737. /**The frames per second of the animation */
  25738. framePerSecond: number;
  25739. /**The data type of the animation */
  25740. dataType: number;
  25741. /**The loop mode of the animation */
  25742. loopMode?: number | undefined;
  25743. /**Specifies if blending should be enabled */
  25744. enableBlending?: boolean | undefined;
  25745. /**
  25746. * Use matrix interpolation instead of using direct key value when animating matrices
  25747. */
  25748. static AllowMatricesInterpolation: boolean;
  25749. /**
  25750. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25751. */
  25752. static AllowMatrixDecomposeForInterpolation: boolean;
  25753. /**
  25754. * Stores the key frames of the animation
  25755. */
  25756. private _keys;
  25757. /**
  25758. * Stores the easing function of the animation
  25759. */
  25760. private _easingFunction;
  25761. /**
  25762. * @hidden Internal use only
  25763. */
  25764. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25765. /**
  25766. * The set of event that will be linked to this animation
  25767. */
  25768. private _events;
  25769. /**
  25770. * Stores an array of target property paths
  25771. */
  25772. targetPropertyPath: string[];
  25773. /**
  25774. * Stores the blending speed of the animation
  25775. */
  25776. blendingSpeed: number;
  25777. /**
  25778. * Stores the animation ranges for the animation
  25779. */
  25780. private _ranges;
  25781. /**
  25782. * @hidden Internal use
  25783. */
  25784. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25785. /**
  25786. * Sets up an animation
  25787. * @param property The property to animate
  25788. * @param animationType The animation type to apply
  25789. * @param framePerSecond The frames per second of the animation
  25790. * @param easingFunction The easing function used in the animation
  25791. * @returns The created animation
  25792. */
  25793. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25794. /**
  25795. * Create and start an animation on a node
  25796. * @param name defines the name of the global animation that will be run on all nodes
  25797. * @param node defines the root node where the animation will take place
  25798. * @param targetProperty defines property to animate
  25799. * @param framePerSecond defines the number of frame per second yo use
  25800. * @param totalFrame defines the number of frames in total
  25801. * @param from defines the initial value
  25802. * @param to defines the final value
  25803. * @param loopMode defines which loop mode you want to use (off by default)
  25804. * @param easingFunction defines the easing function to use (linear by default)
  25805. * @param onAnimationEnd defines the callback to call when animation end
  25806. * @returns the animatable created for this animation
  25807. */
  25808. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25809. /**
  25810. * Create and start an animation on a node and its descendants
  25811. * @param name defines the name of the global animation that will be run on all nodes
  25812. * @param node defines the root node where the animation will take place
  25813. * @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
  25814. * @param targetProperty defines property to animate
  25815. * @param framePerSecond defines the number of frame per second to use
  25816. * @param totalFrame defines the number of frames in total
  25817. * @param from defines the initial value
  25818. * @param to defines the final value
  25819. * @param loopMode defines which loop mode you want to use (off by default)
  25820. * @param easingFunction defines the easing function to use (linear by default)
  25821. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25822. * @returns the list of animatables created for all nodes
  25823. * @example https://www.babylonjs-playground.com/#MH0VLI
  25824. */
  25825. 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[]>;
  25826. /**
  25827. * Creates a new animation, merges it with the existing animations and starts it
  25828. * @param name Name of the animation
  25829. * @param node Node which contains the scene that begins the animations
  25830. * @param targetProperty Specifies which property to animate
  25831. * @param framePerSecond The frames per second of the animation
  25832. * @param totalFrame The total number of frames
  25833. * @param from The frame at the beginning of the animation
  25834. * @param to The frame at the end of the animation
  25835. * @param loopMode Specifies the loop mode of the animation
  25836. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25837. * @param onAnimationEnd Callback to run once the animation is complete
  25838. * @returns Nullable animation
  25839. */
  25840. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25841. /**
  25842. * Transition property of an host to the target Value
  25843. * @param property The property to transition
  25844. * @param targetValue The target Value of the property
  25845. * @param host The object where the property to animate belongs
  25846. * @param scene Scene used to run the animation
  25847. * @param frameRate Framerate (in frame/s) to use
  25848. * @param transition The transition type we want to use
  25849. * @param duration The duration of the animation, in milliseconds
  25850. * @param onAnimationEnd Callback trigger at the end of the animation
  25851. * @returns Nullable animation
  25852. */
  25853. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25854. /**
  25855. * Return the array of runtime animations currently using this animation
  25856. */
  25857. readonly runtimeAnimations: RuntimeAnimation[];
  25858. /**
  25859. * Specifies if any of the runtime animations are currently running
  25860. */
  25861. readonly hasRunningRuntimeAnimations: boolean;
  25862. /**
  25863. * Initializes the animation
  25864. * @param name Name of the animation
  25865. * @param targetProperty Property to animate
  25866. * @param framePerSecond The frames per second of the animation
  25867. * @param dataType The data type of the animation
  25868. * @param loopMode The loop mode of the animation
  25869. * @param enableBlending Specifies if blending should be enabled
  25870. */
  25871. constructor(
  25872. /**Name of the animation */
  25873. name: string,
  25874. /**Property to animate */
  25875. targetProperty: string,
  25876. /**The frames per second of the animation */
  25877. framePerSecond: number,
  25878. /**The data type of the animation */
  25879. dataType: number,
  25880. /**The loop mode of the animation */
  25881. loopMode?: number | undefined,
  25882. /**Specifies if blending should be enabled */
  25883. enableBlending?: boolean | undefined);
  25884. /**
  25885. * Converts the animation to a string
  25886. * @param fullDetails support for multiple levels of logging within scene loading
  25887. * @returns String form of the animation
  25888. */
  25889. toString(fullDetails?: boolean): string;
  25890. /**
  25891. * Add an event to this animation
  25892. * @param event Event to add
  25893. */
  25894. addEvent(event: AnimationEvent): void;
  25895. /**
  25896. * Remove all events found at the given frame
  25897. * @param frame The frame to remove events from
  25898. */
  25899. removeEvents(frame: number): void;
  25900. /**
  25901. * Retrieves all the events from the animation
  25902. * @returns Events from the animation
  25903. */
  25904. getEvents(): AnimationEvent[];
  25905. /**
  25906. * Creates an animation range
  25907. * @param name Name of the animation range
  25908. * @param from Starting frame of the animation range
  25909. * @param to Ending frame of the animation
  25910. */
  25911. createRange(name: string, from: number, to: number): void;
  25912. /**
  25913. * Deletes an animation range by name
  25914. * @param name Name of the animation range to delete
  25915. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25916. */
  25917. deleteRange(name: string, deleteFrames?: boolean): void;
  25918. /**
  25919. * Gets the animation range by name, or null if not defined
  25920. * @param name Name of the animation range
  25921. * @returns Nullable animation range
  25922. */
  25923. getRange(name: string): Nullable<AnimationRange>;
  25924. /**
  25925. * Gets the key frames from the animation
  25926. * @returns The key frames of the animation
  25927. */
  25928. getKeys(): Array<IAnimationKey>;
  25929. /**
  25930. * Gets the highest frame rate of the animation
  25931. * @returns Highest frame rate of the animation
  25932. */
  25933. getHighestFrame(): number;
  25934. /**
  25935. * Gets the easing function of the animation
  25936. * @returns Easing function of the animation
  25937. */
  25938. getEasingFunction(): IEasingFunction;
  25939. /**
  25940. * Sets the easing function of the animation
  25941. * @param easingFunction A custom mathematical formula for animation
  25942. */
  25943. setEasingFunction(easingFunction: EasingFunction): void;
  25944. /**
  25945. * Interpolates a scalar linearly
  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 scalar value
  25950. */
  25951. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25952. /**
  25953. * Interpolates a scalar cubically
  25954. * @param startValue Start value of the animation curve
  25955. * @param outTangent End tangent of the animation
  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 scalar value
  25960. */
  25961. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25962. /**
  25963. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  25968. */
  25969. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25970. /**
  25971. * Interpolates a quaternion cubically
  25972. * @param startValue Start value of the animation curve
  25973. * @param outTangent End tangent of the animation curve
  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 Interpolated quaternion value
  25978. */
  25979. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25980. /**
  25981. * Interpolates a Vector3 linearl
  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 scalar value
  25986. */
  25987. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25988. /**
  25989. * Interpolates a Vector3 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 InterpolatedVector3 value
  25996. */
  25997. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25998. /**
  25999. * Interpolates a Vector2 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 Vector2 value
  26004. */
  26005. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26006. /**
  26007. * Interpolates a Vector2 cubically
  26008. * @param startValue Start value of the animation curve
  26009. * @param outTangent End tangent of the animation
  26010. * @param endValue End value of the animation curve
  26011. * @param inTangent Start tangent of the animation curve
  26012. * @param gradient Scalar amount to interpolate
  26013. * @returns Interpolated Vector2 value
  26014. */
  26015. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26016. /**
  26017. * Interpolates a size linearly
  26018. * @param startValue Start value of the animation curve
  26019. * @param endValue End value of the animation curve
  26020. * @param gradient Scalar amount to interpolate
  26021. * @returns Interpolated Size value
  26022. */
  26023. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26024. /**
  26025. * Interpolates a Color3 linearly
  26026. * @param startValue Start value of the animation curve
  26027. * @param endValue End value of the animation curve
  26028. * @param gradient Scalar amount to interpolate
  26029. * @returns Interpolated Color3 value
  26030. */
  26031. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26032. /**
  26033. * @hidden Internal use only
  26034. */
  26035. _getKeyValue(value: any): any;
  26036. /**
  26037. * @hidden Internal use only
  26038. */
  26039. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26040. /**
  26041. * Defines the function to use to interpolate matrices
  26042. * @param startValue defines the start matrix
  26043. * @param endValue defines the end matrix
  26044. * @param gradient defines the gradient between both matrices
  26045. * @param result defines an optional target matrix where to store the interpolation
  26046. * @returns the interpolated matrix
  26047. */
  26048. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26049. /**
  26050. * Makes a copy of the animation
  26051. * @returns Cloned animation
  26052. */
  26053. clone(): Animation;
  26054. /**
  26055. * Sets the key frames of the animation
  26056. * @param values The animation key frames to set
  26057. */
  26058. setKeys(values: Array<IAnimationKey>): void;
  26059. /**
  26060. * Serializes the animation to an object
  26061. * @returns Serialized object
  26062. */
  26063. serialize(): any;
  26064. /**
  26065. * Float animation type
  26066. */
  26067. private static _ANIMATIONTYPE_FLOAT;
  26068. /**
  26069. * Vector3 animation type
  26070. */
  26071. private static _ANIMATIONTYPE_VECTOR3;
  26072. /**
  26073. * Quaternion animation type
  26074. */
  26075. private static _ANIMATIONTYPE_QUATERNION;
  26076. /**
  26077. * Matrix animation type
  26078. */
  26079. private static _ANIMATIONTYPE_MATRIX;
  26080. /**
  26081. * Color3 animation type
  26082. */
  26083. private static _ANIMATIONTYPE_COLOR3;
  26084. /**
  26085. * Vector2 animation type
  26086. */
  26087. private static _ANIMATIONTYPE_VECTOR2;
  26088. /**
  26089. * Size animation type
  26090. */
  26091. private static _ANIMATIONTYPE_SIZE;
  26092. /**
  26093. * Relative Loop Mode
  26094. */
  26095. private static _ANIMATIONLOOPMODE_RELATIVE;
  26096. /**
  26097. * Cycle Loop Mode
  26098. */
  26099. private static _ANIMATIONLOOPMODE_CYCLE;
  26100. /**
  26101. * Constant Loop Mode
  26102. */
  26103. private static _ANIMATIONLOOPMODE_CONSTANT;
  26104. /**
  26105. * Get the float animation type
  26106. */
  26107. static readonly ANIMATIONTYPE_FLOAT: number;
  26108. /**
  26109. * Get the Vector3 animation type
  26110. */
  26111. static readonly ANIMATIONTYPE_VECTOR3: number;
  26112. /**
  26113. * Get the Vector2 animation type
  26114. */
  26115. static readonly ANIMATIONTYPE_VECTOR2: number;
  26116. /**
  26117. * Get the Size animation type
  26118. */
  26119. static readonly ANIMATIONTYPE_SIZE: number;
  26120. /**
  26121. * Get the Quaternion animation type
  26122. */
  26123. static readonly ANIMATIONTYPE_QUATERNION: number;
  26124. /**
  26125. * Get the Matrix animation type
  26126. */
  26127. static readonly ANIMATIONTYPE_MATRIX: number;
  26128. /**
  26129. * Get the Color3 animation type
  26130. */
  26131. static readonly ANIMATIONTYPE_COLOR3: number;
  26132. /**
  26133. * Get the Relative Loop Mode
  26134. */
  26135. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26136. /**
  26137. * Get the Cycle Loop Mode
  26138. */
  26139. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26140. /**
  26141. * Get the Constant Loop Mode
  26142. */
  26143. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26144. /** @hidden */
  26145. static _UniversalLerp(left: any, right: any, amount: number): any;
  26146. /**
  26147. * Parses an animation object and creates an animation
  26148. * @param parsedAnimation Parsed animation object
  26149. * @returns Animation object
  26150. */
  26151. static Parse(parsedAnimation: any): Animation;
  26152. /**
  26153. * Appends the serialized animations from the source animations
  26154. * @param source Source containing the animations
  26155. * @param destination Target to store the animations
  26156. */
  26157. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26158. }
  26159. }
  26160. declare module "babylonjs/Materials/Textures/baseTexture" {
  26161. import { Observable } from "babylonjs/Misc/observable";
  26162. import { IAnimatable } from "babylonjs/Misc/tools";
  26163. import { Nullable } from "babylonjs/types";
  26164. import { Scene } from "babylonjs/scene";
  26165. import { Matrix, ISize } from "babylonjs/Maths/math";
  26166. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26168. /**
  26169. * Base class of all the textures in babylon.
  26170. * It groups all the common properties the materials, post process, lights... might need
  26171. * in order to make a correct use of the texture.
  26172. */
  26173. export class BaseTexture implements IAnimatable {
  26174. /**
  26175. * Default anisotropic filtering level for the application.
  26176. * It is set to 4 as a good tradeoff between perf and quality.
  26177. */
  26178. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26179. /**
  26180. * Gets or sets the unique id of the texture
  26181. */
  26182. uniqueId: number;
  26183. /**
  26184. * Define the name of the texture.
  26185. */
  26186. name: string;
  26187. /**
  26188. * Gets or sets an object used to store user defined information.
  26189. */
  26190. metadata: any;
  26191. /**
  26192. * For internal use only. Please do not use.
  26193. */
  26194. reservedDataStore: any;
  26195. private _hasAlpha;
  26196. /**
  26197. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26198. */
  26199. hasAlpha: boolean;
  26200. /**
  26201. * Defines if the alpha value should be determined via the rgb values.
  26202. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26203. */
  26204. getAlphaFromRGB: boolean;
  26205. /**
  26206. * Intensity or strength of the texture.
  26207. * It is commonly used by materials to fine tune the intensity of the texture
  26208. */
  26209. level: number;
  26210. /**
  26211. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26212. * This is part of the texture as textures usually maps to one uv set.
  26213. */
  26214. coordinatesIndex: number;
  26215. private _coordinatesMode;
  26216. /**
  26217. * How a texture is mapped.
  26218. *
  26219. * | Value | Type | Description |
  26220. * | ----- | ----------------------------------- | ----------- |
  26221. * | 0 | EXPLICIT_MODE | |
  26222. * | 1 | SPHERICAL_MODE | |
  26223. * | 2 | PLANAR_MODE | |
  26224. * | 3 | CUBIC_MODE | |
  26225. * | 4 | PROJECTION_MODE | |
  26226. * | 5 | SKYBOX_MODE | |
  26227. * | 6 | INVCUBIC_MODE | |
  26228. * | 7 | EQUIRECTANGULAR_MODE | |
  26229. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26230. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26231. */
  26232. coordinatesMode: number;
  26233. /**
  26234. * | Value | Type | Description |
  26235. * | ----- | ------------------ | ----------- |
  26236. * | 0 | CLAMP_ADDRESSMODE | |
  26237. * | 1 | WRAP_ADDRESSMODE | |
  26238. * | 2 | MIRROR_ADDRESSMODE | |
  26239. */
  26240. wrapU: number;
  26241. /**
  26242. * | Value | Type | Description |
  26243. * | ----- | ------------------ | ----------- |
  26244. * | 0 | CLAMP_ADDRESSMODE | |
  26245. * | 1 | WRAP_ADDRESSMODE | |
  26246. * | 2 | MIRROR_ADDRESSMODE | |
  26247. */
  26248. wrapV: number;
  26249. /**
  26250. * | Value | Type | Description |
  26251. * | ----- | ------------------ | ----------- |
  26252. * | 0 | CLAMP_ADDRESSMODE | |
  26253. * | 1 | WRAP_ADDRESSMODE | |
  26254. * | 2 | MIRROR_ADDRESSMODE | |
  26255. */
  26256. wrapR: number;
  26257. /**
  26258. * With compliant hardware and browser (supporting anisotropic filtering)
  26259. * this defines the level of anisotropic filtering in the texture.
  26260. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26261. */
  26262. anisotropicFilteringLevel: number;
  26263. /**
  26264. * Define if the texture is a cube texture or if false a 2d texture.
  26265. */
  26266. isCube: boolean;
  26267. /**
  26268. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26269. */
  26270. is3D: boolean;
  26271. /**
  26272. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26273. * HDR texture are usually stored in linear space.
  26274. * This only impacts the PBR and Background materials
  26275. */
  26276. gammaSpace: boolean;
  26277. /**
  26278. * Gets whether or not the texture contains RGBD data.
  26279. */
  26280. readonly isRGBD: boolean;
  26281. /**
  26282. * Is Z inverted in the texture (useful in a cube texture).
  26283. */
  26284. invertZ: boolean;
  26285. /**
  26286. * Are mip maps generated for this texture or not.
  26287. */
  26288. readonly noMipmap: boolean;
  26289. /**
  26290. * @hidden
  26291. */
  26292. lodLevelInAlpha: boolean;
  26293. /**
  26294. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26295. */
  26296. lodGenerationOffset: number;
  26297. /**
  26298. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26299. */
  26300. lodGenerationScale: number;
  26301. /**
  26302. * Define if the texture is a render target.
  26303. */
  26304. isRenderTarget: boolean;
  26305. /**
  26306. * Define the unique id of the texture in the scene.
  26307. */
  26308. readonly uid: string;
  26309. /**
  26310. * Return a string representation of the texture.
  26311. * @returns the texture as a string
  26312. */
  26313. toString(): string;
  26314. /**
  26315. * Get the class name of the texture.
  26316. * @returns "BaseTexture"
  26317. */
  26318. getClassName(): string;
  26319. /**
  26320. * Define the list of animation attached to the texture.
  26321. */
  26322. animations: import("babylonjs/Animations/animation").Animation[];
  26323. /**
  26324. * An event triggered when the texture is disposed.
  26325. */
  26326. onDisposeObservable: Observable<BaseTexture>;
  26327. private _onDisposeObserver;
  26328. /**
  26329. * Callback triggered when the texture has been disposed.
  26330. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26331. */
  26332. onDispose: () => void;
  26333. /**
  26334. * Define the current state of the loading sequence when in delayed load mode.
  26335. */
  26336. delayLoadState: number;
  26337. private _scene;
  26338. /** @hidden */
  26339. _texture: Nullable<InternalTexture>;
  26340. private _uid;
  26341. /**
  26342. * Define if the texture is preventinga material to render or not.
  26343. * If not and the texture is not ready, the engine will use a default black texture instead.
  26344. */
  26345. readonly isBlocking: boolean;
  26346. /**
  26347. * Instantiates a new BaseTexture.
  26348. * Base class of all the textures in babylon.
  26349. * It groups all the common properties the materials, post process, lights... might need
  26350. * in order to make a correct use of the texture.
  26351. * @param scene Define the scene the texture blongs to
  26352. */
  26353. constructor(scene: Nullable<Scene>);
  26354. /**
  26355. * Get the scene the texture belongs to.
  26356. * @returns the scene or null if undefined
  26357. */
  26358. getScene(): Nullable<Scene>;
  26359. /**
  26360. * Get the texture transform matrix used to offset tile the texture for istance.
  26361. * @returns the transformation matrix
  26362. */
  26363. getTextureMatrix(): Matrix;
  26364. /**
  26365. * Get the texture reflection matrix used to rotate/transform the reflection.
  26366. * @returns the reflection matrix
  26367. */
  26368. getReflectionTextureMatrix(): Matrix;
  26369. /**
  26370. * Get the underlying lower level texture from Babylon.
  26371. * @returns the insternal texture
  26372. */
  26373. getInternalTexture(): Nullable<InternalTexture>;
  26374. /**
  26375. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26376. * @returns true if ready or not blocking
  26377. */
  26378. isReadyOrNotBlocking(): boolean;
  26379. /**
  26380. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26381. * @returns true if fully ready
  26382. */
  26383. isReady(): boolean;
  26384. private _cachedSize;
  26385. /**
  26386. * Get the size of the texture.
  26387. * @returns the texture size.
  26388. */
  26389. getSize(): ISize;
  26390. /**
  26391. * Get the base size of the texture.
  26392. * It can be different from the size if the texture has been resized for POT for instance
  26393. * @returns the base size
  26394. */
  26395. getBaseSize(): ISize;
  26396. /**
  26397. * Update the sampling mode of the texture.
  26398. * Default is Trilinear mode.
  26399. *
  26400. * | Value | Type | Description |
  26401. * | ----- | ------------------ | ----------- |
  26402. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26403. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26404. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26405. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26406. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26407. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26408. * | 7 | NEAREST_LINEAR | |
  26409. * | 8 | NEAREST_NEAREST | |
  26410. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26411. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26412. * | 11 | LINEAR_LINEAR | |
  26413. * | 12 | LINEAR_NEAREST | |
  26414. *
  26415. * > _mag_: magnification filter (close to the viewer)
  26416. * > _min_: minification filter (far from the viewer)
  26417. * > _mip_: filter used between mip map levels
  26418. *@param samplingMode Define the new sampling mode of the texture
  26419. */
  26420. updateSamplingMode(samplingMode: number): void;
  26421. /**
  26422. * Scales the texture if is `canRescale()`
  26423. * @param ratio the resize factor we want to use to rescale
  26424. */
  26425. scale(ratio: number): void;
  26426. /**
  26427. * Get if the texture can rescale.
  26428. */
  26429. readonly canRescale: boolean;
  26430. /** @hidden */
  26431. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26432. /** @hidden */
  26433. _rebuild(): void;
  26434. /**
  26435. * Triggers the load sequence in delayed load mode.
  26436. */
  26437. delayLoad(): void;
  26438. /**
  26439. * Clones the texture.
  26440. * @returns the cloned texture
  26441. */
  26442. clone(): Nullable<BaseTexture>;
  26443. /**
  26444. * Get the texture underlying type (INT, FLOAT...)
  26445. */
  26446. readonly textureType: number;
  26447. /**
  26448. * Get the texture underlying format (RGB, RGBA...)
  26449. */
  26450. readonly textureFormat: number;
  26451. /**
  26452. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26453. * This will returns an RGBA array buffer containing either in values (0-255) or
  26454. * float values (0-1) depending of the underlying buffer type.
  26455. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26456. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26457. * @param buffer defines a user defined buffer to fill with data (can be null)
  26458. * @returns The Array buffer containing the pixels data.
  26459. */
  26460. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26461. /**
  26462. * Release and destroy the underlying lower level texture aka internalTexture.
  26463. */
  26464. releaseInternalTexture(): void;
  26465. /**
  26466. * Get the polynomial representation of the texture data.
  26467. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26468. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26469. */
  26470. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26471. /** @hidden */
  26472. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26473. /** @hidden */
  26474. readonly _lodTextureMid: Nullable<BaseTexture>;
  26475. /** @hidden */
  26476. readonly _lodTextureLow: Nullable<BaseTexture>;
  26477. /**
  26478. * Dispose the texture and release its associated resources.
  26479. */
  26480. dispose(): void;
  26481. /**
  26482. * Serialize the texture into a JSON representation that can be parsed later on.
  26483. * @returns the JSON representation of the texture
  26484. */
  26485. serialize(): any;
  26486. /**
  26487. * Helper function to be called back once a list of texture contains only ready textures.
  26488. * @param textures Define the list of textures to wait for
  26489. * @param callback Define the callback triggered once the entire list will be ready
  26490. */
  26491. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26492. }
  26493. }
  26494. declare module "babylonjs/Materials/uniformBuffer" {
  26495. import { Nullable, FloatArray } from "babylonjs/types";
  26496. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26497. import { Engine } from "babylonjs/Engines/engine";
  26498. import { Effect } from "babylonjs/Materials/effect";
  26499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26500. /**
  26501. * Uniform buffer objects.
  26502. *
  26503. * Handles blocks of uniform on the GPU.
  26504. *
  26505. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26506. *
  26507. * For more information, please refer to :
  26508. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26509. */
  26510. export class UniformBuffer {
  26511. private _engine;
  26512. private _buffer;
  26513. private _data;
  26514. private _bufferData;
  26515. private _dynamic?;
  26516. private _uniformLocations;
  26517. private _uniformSizes;
  26518. private _uniformLocationPointer;
  26519. private _needSync;
  26520. private _noUBO;
  26521. private _currentEffect;
  26522. private static _MAX_UNIFORM_SIZE;
  26523. private static _tempBuffer;
  26524. /**
  26525. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26530. /**
  26531. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26536. /**
  26537. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  26542. /**
  26543. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26548. /**
  26549. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26554. /**
  26555. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26560. /**
  26561. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  26566. /**
  26567. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  26572. /**
  26573. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26574. * This is dynamic to allow compat with webgl 1 and 2.
  26575. * You will need to pass the name of the uniform as well as the value.
  26576. */
  26577. updateVector4: (name: string, vector: Vector4) => void;
  26578. /**
  26579. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26580. * This is dynamic to allow compat with webgl 1 and 2.
  26581. * You will need to pass the name of the uniform as well as the value.
  26582. */
  26583. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26584. /**
  26585. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26586. * This is dynamic to allow compat with webgl 1 and 2.
  26587. * You will need to pass the name of the uniform as well as the value.
  26588. */
  26589. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26590. /**
  26591. * Instantiates a new Uniform buffer objects.
  26592. *
  26593. * Handles blocks of uniform on the GPU.
  26594. *
  26595. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26596. *
  26597. * For more information, please refer to :
  26598. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26599. * @param engine Define the engine the buffer is associated with
  26600. * @param data Define the data contained in the buffer
  26601. * @param dynamic Define if the buffer is updatable
  26602. */
  26603. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26604. /**
  26605. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26606. * or just falling back on setUniformXXX calls.
  26607. */
  26608. readonly useUbo: boolean;
  26609. /**
  26610. * Indicates if the WebGL underlying uniform buffer is in sync
  26611. * with the javascript cache data.
  26612. */
  26613. readonly isSync: boolean;
  26614. /**
  26615. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26616. * Also, a dynamic UniformBuffer will disable cache verification and always
  26617. * update the underlying WebGL uniform buffer to the GPU.
  26618. * @returns if Dynamic, otherwise false
  26619. */
  26620. isDynamic(): boolean;
  26621. /**
  26622. * The data cache on JS side.
  26623. * @returns the underlying data as a float array
  26624. */
  26625. getData(): Float32Array;
  26626. /**
  26627. * The underlying WebGL Uniform buffer.
  26628. * @returns the webgl buffer
  26629. */
  26630. getBuffer(): Nullable<WebGLBuffer>;
  26631. /**
  26632. * std140 layout specifies how to align data within an UBO structure.
  26633. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26634. * for specs.
  26635. */
  26636. private _fillAlignment;
  26637. /**
  26638. * Adds an uniform in the buffer.
  26639. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26640. * for the layout to be correct !
  26641. * @param name Name of the uniform, as used in the uniform block in the shader.
  26642. * @param size Data size, or data directly.
  26643. */
  26644. addUniform(name: string, size: number | number[]): void;
  26645. /**
  26646. * Adds a Matrix 4x4 to the uniform buffer.
  26647. * @param name Name of the uniform, as used in the uniform block in the shader.
  26648. * @param mat A 4x4 matrix.
  26649. */
  26650. addMatrix(name: string, mat: Matrix): void;
  26651. /**
  26652. * Adds a vec2 to the uniform buffer.
  26653. * @param name Name of the uniform, as used in the uniform block in the shader.
  26654. * @param x Define the x component value of the vec2
  26655. * @param y Define the y component value of the vec2
  26656. */
  26657. addFloat2(name: string, x: number, y: number): void;
  26658. /**
  26659. * Adds a vec3 to the uniform buffer.
  26660. * @param name Name of the uniform, as used in the uniform block in the shader.
  26661. * @param x Define the x component value of the vec3
  26662. * @param y Define the y component value of the vec3
  26663. * @param z Define the z component value of the vec3
  26664. */
  26665. addFloat3(name: string, x: number, y: number, z: number): void;
  26666. /**
  26667. * Adds a vec3 to the uniform buffer.
  26668. * @param name Name of the uniform, as used in the uniform block in the shader.
  26669. * @param color Define the vec3 from a Color
  26670. */
  26671. addColor3(name: string, color: Color3): void;
  26672. /**
  26673. * Adds a vec4 to the uniform buffer.
  26674. * @param name Name of the uniform, as used in the uniform block in the shader.
  26675. * @param color Define the rgb components from a Color
  26676. * @param alpha Define the a component of the vec4
  26677. */
  26678. addColor4(name: string, color: Color3, alpha: number): void;
  26679. /**
  26680. * Adds a vec3 to the uniform buffer.
  26681. * @param name Name of the uniform, as used in the uniform block in the shader.
  26682. * @param vector Define the vec3 components from a Vector
  26683. */
  26684. addVector3(name: string, vector: Vector3): void;
  26685. /**
  26686. * Adds a Matrix 3x3 to the uniform buffer.
  26687. * @param name Name of the uniform, as used in the uniform block in the shader.
  26688. */
  26689. addMatrix3x3(name: string): void;
  26690. /**
  26691. * Adds a Matrix 2x2 to the uniform buffer.
  26692. * @param name Name of the uniform, as used in the uniform block in the shader.
  26693. */
  26694. addMatrix2x2(name: string): void;
  26695. /**
  26696. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26697. */
  26698. create(): void;
  26699. /** @hidden */
  26700. _rebuild(): void;
  26701. /**
  26702. * Updates the WebGL Uniform Buffer on the GPU.
  26703. * If the `dynamic` flag is set to true, no cache comparison is done.
  26704. * Otherwise, the buffer will be updated only if the cache differs.
  26705. */
  26706. update(): void;
  26707. /**
  26708. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26709. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26710. * @param data Define the flattened data
  26711. * @param size Define the size of the data.
  26712. */
  26713. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26714. private _updateMatrix3x3ForUniform;
  26715. private _updateMatrix3x3ForEffect;
  26716. private _updateMatrix2x2ForEffect;
  26717. private _updateMatrix2x2ForUniform;
  26718. private _updateFloatForEffect;
  26719. private _updateFloatForUniform;
  26720. private _updateFloat2ForEffect;
  26721. private _updateFloat2ForUniform;
  26722. private _updateFloat3ForEffect;
  26723. private _updateFloat3ForUniform;
  26724. private _updateFloat4ForEffect;
  26725. private _updateFloat4ForUniform;
  26726. private _updateMatrixForEffect;
  26727. private _updateMatrixForUniform;
  26728. private _updateVector3ForEffect;
  26729. private _updateVector3ForUniform;
  26730. private _updateVector4ForEffect;
  26731. private _updateVector4ForUniform;
  26732. private _updateColor3ForEffect;
  26733. private _updateColor3ForUniform;
  26734. private _updateColor4ForEffect;
  26735. private _updateColor4ForUniform;
  26736. /**
  26737. * Sets a sampler uniform on the effect.
  26738. * @param name Define the name of the sampler.
  26739. * @param texture Define the texture to set in the sampler
  26740. */
  26741. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26742. /**
  26743. * Directly updates the value of the uniform in the cache AND on the GPU.
  26744. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26745. * @param data Define the flattened data
  26746. */
  26747. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26748. /**
  26749. * Binds this uniform buffer to an effect.
  26750. * @param effect Define the effect to bind the buffer to
  26751. * @param name Name of the uniform block in the shader.
  26752. */
  26753. bindToEffect(effect: Effect, name: string): void;
  26754. /**
  26755. * Disposes the uniform buffer.
  26756. */
  26757. dispose(): void;
  26758. }
  26759. }
  26760. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26761. import { Nullable } from "babylonjs/types";
  26762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26763. /**
  26764. * This represents the required contract to create a new type of texture loader.
  26765. */
  26766. export interface IInternalTextureLoader {
  26767. /**
  26768. * Defines wether the loader supports cascade loading the different faces.
  26769. */
  26770. supportCascades: boolean;
  26771. /**
  26772. * This returns if the loader support the current file information.
  26773. * @param extension defines the file extension of the file being loaded
  26774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26775. * @param fallback defines the fallback internal texture if any
  26776. * @param isBase64 defines whether the texture is encoded as a base64
  26777. * @param isBuffer defines whether the texture data are stored as a buffer
  26778. * @returns true if the loader can load the specified file
  26779. */
  26780. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26781. /**
  26782. * Transform the url before loading if required.
  26783. * @param rootUrl the url of the texture
  26784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26785. * @returns the transformed texture
  26786. */
  26787. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26788. /**
  26789. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26790. * @param rootUrl the url of the texture
  26791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26792. * @returns the fallback texture
  26793. */
  26794. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26795. /**
  26796. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26797. * @param data contains the texture data
  26798. * @param texture defines the BabylonJS internal texture
  26799. * @param createPolynomials will be true if polynomials have been requested
  26800. * @param onLoad defines the callback to trigger once the texture is ready
  26801. * @param onError defines the callback to trigger in case of error
  26802. */
  26803. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26804. /**
  26805. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26806. * @param data contains the texture data
  26807. * @param texture defines the BabylonJS internal texture
  26808. * @param callback defines the method to call once ready to upload
  26809. */
  26810. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26811. }
  26812. }
  26813. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26814. import { Scene } from "babylonjs/scene";
  26815. import { Engine } from "babylonjs/Engines/engine";
  26816. import { Texture } from "babylonjs/Materials/Textures/texture";
  26817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26818. /**
  26819. * Creation options of the multi render target texture.
  26820. */
  26821. export interface IMultiRenderTargetOptions {
  26822. /**
  26823. * Define if the texture needs to create mip maps after render.
  26824. */
  26825. generateMipMaps?: boolean;
  26826. /**
  26827. * Define the types of all the draw buffers we want to create
  26828. */
  26829. types?: number[];
  26830. /**
  26831. * Define the sampling modes of all the draw buffers we want to create
  26832. */
  26833. samplingModes?: number[];
  26834. /**
  26835. * Define if a depth buffer is required
  26836. */
  26837. generateDepthBuffer?: boolean;
  26838. /**
  26839. * Define if a stencil buffer is required
  26840. */
  26841. generateStencilBuffer?: boolean;
  26842. /**
  26843. * Define if a depth texture is required instead of a depth buffer
  26844. */
  26845. generateDepthTexture?: boolean;
  26846. /**
  26847. * Define the number of desired draw buffers
  26848. */
  26849. textureCount?: number;
  26850. /**
  26851. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26852. */
  26853. doNotChangeAspectRatio?: boolean;
  26854. /**
  26855. * Define the default type of the buffers we are creating
  26856. */
  26857. defaultType?: number;
  26858. }
  26859. /**
  26860. * A multi render target, like a render target provides the ability to render to a texture.
  26861. * Unlike the render target, it can render to several draw buffers in one draw.
  26862. * This is specially interesting in deferred rendering or for any effects requiring more than
  26863. * just one color from a single pass.
  26864. */
  26865. export class MultiRenderTarget extends RenderTargetTexture {
  26866. private _internalTextures;
  26867. private _textures;
  26868. private _multiRenderTargetOptions;
  26869. /**
  26870. * Get if draw buffers are currently supported by the used hardware and browser.
  26871. */
  26872. readonly isSupported: boolean;
  26873. /**
  26874. * Get the list of textures generated by the multi render target.
  26875. */
  26876. readonly textures: Texture[];
  26877. /**
  26878. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26879. */
  26880. readonly depthTexture: Texture;
  26881. /**
  26882. * Set the wrapping mode on U of all the textures we are rendering to.
  26883. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26884. */
  26885. wrapU: number;
  26886. /**
  26887. * Set the wrapping mode on V of all the textures we are rendering to.
  26888. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26889. */
  26890. wrapV: number;
  26891. /**
  26892. * Instantiate a new multi render target texture.
  26893. * A multi render target, like a render target provides the ability to render to a texture.
  26894. * Unlike the render target, it can render to several draw buffers in one draw.
  26895. * This is specially interesting in deferred rendering or for any effects requiring more than
  26896. * just one color from a single pass.
  26897. * @param name Define the name of the texture
  26898. * @param size Define the size of the buffers to render to
  26899. * @param count Define the number of target we are rendering into
  26900. * @param scene Define the scene the texture belongs to
  26901. * @param options Define the options used to create the multi render target
  26902. */
  26903. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26904. /** @hidden */
  26905. _rebuild(): void;
  26906. private _createInternalTextures;
  26907. private _createTextures;
  26908. /**
  26909. * Define the number of samples used if MSAA is enabled.
  26910. */
  26911. samples: number;
  26912. /**
  26913. * Resize all the textures in the multi render target.
  26914. * Be carrefull as it will recreate all the data in the new texture.
  26915. * @param size Define the new size
  26916. */
  26917. resize(size: any): void;
  26918. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26919. /**
  26920. * Dispose the render targets and their associated resources
  26921. */
  26922. dispose(): void;
  26923. /**
  26924. * Release all the underlying texture used as draw buffers.
  26925. */
  26926. releaseInternalTextures(): void;
  26927. }
  26928. }
  26929. declare module "babylonjs/Audio/analyser" {
  26930. import { Scene } from "babylonjs/scene";
  26931. /**
  26932. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26934. */
  26935. export class Analyser {
  26936. /**
  26937. * Gets or sets the smoothing
  26938. * @ignorenaming
  26939. */
  26940. SMOOTHING: number;
  26941. /**
  26942. * Gets or sets the FFT table size
  26943. * @ignorenaming
  26944. */
  26945. FFT_SIZE: number;
  26946. /**
  26947. * Gets or sets the bar graph amplitude
  26948. * @ignorenaming
  26949. */
  26950. BARGRAPHAMPLITUDE: number;
  26951. /**
  26952. * Gets or sets the position of the debug canvas
  26953. * @ignorenaming
  26954. */
  26955. DEBUGCANVASPOS: {
  26956. x: number;
  26957. y: number;
  26958. };
  26959. /**
  26960. * Gets or sets the debug canvas size
  26961. * @ignorenaming
  26962. */
  26963. DEBUGCANVASSIZE: {
  26964. width: number;
  26965. height: number;
  26966. };
  26967. private _byteFreqs;
  26968. private _byteTime;
  26969. private _floatFreqs;
  26970. private _webAudioAnalyser;
  26971. private _debugCanvas;
  26972. private _debugCanvasContext;
  26973. private _scene;
  26974. private _registerFunc;
  26975. private _audioEngine;
  26976. /**
  26977. * Creates a new analyser
  26978. * @param scene defines hosting scene
  26979. */
  26980. constructor(scene: Scene);
  26981. /**
  26982. * Get the number of data values you will have to play with for the visualization
  26983. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26984. * @returns a number
  26985. */
  26986. getFrequencyBinCount(): number;
  26987. /**
  26988. * Gets the current frequency data as a byte array
  26989. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26990. * @returns a Uint8Array
  26991. */
  26992. getByteFrequencyData(): Uint8Array;
  26993. /**
  26994. * Gets the current waveform as a byte array
  26995. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26996. * @returns a Uint8Array
  26997. */
  26998. getByteTimeDomainData(): Uint8Array;
  26999. /**
  27000. * Gets the current frequency data as a float array
  27001. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27002. * @returns a Float32Array
  27003. */
  27004. getFloatFrequencyData(): Float32Array;
  27005. /**
  27006. * Renders the debug canvas
  27007. */
  27008. drawDebugCanvas(): void;
  27009. /**
  27010. * Stops rendering the debug canvas and removes it
  27011. */
  27012. stopDebugCanvas(): void;
  27013. /**
  27014. * Connects two audio nodes
  27015. * @param inputAudioNode defines first node to connect
  27016. * @param outputAudioNode defines second node to connect
  27017. */
  27018. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27019. /**
  27020. * Releases all associated resources
  27021. */
  27022. dispose(): void;
  27023. }
  27024. }
  27025. declare module "babylonjs/Audio/audioEngine" {
  27026. import { IDisposable } from "babylonjs/scene";
  27027. import { Analyser } from "babylonjs/Audio/analyser";
  27028. import { Nullable } from "babylonjs/types";
  27029. import { Observable } from "babylonjs/Misc/observable";
  27030. /**
  27031. * This represents an audio engine and it is responsible
  27032. * to play, synchronize and analyse sounds throughout the application.
  27033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27034. */
  27035. export interface IAudioEngine extends IDisposable {
  27036. /**
  27037. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27038. */
  27039. readonly canUseWebAudio: boolean;
  27040. /**
  27041. * Gets the current AudioContext if available.
  27042. */
  27043. readonly audioContext: Nullable<AudioContext>;
  27044. /**
  27045. * The master gain node defines the global audio volume of your audio engine.
  27046. */
  27047. readonly masterGain: GainNode;
  27048. /**
  27049. * Gets whether or not mp3 are supported by your browser.
  27050. */
  27051. readonly isMP3supported: boolean;
  27052. /**
  27053. * Gets whether or not ogg are supported by your browser.
  27054. */
  27055. readonly isOGGsupported: boolean;
  27056. /**
  27057. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27058. * @ignoreNaming
  27059. */
  27060. WarnedWebAudioUnsupported: boolean;
  27061. /**
  27062. * Defines if the audio engine relies on a custom unlocked button.
  27063. * In this case, the embedded button will not be displayed.
  27064. */
  27065. useCustomUnlockedButton: boolean;
  27066. /**
  27067. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27068. */
  27069. readonly unlocked: boolean;
  27070. /**
  27071. * Event raised when audio has been unlocked on the browser.
  27072. */
  27073. onAudioUnlockedObservable: Observable<AudioEngine>;
  27074. /**
  27075. * Event raised when audio has been locked on the browser.
  27076. */
  27077. onAudioLockedObservable: Observable<AudioEngine>;
  27078. /**
  27079. * Flags the audio engine in Locked state.
  27080. * This happens due to new browser policies preventing audio to autoplay.
  27081. */
  27082. lock(): void;
  27083. /**
  27084. * Unlocks the audio engine once a user action has been done on the dom.
  27085. * This is helpful to resume play once browser policies have been satisfied.
  27086. */
  27087. unlock(): void;
  27088. }
  27089. /**
  27090. * This represents the default audio engine used in babylon.
  27091. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27093. */
  27094. export class AudioEngine implements IAudioEngine {
  27095. private _audioContext;
  27096. private _audioContextInitialized;
  27097. private _muteButton;
  27098. private _hostElement;
  27099. /**
  27100. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27101. */
  27102. canUseWebAudio: boolean;
  27103. /**
  27104. * The master gain node defines the global audio volume of your audio engine.
  27105. */
  27106. masterGain: GainNode;
  27107. /**
  27108. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27109. * @ignoreNaming
  27110. */
  27111. WarnedWebAudioUnsupported: boolean;
  27112. /**
  27113. * Gets whether or not mp3 are supported by your browser.
  27114. */
  27115. isMP3supported: boolean;
  27116. /**
  27117. * Gets whether or not ogg are supported by your browser.
  27118. */
  27119. isOGGsupported: boolean;
  27120. /**
  27121. * Gets whether audio has been unlocked on the device.
  27122. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27123. * a user interaction has happened.
  27124. */
  27125. unlocked: boolean;
  27126. /**
  27127. * Defines if the audio engine relies on a custom unlocked button.
  27128. * In this case, the embedded button will not be displayed.
  27129. */
  27130. useCustomUnlockedButton: boolean;
  27131. /**
  27132. * Event raised when audio has been unlocked on the browser.
  27133. */
  27134. onAudioUnlockedObservable: Observable<AudioEngine>;
  27135. /**
  27136. * Event raised when audio has been locked on the browser.
  27137. */
  27138. onAudioLockedObservable: Observable<AudioEngine>;
  27139. /**
  27140. * Gets the current AudioContext if available.
  27141. */
  27142. readonly audioContext: Nullable<AudioContext>;
  27143. private _connectedAnalyser;
  27144. /**
  27145. * Instantiates a new audio engine.
  27146. *
  27147. * There should be only one per page as some browsers restrict the number
  27148. * of audio contexts you can create.
  27149. * @param hostElement defines the host element where to display the mute icon if necessary
  27150. */
  27151. constructor(hostElement?: Nullable<HTMLElement>);
  27152. /**
  27153. * Flags the audio engine in Locked state.
  27154. * This happens due to new browser policies preventing audio to autoplay.
  27155. */
  27156. lock(): void;
  27157. /**
  27158. * Unlocks the audio engine once a user action has been done on the dom.
  27159. * This is helpful to resume play once browser policies have been satisfied.
  27160. */
  27161. unlock(): void;
  27162. private _resumeAudioContext;
  27163. private _initializeAudioContext;
  27164. private _tryToRun;
  27165. private _triggerRunningState;
  27166. private _triggerSuspendedState;
  27167. private _displayMuteButton;
  27168. private _moveButtonToTopLeft;
  27169. private _onResize;
  27170. private _hideMuteButton;
  27171. /**
  27172. * Destroy and release the resources associated with the audio ccontext.
  27173. */
  27174. dispose(): void;
  27175. /**
  27176. * Gets the global volume sets on the master gain.
  27177. * @returns the global volume if set or -1 otherwise
  27178. */
  27179. getGlobalVolume(): number;
  27180. /**
  27181. * Sets the global volume of your experience (sets on the master gain).
  27182. * @param newVolume Defines the new global volume of the application
  27183. */
  27184. setGlobalVolume(newVolume: number): void;
  27185. /**
  27186. * Connect the audio engine to an audio analyser allowing some amazing
  27187. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27189. * @param analyser The analyser to connect to the engine
  27190. */
  27191. connectToAnalyser(analyser: Analyser): void;
  27192. }
  27193. }
  27194. declare module "babylonjs/Loading/loadingScreen" {
  27195. /**
  27196. * Interface used to present a loading screen while loading a scene
  27197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27198. */
  27199. export interface ILoadingScreen {
  27200. /**
  27201. * Function called to display the loading screen
  27202. */
  27203. displayLoadingUI: () => void;
  27204. /**
  27205. * Function called to hide the loading screen
  27206. */
  27207. hideLoadingUI: () => void;
  27208. /**
  27209. * Gets or sets the color to use for the background
  27210. */
  27211. loadingUIBackgroundColor: string;
  27212. /**
  27213. * Gets or sets the text to display while loading
  27214. */
  27215. loadingUIText: string;
  27216. }
  27217. /**
  27218. * Class used for the default loading screen
  27219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27220. */
  27221. export class DefaultLoadingScreen implements ILoadingScreen {
  27222. private _renderingCanvas;
  27223. private _loadingText;
  27224. private _loadingDivBackgroundColor;
  27225. private _loadingDiv;
  27226. private _loadingTextDiv;
  27227. /**
  27228. * Creates a new default loading screen
  27229. * @param _renderingCanvas defines the canvas used to render the scene
  27230. * @param _loadingText defines the default text to display
  27231. * @param _loadingDivBackgroundColor defines the default background color
  27232. */
  27233. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27234. /**
  27235. * Function called to display the loading screen
  27236. */
  27237. displayLoadingUI(): void;
  27238. /**
  27239. * Function called to hide the loading screen
  27240. */
  27241. hideLoadingUI(): void;
  27242. /**
  27243. * Gets or sets the text to display while loading
  27244. */
  27245. loadingUIText: string;
  27246. /**
  27247. * Gets or sets the color to use for the background
  27248. */
  27249. loadingUIBackgroundColor: string;
  27250. private _resizeLoadingUI;
  27251. }
  27252. }
  27253. declare module "babylonjs/Materials/Textures/videoTexture" {
  27254. import { Observable } from "babylonjs/Misc/observable";
  27255. import { Nullable } from "babylonjs/types";
  27256. import { Scene } from "babylonjs/scene";
  27257. import { Texture } from "babylonjs/Materials/Textures/texture";
  27258. /**
  27259. * Settings for finer control over video usage
  27260. */
  27261. export interface VideoTextureSettings {
  27262. /**
  27263. * Applies `autoplay` to video, if specified
  27264. */
  27265. autoPlay?: boolean;
  27266. /**
  27267. * Applies `loop` to video, if specified
  27268. */
  27269. loop?: boolean;
  27270. /**
  27271. * Automatically updates internal texture from video at every frame in the render loop
  27272. */
  27273. autoUpdateTexture: boolean;
  27274. /**
  27275. * Image src displayed during the video loading or until the user interacts with the video.
  27276. */
  27277. poster?: string;
  27278. }
  27279. /**
  27280. * If you want to display a video in your scene, this is the special texture for that.
  27281. * This special texture works similar to other textures, with the exception of a few parameters.
  27282. * @see https://doc.babylonjs.com/how_to/video_texture
  27283. */
  27284. export class VideoTexture extends Texture {
  27285. /**
  27286. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27287. */
  27288. readonly autoUpdateTexture: boolean;
  27289. /**
  27290. * The video instance used by the texture internally
  27291. */
  27292. readonly video: HTMLVideoElement;
  27293. private _onUserActionRequestedObservable;
  27294. /**
  27295. * Event triggerd when a dom action is required by the user to play the video.
  27296. * This happens due to recent changes in browser policies preventing video to auto start.
  27297. */
  27298. readonly onUserActionRequestedObservable: Observable<Texture>;
  27299. private _generateMipMaps;
  27300. private _engine;
  27301. private _stillImageCaptured;
  27302. private _displayingPosterTexture;
  27303. private _settings;
  27304. private _createInternalTextureOnEvent;
  27305. /**
  27306. * Creates a video texture.
  27307. * If you want to display a video in your scene, this is the special texture for that.
  27308. * This special texture works similar to other textures, with the exception of a few parameters.
  27309. * @see https://doc.babylonjs.com/how_to/video_texture
  27310. * @param name optional name, will detect from video source, if not defined
  27311. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27312. * @param scene is obviously the current scene.
  27313. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27314. * @param invertY is false by default but can be used to invert video on Y axis
  27315. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27316. * @param settings allows finer control over video usage
  27317. */
  27318. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27319. private _getName;
  27320. private _getVideo;
  27321. private _createInternalTexture;
  27322. private reset;
  27323. /**
  27324. * @hidden Internal method to initiate `update`.
  27325. */
  27326. _rebuild(): void;
  27327. /**
  27328. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27329. */
  27330. update(): void;
  27331. /**
  27332. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27333. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27334. */
  27335. updateTexture(isVisible: boolean): void;
  27336. protected _updateInternalTexture: () => void;
  27337. /**
  27338. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27339. * @param url New url.
  27340. */
  27341. updateURL(url: string): void;
  27342. /**
  27343. * Dispose the texture and release its associated resources.
  27344. */
  27345. dispose(): void;
  27346. /**
  27347. * Creates a video texture straight from a stream.
  27348. * @param scene Define the scene the texture should be created in
  27349. * @param stream Define the stream the texture should be created from
  27350. * @returns The created video texture as a promise
  27351. */
  27352. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27353. /**
  27354. * Creates a video texture straight from your WebCam video feed.
  27355. * @param scene Define the scene the texture should be created in
  27356. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27357. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27358. * @returns The created video texture as a promise
  27359. */
  27360. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27361. minWidth: number;
  27362. maxWidth: number;
  27363. minHeight: number;
  27364. maxHeight: number;
  27365. deviceId: string;
  27366. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27367. /**
  27368. * Creates a video texture straight from your WebCam video feed.
  27369. * @param scene Define the scene the texture should be created in
  27370. * @param onReady Define a callback to triggered once the texture will be ready
  27371. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27372. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27373. */
  27374. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27375. minWidth: number;
  27376. maxWidth: number;
  27377. minHeight: number;
  27378. maxHeight: number;
  27379. deviceId: string;
  27380. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27381. }
  27382. }
  27383. declare module "babylonjs/Engines/engine" {
  27384. import { Observable } from "babylonjs/Misc/observable";
  27385. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27386. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27387. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27388. import { Camera } from "babylonjs/Cameras/camera";
  27389. import { Scene } from "babylonjs/scene";
  27390. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27391. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27392. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27393. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27394. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27395. import { Material } from "babylonjs/Materials/material";
  27396. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27399. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27400. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27401. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27402. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27403. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27404. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27405. import { WebRequest } from "babylonjs/Misc/webRequest";
  27406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27408. /**
  27409. * Interface for attribute information associated with buffer instanciation
  27410. */
  27411. export class InstancingAttributeInfo {
  27412. /**
  27413. * Index/offset of the attribute in the vertex shader
  27414. */
  27415. index: number;
  27416. /**
  27417. * size of the attribute, 1, 2, 3 or 4
  27418. */
  27419. attributeSize: number;
  27420. /**
  27421. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27422. * default is FLOAT
  27423. */
  27424. attribyteType: number;
  27425. /**
  27426. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27427. */
  27428. normalized: boolean;
  27429. /**
  27430. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27431. */
  27432. offset: number;
  27433. /**
  27434. * Name of the GLSL attribute, for debugging purpose only
  27435. */
  27436. attributeName: string;
  27437. }
  27438. /**
  27439. * Define options used to create a depth texture
  27440. */
  27441. export class DepthTextureCreationOptions {
  27442. /** Specifies whether or not a stencil should be allocated in the texture */
  27443. generateStencil?: boolean;
  27444. /** Specifies whether or not bilinear filtering is enable on the texture */
  27445. bilinearFiltering?: boolean;
  27446. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27447. comparisonFunction?: number;
  27448. /** Specifies if the created texture is a cube texture */
  27449. isCube?: boolean;
  27450. }
  27451. /**
  27452. * Class used to describe the capabilities of the engine relatively to the current browser
  27453. */
  27454. export class EngineCapabilities {
  27455. /** Maximum textures units per fragment shader */
  27456. maxTexturesImageUnits: number;
  27457. /** Maximum texture units per vertex shader */
  27458. maxVertexTextureImageUnits: number;
  27459. /** Maximum textures units in the entire pipeline */
  27460. maxCombinedTexturesImageUnits: number;
  27461. /** Maximum texture size */
  27462. maxTextureSize: number;
  27463. /** Maximum cube texture size */
  27464. maxCubemapTextureSize: number;
  27465. /** Maximum render texture size */
  27466. maxRenderTextureSize: number;
  27467. /** Maximum number of vertex attributes */
  27468. maxVertexAttribs: number;
  27469. /** Maximum number of varyings */
  27470. maxVaryingVectors: number;
  27471. /** Maximum number of uniforms per vertex shader */
  27472. maxVertexUniformVectors: number;
  27473. /** Maximum number of uniforms per fragment shader */
  27474. maxFragmentUniformVectors: number;
  27475. /** Defines if standard derivates (dx/dy) are supported */
  27476. standardDerivatives: boolean;
  27477. /** Defines if s3tc texture compression is supported */
  27478. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27479. /** Defines if pvrtc texture compression is supported */
  27480. pvrtc: any;
  27481. /** Defines if etc1 texture compression is supported */
  27482. etc1: any;
  27483. /** Defines if etc2 texture compression is supported */
  27484. etc2: any;
  27485. /** Defines if astc texture compression is supported */
  27486. astc: any;
  27487. /** Defines if float textures are supported */
  27488. textureFloat: boolean;
  27489. /** Defines if vertex array objects are supported */
  27490. vertexArrayObject: boolean;
  27491. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27492. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27493. /** Gets the maximum level of anisotropy supported */
  27494. maxAnisotropy: number;
  27495. /** Defines if instancing is supported */
  27496. instancedArrays: boolean;
  27497. /** Defines if 32 bits indices are supported */
  27498. uintIndices: boolean;
  27499. /** Defines if high precision shaders are supported */
  27500. highPrecisionShaderSupported: boolean;
  27501. /** Defines if depth reading in the fragment shader is supported */
  27502. fragmentDepthSupported: boolean;
  27503. /** Defines if float texture linear filtering is supported*/
  27504. textureFloatLinearFiltering: boolean;
  27505. /** Defines if rendering to float textures is supported */
  27506. textureFloatRender: boolean;
  27507. /** Defines if half float textures are supported*/
  27508. textureHalfFloat: boolean;
  27509. /** Defines if half float texture linear filtering is supported*/
  27510. textureHalfFloatLinearFiltering: boolean;
  27511. /** Defines if rendering to half float textures is supported */
  27512. textureHalfFloatRender: boolean;
  27513. /** Defines if textureLOD shader command is supported */
  27514. textureLOD: boolean;
  27515. /** Defines if draw buffers extension is supported */
  27516. drawBuffersExtension: boolean;
  27517. /** Defines if depth textures are supported */
  27518. depthTextureExtension: boolean;
  27519. /** Defines if float color buffer are supported */
  27520. colorBufferFloat: boolean;
  27521. /** Gets disjoint timer query extension (null if not supported) */
  27522. timerQuery: EXT_disjoint_timer_query;
  27523. /** Defines if timestamp can be used with timer query */
  27524. canUseTimestampForTimerQuery: boolean;
  27525. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27526. multiview: any;
  27527. /** Function used to let the system compiles shaders in background */
  27528. parallelShaderCompile: {
  27529. COMPLETION_STATUS_KHR: number;
  27530. };
  27531. }
  27532. /** Interface defining initialization parameters for Engine class */
  27533. export interface EngineOptions extends WebGLContextAttributes {
  27534. /**
  27535. * Defines if the engine should no exceed a specified device ratio
  27536. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27537. */
  27538. limitDeviceRatio?: number;
  27539. /**
  27540. * Defines if webvr should be enabled automatically
  27541. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27542. */
  27543. autoEnableWebVR?: boolean;
  27544. /**
  27545. * Defines if webgl2 should be turned off even if supported
  27546. * @see http://doc.babylonjs.com/features/webgl2
  27547. */
  27548. disableWebGL2Support?: boolean;
  27549. /**
  27550. * Defines if webaudio should be initialized as well
  27551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27552. */
  27553. audioEngine?: boolean;
  27554. /**
  27555. * Defines if animations should run using a deterministic lock step
  27556. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27557. */
  27558. deterministicLockstep?: boolean;
  27559. /** Defines the maximum steps to use with deterministic lock step mode */
  27560. lockstepMaxSteps?: number;
  27561. /**
  27562. * Defines that engine should ignore context lost events
  27563. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27564. */
  27565. doNotHandleContextLost?: boolean;
  27566. /**
  27567. * Defines that engine should ignore modifying touch action attribute and style
  27568. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27569. */
  27570. doNotHandleTouchAction?: boolean;
  27571. /**
  27572. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27573. */
  27574. useHighPrecisionFloats?: boolean;
  27575. }
  27576. /**
  27577. * Defines the interface used by display changed events
  27578. */
  27579. export interface IDisplayChangedEventArgs {
  27580. /** Gets the vrDisplay object (if any) */
  27581. vrDisplay: Nullable<any>;
  27582. /** Gets a boolean indicating if webVR is supported */
  27583. vrSupported: boolean;
  27584. }
  27585. /**
  27586. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27587. */
  27588. export class Engine {
  27589. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27590. static ExceptionList: ({
  27591. key: string;
  27592. capture: string;
  27593. captureConstraint: number;
  27594. targets: string[];
  27595. } | {
  27596. key: string;
  27597. capture: null;
  27598. captureConstraint: null;
  27599. targets: string[];
  27600. })[];
  27601. /** Gets the list of created engines */
  27602. static readonly Instances: Engine[];
  27603. /**
  27604. * Gets the latest created engine
  27605. */
  27606. static readonly LastCreatedEngine: Nullable<Engine>;
  27607. /**
  27608. * Gets the latest created scene
  27609. */
  27610. static readonly LastCreatedScene: Nullable<Scene>;
  27611. /**
  27612. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27613. * @param flag defines which part of the materials must be marked as dirty
  27614. * @param predicate defines a predicate used to filter which materials should be affected
  27615. */
  27616. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27617. /**
  27618. * Hidden
  27619. */
  27620. static _TextureLoaders: IInternalTextureLoader[];
  27621. /** Defines that alpha blending is disabled */
  27622. static readonly ALPHA_DISABLE: number;
  27623. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27624. static readonly ALPHA_ADD: number;
  27625. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27626. static readonly ALPHA_COMBINE: number;
  27627. /** Defines that alpha blending to DEST - SRC * DEST */
  27628. static readonly ALPHA_SUBTRACT: number;
  27629. /** Defines that alpha blending to SRC * DEST */
  27630. static readonly ALPHA_MULTIPLY: number;
  27631. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27632. static readonly ALPHA_MAXIMIZED: number;
  27633. /** Defines that alpha blending to SRC + DEST */
  27634. static readonly ALPHA_ONEONE: number;
  27635. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27636. static readonly ALPHA_PREMULTIPLIED: number;
  27637. /**
  27638. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27639. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27640. */
  27641. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27642. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27643. static readonly ALPHA_INTERPOLATE: number;
  27644. /**
  27645. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27646. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27647. */
  27648. static readonly ALPHA_SCREENMODE: number;
  27649. /** Defines that the ressource is not delayed*/
  27650. static readonly DELAYLOADSTATE_NONE: number;
  27651. /** Defines that the ressource was successfully delay loaded */
  27652. static readonly DELAYLOADSTATE_LOADED: number;
  27653. /** Defines that the ressource is currently delay loading */
  27654. static readonly DELAYLOADSTATE_LOADING: number;
  27655. /** Defines that the ressource is delayed and has not started loading */
  27656. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27657. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27658. static readonly NEVER: number;
  27659. /** 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 */
  27660. static readonly ALWAYS: number;
  27661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27662. static readonly LESS: number;
  27663. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27664. static readonly EQUAL: number;
  27665. /** 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 */
  27666. static readonly LEQUAL: number;
  27667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27668. static readonly GREATER: number;
  27669. /** 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 */
  27670. static readonly GEQUAL: number;
  27671. /** 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 */
  27672. static readonly NOTEQUAL: number;
  27673. /** Passed to stencilOperation to specify that stencil value must be kept */
  27674. static readonly KEEP: number;
  27675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27676. static readonly REPLACE: number;
  27677. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27678. static readonly INCR: number;
  27679. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27680. static readonly DECR: number;
  27681. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27682. static readonly INVERT: number;
  27683. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27684. static readonly INCR_WRAP: number;
  27685. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27686. static readonly DECR_WRAP: number;
  27687. /** Texture is not repeating outside of 0..1 UVs */
  27688. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27689. /** Texture is repeating outside of 0..1 UVs */
  27690. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27691. /** Texture is repeating and mirrored */
  27692. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27693. /** ALPHA */
  27694. static readonly TEXTUREFORMAT_ALPHA: number;
  27695. /** LUMINANCE */
  27696. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27697. /** LUMINANCE_ALPHA */
  27698. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27699. /** RGB */
  27700. static readonly TEXTUREFORMAT_RGB: number;
  27701. /** RGBA */
  27702. static readonly TEXTUREFORMAT_RGBA: number;
  27703. /** RED */
  27704. static readonly TEXTUREFORMAT_RED: number;
  27705. /** RED (2nd reference) */
  27706. static readonly TEXTUREFORMAT_R: number;
  27707. /** RG */
  27708. static readonly TEXTUREFORMAT_RG: number;
  27709. /** RED_INTEGER */
  27710. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27711. /** RED_INTEGER (2nd reference) */
  27712. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27713. /** RG_INTEGER */
  27714. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27715. /** RGB_INTEGER */
  27716. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27717. /** RGBA_INTEGER */
  27718. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27719. /** UNSIGNED_BYTE */
  27720. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27721. /** UNSIGNED_BYTE (2nd reference) */
  27722. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27723. /** FLOAT */
  27724. static readonly TEXTURETYPE_FLOAT: number;
  27725. /** HALF_FLOAT */
  27726. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27727. /** BYTE */
  27728. static readonly TEXTURETYPE_BYTE: number;
  27729. /** SHORT */
  27730. static readonly TEXTURETYPE_SHORT: number;
  27731. /** UNSIGNED_SHORT */
  27732. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27733. /** INT */
  27734. static readonly TEXTURETYPE_INT: number;
  27735. /** UNSIGNED_INT */
  27736. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27737. /** UNSIGNED_SHORT_4_4_4_4 */
  27738. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27739. /** UNSIGNED_SHORT_5_5_5_1 */
  27740. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27741. /** UNSIGNED_SHORT_5_6_5 */
  27742. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27743. /** UNSIGNED_INT_2_10_10_10_REV */
  27744. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27745. /** UNSIGNED_INT_24_8 */
  27746. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27747. /** UNSIGNED_INT_10F_11F_11F_REV */
  27748. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27749. /** UNSIGNED_INT_5_9_9_9_REV */
  27750. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27751. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27752. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27753. /** nearest is mag = nearest and min = nearest and mip = linear */
  27754. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27755. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27756. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27757. /** Trilinear is mag = linear and min = linear and mip = linear */
  27758. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27759. /** nearest is mag = nearest and min = nearest and mip = linear */
  27760. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27761. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27762. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27763. /** Trilinear is mag = linear and min = linear and mip = linear */
  27764. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27765. /** mag = nearest and min = nearest and mip = nearest */
  27766. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27767. /** mag = nearest and min = linear and mip = nearest */
  27768. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27769. /** mag = nearest and min = linear and mip = linear */
  27770. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27771. /** mag = nearest and min = linear and mip = none */
  27772. static readonly TEXTURE_NEAREST_LINEAR: number;
  27773. /** mag = nearest and min = nearest and mip = none */
  27774. static readonly TEXTURE_NEAREST_NEAREST: number;
  27775. /** mag = linear and min = nearest and mip = nearest */
  27776. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27777. /** mag = linear and min = nearest and mip = linear */
  27778. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27779. /** mag = linear and min = linear and mip = none */
  27780. static readonly TEXTURE_LINEAR_LINEAR: number;
  27781. /** mag = linear and min = nearest and mip = none */
  27782. static readonly TEXTURE_LINEAR_NEAREST: number;
  27783. /** Explicit coordinates mode */
  27784. static readonly TEXTURE_EXPLICIT_MODE: number;
  27785. /** Spherical coordinates mode */
  27786. static readonly TEXTURE_SPHERICAL_MODE: number;
  27787. /** Planar coordinates mode */
  27788. static readonly TEXTURE_PLANAR_MODE: number;
  27789. /** Cubic coordinates mode */
  27790. static readonly TEXTURE_CUBIC_MODE: number;
  27791. /** Projection coordinates mode */
  27792. static readonly TEXTURE_PROJECTION_MODE: number;
  27793. /** Skybox coordinates mode */
  27794. static readonly TEXTURE_SKYBOX_MODE: number;
  27795. /** Inverse Cubic coordinates mode */
  27796. static readonly TEXTURE_INVCUBIC_MODE: number;
  27797. /** Equirectangular coordinates mode */
  27798. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27799. /** Equirectangular Fixed coordinates mode */
  27800. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27801. /** Equirectangular Fixed Mirrored coordinates mode */
  27802. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27803. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27804. static readonly SCALEMODE_FLOOR: number;
  27805. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27806. static readonly SCALEMODE_NEAREST: number;
  27807. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27808. static readonly SCALEMODE_CEILING: number;
  27809. /**
  27810. * Returns the current npm package of the sdk
  27811. */
  27812. static readonly NpmPackage: string;
  27813. /**
  27814. * Returns the current version of the framework
  27815. */
  27816. static readonly Version: string;
  27817. /**
  27818. * Returns a string describing the current engine
  27819. */
  27820. readonly description: string;
  27821. /**
  27822. * Gets or sets the epsilon value used by collision engine
  27823. */
  27824. static CollisionsEpsilon: number;
  27825. /**
  27826. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27827. */
  27828. static ShadersRepository: string;
  27829. /**
  27830. * Method called to create the default loading screen.
  27831. * This can be overriden in your own app.
  27832. * @param canvas The rendering canvas element
  27833. * @returns The loading screen
  27834. */
  27835. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27836. /**
  27837. * Method called to create the default rescale post process on each engine.
  27838. */
  27839. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27840. /**
  27841. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27842. */
  27843. forcePOTTextures: boolean;
  27844. /**
  27845. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27846. */
  27847. isFullscreen: boolean;
  27848. /**
  27849. * Gets a boolean indicating if the pointer is currently locked
  27850. */
  27851. isPointerLock: boolean;
  27852. /**
  27853. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27854. */
  27855. cullBackFaces: boolean;
  27856. /**
  27857. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27858. */
  27859. renderEvenInBackground: boolean;
  27860. /**
  27861. * Gets or sets a boolean indicating that cache can be kept between frames
  27862. */
  27863. preventCacheWipeBetweenFrames: boolean;
  27864. /**
  27865. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27866. **/
  27867. enableOfflineSupport: boolean;
  27868. /**
  27869. * 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)
  27870. **/
  27871. disableManifestCheck: boolean;
  27872. /**
  27873. * Gets the list of created scenes
  27874. */
  27875. scenes: Scene[];
  27876. /**
  27877. * Event raised when a new scene is created
  27878. */
  27879. onNewSceneAddedObservable: Observable<Scene>;
  27880. /**
  27881. * Gets the list of created postprocesses
  27882. */
  27883. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27884. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27885. validateShaderPrograms: boolean;
  27886. /**
  27887. * Observable event triggered each time the rendering canvas is resized
  27888. */
  27889. onResizeObservable: Observable<Engine>;
  27890. /**
  27891. * Observable event triggered each time the canvas loses focus
  27892. */
  27893. onCanvasBlurObservable: Observable<Engine>;
  27894. /**
  27895. * Observable event triggered each time the canvas gains focus
  27896. */
  27897. onCanvasFocusObservable: Observable<Engine>;
  27898. /**
  27899. * Observable event triggered each time the canvas receives pointerout event
  27900. */
  27901. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27902. /**
  27903. * Observable event triggered before each texture is initialized
  27904. */
  27905. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27906. private _vrDisplay;
  27907. private _vrSupported;
  27908. private _oldSize;
  27909. private _oldHardwareScaleFactor;
  27910. private _vrExclusivePointerMode;
  27911. private _webVRInitPromise;
  27912. /**
  27913. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27914. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27915. */
  27916. readonly isInVRExclusivePointerMode: boolean;
  27917. /**
  27918. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27919. */
  27920. disableUniformBuffers: boolean;
  27921. /** @hidden */
  27922. _uniformBuffers: UniformBuffer[];
  27923. /**
  27924. * Gets a boolean indicating that the engine supports uniform buffers
  27925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27926. */
  27927. readonly supportsUniformBuffers: boolean;
  27928. /**
  27929. * Observable raised when the engine begins a new frame
  27930. */
  27931. onBeginFrameObservable: Observable<Engine>;
  27932. /**
  27933. * If set, will be used to request the next animation frame for the render loop
  27934. */
  27935. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27936. /**
  27937. * Observable raised when the engine ends the current frame
  27938. */
  27939. onEndFrameObservable: Observable<Engine>;
  27940. /**
  27941. * Observable raised when the engine is about to compile a shader
  27942. */
  27943. onBeforeShaderCompilationObservable: Observable<Engine>;
  27944. /**
  27945. * Observable raised when the engine has jsut compiled a shader
  27946. */
  27947. onAfterShaderCompilationObservable: Observable<Engine>;
  27948. /** @hidden */
  27949. _gl: WebGLRenderingContext;
  27950. private _renderingCanvas;
  27951. private _windowIsBackground;
  27952. private _webGLVersion;
  27953. protected _highPrecisionShadersAllowed: boolean;
  27954. /** @hidden */
  27955. readonly _shouldUseHighPrecisionShader: boolean;
  27956. /**
  27957. * Gets a boolean indicating that only power of 2 textures are supported
  27958. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27959. */
  27960. readonly needPOTTextures: boolean;
  27961. /** @hidden */
  27962. _badOS: boolean;
  27963. /** @hidden */
  27964. _badDesktopOS: boolean;
  27965. /**
  27966. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27967. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27968. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27969. */
  27970. disableTextureBindingOptimization: boolean;
  27971. /**
  27972. * Gets the audio engine
  27973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27974. * @ignorenaming
  27975. */
  27976. static audioEngine: IAudioEngine;
  27977. /**
  27978. * Default AudioEngine factory responsible of creating the Audio Engine.
  27979. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27980. */
  27981. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27982. /**
  27983. * Default offline support factory responsible of creating a tool used to store data locally.
  27984. * By default, this will create a Database object if the workload has been embedded.
  27985. */
  27986. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27987. private _onFocus;
  27988. private _onBlur;
  27989. private _onCanvasPointerOut;
  27990. private _onCanvasBlur;
  27991. private _onCanvasFocus;
  27992. private _onFullscreenChange;
  27993. private _onPointerLockChange;
  27994. private _onVRDisplayPointerRestricted;
  27995. private _onVRDisplayPointerUnrestricted;
  27996. private _onVrDisplayConnect;
  27997. private _onVrDisplayDisconnect;
  27998. private _onVrDisplayPresentChange;
  27999. /**
  28000. * Observable signaled when VR display mode changes
  28001. */
  28002. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28003. /**
  28004. * Observable signaled when VR request present is complete
  28005. */
  28006. onVRRequestPresentComplete: Observable<boolean>;
  28007. /**
  28008. * Observable signaled when VR request present starts
  28009. */
  28010. onVRRequestPresentStart: Observable<Engine>;
  28011. private _hardwareScalingLevel;
  28012. /** @hidden */
  28013. protected _caps: EngineCapabilities;
  28014. private _pointerLockRequested;
  28015. private _isStencilEnable;
  28016. private _colorWrite;
  28017. private _loadingScreen;
  28018. /** @hidden */
  28019. _drawCalls: PerfCounter;
  28020. /** @hidden */
  28021. _textureCollisions: PerfCounter;
  28022. private _glVersion;
  28023. private _glRenderer;
  28024. private _glVendor;
  28025. private _videoTextureSupported;
  28026. private _renderingQueueLaunched;
  28027. private _activeRenderLoops;
  28028. private _deterministicLockstep;
  28029. private _lockstepMaxSteps;
  28030. /**
  28031. * Observable signaled when a context lost event is raised
  28032. */
  28033. onContextLostObservable: Observable<Engine>;
  28034. /**
  28035. * Observable signaled when a context restored event is raised
  28036. */
  28037. onContextRestoredObservable: Observable<Engine>;
  28038. private _onContextLost;
  28039. private _onContextRestored;
  28040. private _contextWasLost;
  28041. private _doNotHandleContextLost;
  28042. /**
  28043. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28045. */
  28046. doNotHandleContextLost: boolean;
  28047. private _performanceMonitor;
  28048. private _fps;
  28049. private _deltaTime;
  28050. /**
  28051. * Turn this value on if you want to pause FPS computation when in background
  28052. */
  28053. disablePerformanceMonitorInBackground: boolean;
  28054. /**
  28055. * Gets the performance monitor attached to this engine
  28056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28057. */
  28058. readonly performanceMonitor: PerformanceMonitor;
  28059. /**
  28060. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28061. */
  28062. disableVertexArrayObjects: boolean;
  28063. /** @hidden */
  28064. protected _depthCullingState: _DepthCullingState;
  28065. /** @hidden */
  28066. protected _stencilState: _StencilState;
  28067. /** @hidden */
  28068. protected _alphaState: _AlphaState;
  28069. /** @hidden */
  28070. protected _alphaMode: number;
  28071. protected _internalTexturesCache: InternalTexture[];
  28072. /** @hidden */
  28073. protected _activeChannel: number;
  28074. private _currentTextureChannel;
  28075. /** @hidden */
  28076. protected _boundTexturesCache: {
  28077. [key: string]: Nullable<InternalTexture>;
  28078. };
  28079. /** @hidden */
  28080. protected _currentEffect: Nullable<Effect>;
  28081. /** @hidden */
  28082. protected _currentProgram: Nullable<WebGLProgram>;
  28083. private _compiledEffects;
  28084. private _vertexAttribArraysEnabled;
  28085. /** @hidden */
  28086. protected _cachedViewport: Nullable<Viewport>;
  28087. private _cachedVertexArrayObject;
  28088. /** @hidden */
  28089. protected _cachedVertexBuffers: any;
  28090. /** @hidden */
  28091. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28092. /** @hidden */
  28093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28094. /** @hidden */
  28095. protected _currentRenderTarget: Nullable<InternalTexture>;
  28096. private _uintIndicesCurrentlySet;
  28097. private _currentBoundBuffer;
  28098. /** @hidden */
  28099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28100. private _currentBufferPointers;
  28101. private _currentInstanceLocations;
  28102. private _currentInstanceBuffers;
  28103. private _textureUnits;
  28104. private _firstBoundInternalTextureTracker;
  28105. private _lastBoundInternalTextureTracker;
  28106. private _workingCanvas;
  28107. private _workingContext;
  28108. private _rescalePostProcess;
  28109. private _dummyFramebuffer;
  28110. private _externalData;
  28111. private _bindedRenderFunction;
  28112. private _vaoRecordInProgress;
  28113. private _mustWipeVertexAttributes;
  28114. private _emptyTexture;
  28115. private _emptyCubeTexture;
  28116. private _emptyTexture3D;
  28117. /** @hidden */
  28118. _frameHandler: number;
  28119. private _nextFreeTextureSlots;
  28120. private _maxSimultaneousTextures;
  28121. private _activeRequests;
  28122. private _texturesSupported;
  28123. private _textureFormatInUse;
  28124. /**
  28125. * Gets the list of texture formats supported
  28126. */
  28127. readonly texturesSupported: Array<string>;
  28128. /**
  28129. * Gets the list of texture formats in use
  28130. */
  28131. readonly textureFormatInUse: Nullable<string>;
  28132. /**
  28133. * Gets the current viewport
  28134. */
  28135. readonly currentViewport: Nullable<Viewport>;
  28136. /**
  28137. * Gets the default empty texture
  28138. */
  28139. readonly emptyTexture: InternalTexture;
  28140. /**
  28141. * Gets the default empty 3D texture
  28142. */
  28143. readonly emptyTexture3D: InternalTexture;
  28144. /**
  28145. * Gets the default empty cube texture
  28146. */
  28147. readonly emptyCubeTexture: InternalTexture;
  28148. /**
  28149. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28150. */
  28151. readonly premultipliedAlpha: boolean;
  28152. /**
  28153. * Creates a new engine
  28154. * @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
  28155. * @param antialias defines enable antialiasing (default: false)
  28156. * @param options defines further options to be sent to the getContext() function
  28157. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28158. */
  28159. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28160. private _disableTouchAction;
  28161. private _rebuildInternalTextures;
  28162. private _rebuildEffects;
  28163. /**
  28164. * Gets a boolean indicating if all created effects are ready
  28165. * @returns true if all effects are ready
  28166. */
  28167. areAllEffectsReady(): boolean;
  28168. private _rebuildBuffers;
  28169. private _initGLContext;
  28170. /**
  28171. * Gets version of the current webGL context
  28172. */
  28173. readonly webGLVersion: number;
  28174. /**
  28175. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28176. */
  28177. readonly isStencilEnable: boolean;
  28178. private _prepareWorkingCanvas;
  28179. /**
  28180. * Reset the texture cache to empty state
  28181. */
  28182. resetTextureCache(): void;
  28183. /**
  28184. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28186. * @returns true if engine is in deterministic lock step mode
  28187. */
  28188. isDeterministicLockStep(): boolean;
  28189. /**
  28190. * Gets the max steps when engine is running in deterministic lock step
  28191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28192. * @returns the max steps
  28193. */
  28194. getLockstepMaxSteps(): number;
  28195. /**
  28196. * Gets an object containing information about the current webGL context
  28197. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28198. */
  28199. getGlInfo(): {
  28200. vendor: string;
  28201. renderer: string;
  28202. version: string;
  28203. };
  28204. /**
  28205. * Gets current aspect ratio
  28206. * @param camera defines the camera to use to get the aspect ratio
  28207. * @param useScreen defines if screen size must be used (or the current render target if any)
  28208. * @returns a number defining the aspect ratio
  28209. */
  28210. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28211. /**
  28212. * Gets current screen aspect ratio
  28213. * @returns a number defining the aspect ratio
  28214. */
  28215. getScreenAspectRatio(): number;
  28216. /**
  28217. * Gets the current render width
  28218. * @param useScreen defines if screen size must be used (or the current render target if any)
  28219. * @returns a number defining the current render width
  28220. */
  28221. getRenderWidth(useScreen?: boolean): number;
  28222. /**
  28223. * Gets the current render height
  28224. * @param useScreen defines if screen size must be used (or the current render target if any)
  28225. * @returns a number defining the current render height
  28226. */
  28227. getRenderHeight(useScreen?: boolean): number;
  28228. /**
  28229. * Gets the HTML canvas attached with the current webGL context
  28230. * @returns a HTML canvas
  28231. */
  28232. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28233. /**
  28234. * Gets the client rect of the HTML canvas attached with the current webGL context
  28235. * @returns a client rectanglee
  28236. */
  28237. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28238. /**
  28239. * Defines the hardware scaling level.
  28240. * By default the hardware scaling level is computed from the window device ratio.
  28241. * 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.
  28242. * @param level defines the level to use
  28243. */
  28244. setHardwareScalingLevel(level: number): void;
  28245. /**
  28246. * Gets the current hardware scaling level.
  28247. * By default the hardware scaling level is computed from the window device ratio.
  28248. * 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.
  28249. * @returns a number indicating the current hardware scaling level
  28250. */
  28251. getHardwareScalingLevel(): number;
  28252. /**
  28253. * Gets the list of loaded textures
  28254. * @returns an array containing all loaded textures
  28255. */
  28256. getLoadedTexturesCache(): InternalTexture[];
  28257. /**
  28258. * Gets the object containing all engine capabilities
  28259. * @returns the EngineCapabilities object
  28260. */
  28261. getCaps(): EngineCapabilities;
  28262. /**
  28263. * Gets the current depth function
  28264. * @returns a number defining the depth function
  28265. */
  28266. getDepthFunction(): Nullable<number>;
  28267. /**
  28268. * Sets the current depth function
  28269. * @param depthFunc defines the function to use
  28270. */
  28271. setDepthFunction(depthFunc: number): void;
  28272. /**
  28273. * Sets the current depth function to GREATER
  28274. */
  28275. setDepthFunctionToGreater(): void;
  28276. /**
  28277. * Sets the current depth function to GEQUAL
  28278. */
  28279. setDepthFunctionToGreaterOrEqual(): void;
  28280. /**
  28281. * Sets the current depth function to LESS
  28282. */
  28283. setDepthFunctionToLess(): void;
  28284. private _cachedStencilBuffer;
  28285. private _cachedStencilFunction;
  28286. private _cachedStencilMask;
  28287. private _cachedStencilOperationPass;
  28288. private _cachedStencilOperationFail;
  28289. private _cachedStencilOperationDepthFail;
  28290. private _cachedStencilReference;
  28291. /**
  28292. * Caches the the state of the stencil buffer
  28293. */
  28294. cacheStencilState(): void;
  28295. /**
  28296. * Restores the state of the stencil buffer
  28297. */
  28298. restoreStencilState(): void;
  28299. /**
  28300. * Sets the current depth function to LEQUAL
  28301. */
  28302. setDepthFunctionToLessOrEqual(): void;
  28303. /**
  28304. * Gets a boolean indicating if stencil buffer is enabled
  28305. * @returns the current stencil buffer state
  28306. */
  28307. getStencilBuffer(): boolean;
  28308. /**
  28309. * Enable or disable the stencil buffer
  28310. * @param enable defines if the stencil buffer must be enabled or disabled
  28311. */
  28312. setStencilBuffer(enable: boolean): void;
  28313. /**
  28314. * Gets the current stencil mask
  28315. * @returns a number defining the new stencil mask to use
  28316. */
  28317. getStencilMask(): number;
  28318. /**
  28319. * Sets the current stencil mask
  28320. * @param mask defines the new stencil mask to use
  28321. */
  28322. setStencilMask(mask: number): void;
  28323. /**
  28324. * Gets the current stencil function
  28325. * @returns a number defining the stencil function to use
  28326. */
  28327. getStencilFunction(): number;
  28328. /**
  28329. * Gets the current stencil reference value
  28330. * @returns a number defining the stencil reference value to use
  28331. */
  28332. getStencilFunctionReference(): number;
  28333. /**
  28334. * Gets the current stencil mask
  28335. * @returns a number defining the stencil mask to use
  28336. */
  28337. getStencilFunctionMask(): number;
  28338. /**
  28339. * Sets the current stencil function
  28340. * @param stencilFunc defines the new stencil function to use
  28341. */
  28342. setStencilFunction(stencilFunc: number): void;
  28343. /**
  28344. * Sets the current stencil reference
  28345. * @param reference defines the new stencil reference to use
  28346. */
  28347. setStencilFunctionReference(reference: number): void;
  28348. /**
  28349. * Sets the current stencil mask
  28350. * @param mask defines the new stencil mask to use
  28351. */
  28352. setStencilFunctionMask(mask: number): void;
  28353. /**
  28354. * Gets the current stencil operation when stencil fails
  28355. * @returns a number defining stencil operation to use when stencil fails
  28356. */
  28357. getStencilOperationFail(): number;
  28358. /**
  28359. * Gets the current stencil operation when depth fails
  28360. * @returns a number defining stencil operation to use when depth fails
  28361. */
  28362. getStencilOperationDepthFail(): number;
  28363. /**
  28364. * Gets the current stencil operation when stencil passes
  28365. * @returns a number defining stencil operation to use when stencil passes
  28366. */
  28367. getStencilOperationPass(): number;
  28368. /**
  28369. * Sets the stencil operation to use when stencil fails
  28370. * @param operation defines the stencil operation to use when stencil fails
  28371. */
  28372. setStencilOperationFail(operation: number): void;
  28373. /**
  28374. * Sets the stencil operation to use when depth fails
  28375. * @param operation defines the stencil operation to use when depth fails
  28376. */
  28377. setStencilOperationDepthFail(operation: number): void;
  28378. /**
  28379. * Sets the stencil operation to use when stencil passes
  28380. * @param operation defines the stencil operation to use when stencil passes
  28381. */
  28382. setStencilOperationPass(operation: number): void;
  28383. /**
  28384. * Sets a boolean indicating if the dithering state is enabled or disabled
  28385. * @param value defines the dithering state
  28386. */
  28387. setDitheringState(value: boolean): void;
  28388. /**
  28389. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28390. * @param value defines the rasterizer state
  28391. */
  28392. setRasterizerState(value: boolean): void;
  28393. /**
  28394. * stop executing a render loop function and remove it from the execution array
  28395. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28396. */
  28397. stopRenderLoop(renderFunction?: () => void): void;
  28398. /** @hidden */
  28399. _renderLoop(): void;
  28400. /**
  28401. * Register and execute a render loop. The engine can have more than one render function
  28402. * @param renderFunction defines the function to continuously execute
  28403. */
  28404. runRenderLoop(renderFunction: () => void): void;
  28405. /**
  28406. * Toggle full screen mode
  28407. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28408. */
  28409. switchFullscreen(requestPointerLock: boolean): void;
  28410. /**
  28411. * Enters full screen mode
  28412. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28413. */
  28414. enterFullscreen(requestPointerLock: boolean): void;
  28415. /**
  28416. * Exits full screen mode
  28417. */
  28418. exitFullscreen(): void;
  28419. /**
  28420. * Clear the current render buffer or the current render target (if any is set up)
  28421. * @param color defines the color to use
  28422. * @param backBuffer defines if the back buffer must be cleared
  28423. * @param depth defines if the depth buffer must be cleared
  28424. * @param stencil defines if the stencil buffer must be cleared
  28425. */
  28426. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28427. /**
  28428. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28430. * @param y defines the y-coordinate of the corner of the clear rectangle
  28431. * @param width defines the width of the clear rectangle
  28432. * @param height defines the height of the clear rectangle
  28433. * @param clearColor defines the clear color
  28434. */
  28435. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28436. /**
  28437. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28439. * @param y defines the y-coordinate of the corner of the clear rectangle
  28440. * @param width defines the width of the clear rectangle
  28441. * @param height defines the height of the clear rectangle
  28442. */
  28443. enableScissor(x: number, y: number, width: number, height: number): void;
  28444. /**
  28445. * Disable previously set scissor test rectangle
  28446. */
  28447. disableScissor(): void;
  28448. private _viewportCached;
  28449. /** @hidden */
  28450. _viewport(x: number, y: number, width: number, height: number): void;
  28451. /**
  28452. * Set the WebGL's viewport
  28453. * @param viewport defines the viewport element to be used
  28454. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28455. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28456. */
  28457. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28458. /**
  28459. * Directly set the WebGL Viewport
  28460. * @param x defines the x coordinate of the viewport (in screen space)
  28461. * @param y defines the y coordinate of the viewport (in screen space)
  28462. * @param width defines the width of the viewport (in screen space)
  28463. * @param height defines the height of the viewport (in screen space)
  28464. * @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
  28465. */
  28466. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28467. /**
  28468. * Begin a new frame
  28469. */
  28470. beginFrame(): void;
  28471. /**
  28472. * Enf the current frame
  28473. */
  28474. endFrame(): void;
  28475. /**
  28476. * Resize the view according to the canvas' size
  28477. */
  28478. resize(): void;
  28479. /**
  28480. * Force a specific size of the canvas
  28481. * @param width defines the new canvas' width
  28482. * @param height defines the new canvas' height
  28483. */
  28484. setSize(width: number, height: number): void;
  28485. /**
  28486. * Gets a boolean indicating if a webVR device was detected
  28487. * @returns true if a webVR device was detected
  28488. */
  28489. isVRDevicePresent(): boolean;
  28490. /**
  28491. * Gets the current webVR device
  28492. * @returns the current webVR device (or null)
  28493. */
  28494. getVRDevice(): any;
  28495. /**
  28496. * Initializes a webVR display and starts listening to display change events
  28497. * The onVRDisplayChangedObservable will be notified upon these changes
  28498. * @returns The onVRDisplayChangedObservable
  28499. */
  28500. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28501. /**
  28502. * Initializes a webVR display and starts listening to display change events
  28503. * The onVRDisplayChangedObservable will be notified upon these changes
  28504. * @returns A promise containing a VRDisplay and if vr is supported
  28505. */
  28506. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28507. /**
  28508. * Call this function to switch to webVR mode
  28509. * Will do nothing if webVR is not supported or if there is no webVR device
  28510. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28511. */
  28512. enableVR(): void;
  28513. /**
  28514. * Call this function to leave webVR mode
  28515. * Will do nothing if webVR is not supported or if there is no webVR device
  28516. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28517. */
  28518. disableVR(): void;
  28519. private _onVRFullScreenTriggered;
  28520. private _getVRDisplaysAsync;
  28521. /**
  28522. * Binds the frame buffer to the specified texture.
  28523. * @param texture The texture to render to or null for the default canvas
  28524. * @param faceIndex The face of the texture to render to in case of cube texture
  28525. * @param requiredWidth The width of the target to render to
  28526. * @param requiredHeight The height of the target to render to
  28527. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28528. * @param depthStencilTexture The depth stencil texture to use to render
  28529. * @param lodLevel defines le lod level to bind to the frame buffer
  28530. */
  28531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28532. private bindUnboundFramebuffer;
  28533. /**
  28534. * Unbind the current render target texture from the webGL context
  28535. * @param texture defines the render target texture to unbind
  28536. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28537. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28538. */
  28539. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28540. /**
  28541. * Unbind a list of render target textures from the webGL context
  28542. * This is used only when drawBuffer extension or webGL2 are active
  28543. * @param textures defines the render target textures to unbind
  28544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28546. */
  28547. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28548. /**
  28549. * Force the mipmap generation for the given render target texture
  28550. * @param texture defines the render target texture to use
  28551. */
  28552. generateMipMapsForCubemap(texture: InternalTexture): void;
  28553. /**
  28554. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28555. */
  28556. flushFramebuffer(): void;
  28557. /**
  28558. * Unbind the current render target and bind the default framebuffer
  28559. */
  28560. restoreDefaultFramebuffer(): void;
  28561. /**
  28562. * Create an uniform buffer
  28563. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28564. * @param elements defines the content of the uniform buffer
  28565. * @returns the webGL uniform buffer
  28566. */
  28567. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28568. /**
  28569. * Create a dynamic uniform buffer
  28570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28571. * @param elements defines the content of the uniform buffer
  28572. * @returns the webGL uniform buffer
  28573. */
  28574. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28575. /**
  28576. * Update an existing uniform buffer
  28577. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28578. * @param uniformBuffer defines the target uniform buffer
  28579. * @param elements defines the content to update
  28580. * @param offset defines the offset in the uniform buffer where update should start
  28581. * @param count defines the size of the data to update
  28582. */
  28583. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28584. private _resetVertexBufferBinding;
  28585. /**
  28586. * Creates a vertex buffer
  28587. * @param data the data for the vertex buffer
  28588. * @returns the new WebGL static buffer
  28589. */
  28590. createVertexBuffer(data: DataArray): WebGLBuffer;
  28591. /**
  28592. * Creates a dynamic vertex buffer
  28593. * @param data the data for the dynamic vertex buffer
  28594. * @returns the new WebGL dynamic buffer
  28595. */
  28596. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28597. /**
  28598. * Update a dynamic index buffer
  28599. * @param indexBuffer defines the target index buffer
  28600. * @param indices defines the data to update
  28601. * @param offset defines the offset in the target index buffer where update should start
  28602. */
  28603. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28604. /**
  28605. * Updates a dynamic vertex buffer.
  28606. * @param vertexBuffer the vertex buffer to update
  28607. * @param data the data used to update the vertex buffer
  28608. * @param byteOffset the byte offset of the data
  28609. * @param byteLength the byte length of the data
  28610. */
  28611. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28612. private _resetIndexBufferBinding;
  28613. /**
  28614. * Creates a new index buffer
  28615. * @param indices defines the content of the index buffer
  28616. * @param updatable defines if the index buffer must be updatable
  28617. * @returns a new webGL buffer
  28618. */
  28619. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28620. /**
  28621. * Bind a webGL buffer to the webGL context
  28622. * @param buffer defines the buffer to bind
  28623. */
  28624. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28625. /**
  28626. * Bind an uniform buffer to the current webGL context
  28627. * @param buffer defines the buffer to bind
  28628. */
  28629. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28630. /**
  28631. * Bind a buffer to the current webGL context at a given location
  28632. * @param buffer defines the buffer to bind
  28633. * @param location defines the index where to bind the buffer
  28634. */
  28635. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28636. /**
  28637. * Bind a specific block at a given index in a specific shader program
  28638. * @param shaderProgram defines the shader program
  28639. * @param blockName defines the block name
  28640. * @param index defines the index where to bind the block
  28641. */
  28642. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28643. private bindIndexBuffer;
  28644. private bindBuffer;
  28645. /**
  28646. * update the bound buffer with the given data
  28647. * @param data defines the data to update
  28648. */
  28649. updateArrayBuffer(data: Float32Array): void;
  28650. private _vertexAttribPointer;
  28651. private _bindIndexBufferWithCache;
  28652. private _bindVertexBuffersAttributes;
  28653. /**
  28654. * Records a vertex array object
  28655. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28656. * @param vertexBuffers defines the list of vertex buffers to store
  28657. * @param indexBuffer defines the index buffer to store
  28658. * @param effect defines the effect to store
  28659. * @returns the new vertex array object
  28660. */
  28661. recordVertexArrayObject(vertexBuffers: {
  28662. [key: string]: VertexBuffer;
  28663. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28664. /**
  28665. * Bind a specific vertex array object
  28666. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28667. * @param vertexArrayObject defines the vertex array object to bind
  28668. * @param indexBuffer defines the index buffer to bind
  28669. */
  28670. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28671. /**
  28672. * Bind webGl buffers directly to the webGL context
  28673. * @param vertexBuffer defines the vertex buffer to bind
  28674. * @param indexBuffer defines the index buffer to bind
  28675. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28676. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28677. * @param effect defines the effect associated with the vertex buffer
  28678. */
  28679. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28680. private _unbindVertexArrayObject;
  28681. /**
  28682. * Bind a list of vertex buffers to the webGL context
  28683. * @param vertexBuffers defines the list of vertex buffers to bind
  28684. * @param indexBuffer defines the index buffer to bind
  28685. * @param effect defines the effect associated with the vertex buffers
  28686. */
  28687. bindBuffers(vertexBuffers: {
  28688. [key: string]: Nullable<VertexBuffer>;
  28689. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28690. /**
  28691. * Unbind all instance attributes
  28692. */
  28693. unbindInstanceAttributes(): void;
  28694. /**
  28695. * Release and free the memory of a vertex array object
  28696. * @param vao defines the vertex array object to delete
  28697. */
  28698. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28699. /** @hidden */
  28700. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28701. /**
  28702. * Creates a webGL buffer to use with instanciation
  28703. * @param capacity defines the size of the buffer
  28704. * @returns the webGL buffer
  28705. */
  28706. createInstancesBuffer(capacity: number): WebGLBuffer;
  28707. /**
  28708. * Delete a webGL buffer used with instanciation
  28709. * @param buffer defines the webGL buffer to delete
  28710. */
  28711. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28712. /**
  28713. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28714. * @param instancesBuffer defines the webGL buffer to update and bind
  28715. * @param data defines the data to store in the buffer
  28716. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28717. */
  28718. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28719. /**
  28720. * Apply all cached states (depth, culling, stencil and alpha)
  28721. */
  28722. applyStates(): void;
  28723. /**
  28724. * Send a draw order
  28725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28726. * @param indexStart defines the starting index
  28727. * @param indexCount defines the number of index to draw
  28728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28729. */
  28730. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28731. /**
  28732. * Draw a list of points
  28733. * @param verticesStart defines the index of first vertex to draw
  28734. * @param verticesCount defines the count of vertices to draw
  28735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28736. */
  28737. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28738. /**
  28739. * Draw a list of unindexed primitives
  28740. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28741. * @param verticesStart defines the index of first vertex to draw
  28742. * @param verticesCount defines the count of vertices to draw
  28743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28744. */
  28745. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28746. /**
  28747. * Draw a list of indexed primitives
  28748. * @param fillMode defines the primitive to use
  28749. * @param indexStart defines the starting index
  28750. * @param indexCount defines the number of index to draw
  28751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28752. */
  28753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28754. /**
  28755. * Draw a list of unindexed primitives
  28756. * @param fillMode defines the primitive to use
  28757. * @param verticesStart defines the index of first vertex to draw
  28758. * @param verticesCount defines the count of vertices to draw
  28759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28760. */
  28761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28762. private _drawMode;
  28763. /** @hidden */
  28764. _releaseEffect(effect: Effect): void;
  28765. /** @hidden */
  28766. _deleteProgram(program: WebGLProgram): void;
  28767. /**
  28768. * Create a new effect (used to store vertex/fragment shaders)
  28769. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28770. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28771. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28772. * @param samplers defines an array of string used to represent textures
  28773. * @param defines defines the string containing the defines to use to compile the shaders
  28774. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28775. * @param onCompiled defines a function to call when the effect creation is successful
  28776. * @param onError defines a function to call when the effect creation has failed
  28777. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28778. * @returns the new Effect
  28779. */
  28780. 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;
  28781. private _compileShader;
  28782. private _compileRawShader;
  28783. /**
  28784. * Directly creates a webGL program
  28785. * @param vertexCode defines the vertex shader code to use
  28786. * @param fragmentCode defines the fragment shader code to use
  28787. * @param context defines the webGL context to use (if not set, the current one will be used)
  28788. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28789. * @returns the new webGL program
  28790. */
  28791. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28792. /**
  28793. * Creates a webGL program
  28794. * @param vertexCode defines the vertex shader code to use
  28795. * @param fragmentCode defines the fragment shader code to use
  28796. * @param defines defines the string containing the defines to use to compile the shaders
  28797. * @param context defines the webGL context to use (if not set, the current one will be used)
  28798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28799. * @returns the new webGL program
  28800. */
  28801. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28802. private _createShaderProgram;
  28803. private _finalizeProgram;
  28804. /** @hidden */
  28805. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28806. /** @hidden */
  28807. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28808. /**
  28809. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28810. * @param shaderProgram defines the webGL program to use
  28811. * @param uniformsNames defines the list of uniform names
  28812. * @returns an array of webGL uniform locations
  28813. */
  28814. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28815. /**
  28816. * Gets the lsit of active attributes for a given webGL program
  28817. * @param shaderProgram defines the webGL program to use
  28818. * @param attributesNames defines the list of attribute names to get
  28819. * @returns an array of indices indicating the offset of each attribute
  28820. */
  28821. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28822. /**
  28823. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28824. * @param effect defines the effect to activate
  28825. */
  28826. enableEffect(effect: Nullable<Effect>): void;
  28827. /**
  28828. * Set the value of an uniform to an array of int32
  28829. * @param uniform defines the webGL uniform location where to store the value
  28830. * @param array defines the array of int32 to store
  28831. */
  28832. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28833. /**
  28834. * Set the value of an uniform to an array of int32 (stored as vec2)
  28835. * @param uniform defines the webGL uniform location where to store the value
  28836. * @param array defines the array of int32 to store
  28837. */
  28838. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28839. /**
  28840. * Set the value of an uniform to an array of int32 (stored as vec3)
  28841. * @param uniform defines the webGL uniform location where to store the value
  28842. * @param array defines the array of int32 to store
  28843. */
  28844. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28845. /**
  28846. * Set the value of an uniform to an array of int32 (stored as vec4)
  28847. * @param uniform defines the webGL uniform location where to store the value
  28848. * @param array defines the array of int32 to store
  28849. */
  28850. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28851. /**
  28852. * Set the value of an uniform to an array of float32
  28853. * @param uniform defines the webGL uniform location where to store the value
  28854. * @param array defines the array of float32 to store
  28855. */
  28856. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28857. /**
  28858. * Set the value of an uniform to an array of float32 (stored as vec2)
  28859. * @param uniform defines the webGL uniform location where to store the value
  28860. * @param array defines the array of float32 to store
  28861. */
  28862. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28863. /**
  28864. * Set the value of an uniform to an array of float32 (stored as vec3)
  28865. * @param uniform defines the webGL uniform location where to store the value
  28866. * @param array defines the array of float32 to store
  28867. */
  28868. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28869. /**
  28870. * Set the value of an uniform to an array of float32 (stored as vec4)
  28871. * @param uniform defines the webGL uniform location where to store the value
  28872. * @param array defines the array of float32 to store
  28873. */
  28874. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28875. /**
  28876. * Set the value of an uniform to an array of number
  28877. * @param uniform defines the webGL uniform location where to store the value
  28878. * @param array defines the array of number to store
  28879. */
  28880. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28881. /**
  28882. * Set the value of an uniform to an array of number (stored as vec2)
  28883. * @param uniform defines the webGL uniform location where to store the value
  28884. * @param array defines the array of number to store
  28885. */
  28886. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28887. /**
  28888. * Set the value of an uniform to an array of number (stored as vec3)
  28889. * @param uniform defines the webGL uniform location where to store the value
  28890. * @param array defines the array of number to store
  28891. */
  28892. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28893. /**
  28894. * Set the value of an uniform to an array of number (stored as vec4)
  28895. * @param uniform defines the webGL uniform location where to store the value
  28896. * @param array defines the array of number to store
  28897. */
  28898. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28899. /**
  28900. * Set the value of an uniform to an array of float32 (stored as matrices)
  28901. * @param uniform defines the webGL uniform location where to store the value
  28902. * @param matrices defines the array of float32 to store
  28903. */
  28904. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28905. /**
  28906. * Set the value of an uniform to a matrix
  28907. * @param uniform defines the webGL uniform location where to store the value
  28908. * @param matrix defines the matrix to store
  28909. */
  28910. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28911. /**
  28912. * Set the value of an uniform to a matrix (3x3)
  28913. * @param uniform defines the webGL uniform location where to store the value
  28914. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28915. */
  28916. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28917. /**
  28918. * Set the value of an uniform to a matrix (2x2)
  28919. * @param uniform defines the webGL uniform location where to store the value
  28920. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28921. */
  28922. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28923. /**
  28924. * Set the value of an uniform to a number (int)
  28925. * @param uniform defines the webGL uniform location where to store the value
  28926. * @param value defines the int number to store
  28927. */
  28928. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28929. /**
  28930. * Set the value of an uniform to a number (float)
  28931. * @param uniform defines the webGL uniform location where to store the value
  28932. * @param value defines the float number to store
  28933. */
  28934. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28935. /**
  28936. * Set the value of an uniform to a vec2
  28937. * @param uniform defines the webGL uniform location where to store the value
  28938. * @param x defines the 1st component of the value
  28939. * @param y defines the 2nd component of the value
  28940. */
  28941. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28942. /**
  28943. * Set the value of an uniform to a vec3
  28944. * @param uniform defines the webGL uniform location where to store the value
  28945. * @param x defines the 1st component of the value
  28946. * @param y defines the 2nd component of the value
  28947. * @param z defines the 3rd component of the value
  28948. */
  28949. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28950. /**
  28951. * Set the value of an uniform to a boolean
  28952. * @param uniform defines the webGL uniform location where to store the value
  28953. * @param bool defines the boolean to store
  28954. */
  28955. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28956. /**
  28957. * Set the value of an uniform to a vec4
  28958. * @param uniform defines the webGL uniform location where to store the value
  28959. * @param x defines the 1st component of the value
  28960. * @param y defines the 2nd component of the value
  28961. * @param z defines the 3rd component of the value
  28962. * @param w defines the 4th component of the value
  28963. */
  28964. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28965. /**
  28966. * Set the value of an uniform to a Color3
  28967. * @param uniform defines the webGL uniform location where to store the value
  28968. * @param color3 defines the color to store
  28969. */
  28970. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28971. /**
  28972. * Set the value of an uniform to a Color3 and an alpha value
  28973. * @param uniform defines the webGL uniform location where to store the value
  28974. * @param color3 defines the color to store
  28975. * @param alpha defines the alpha component to store
  28976. */
  28977. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28978. /**
  28979. * Sets a Color4 on a uniform variable
  28980. * @param uniform defines the uniform location
  28981. * @param color4 defines the value to be set
  28982. */
  28983. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28984. /**
  28985. * Set various states to the webGL context
  28986. * @param culling defines backface culling state
  28987. * @param zOffset defines the value to apply to zOffset (0 by default)
  28988. * @param force defines if states must be applied even if cache is up to date
  28989. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28990. */
  28991. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28992. /**
  28993. * Set the z offset to apply to current rendering
  28994. * @param value defines the offset to apply
  28995. */
  28996. setZOffset(value: number): void;
  28997. /**
  28998. * Gets the current value of the zOffset
  28999. * @returns the current zOffset state
  29000. */
  29001. getZOffset(): number;
  29002. /**
  29003. * Enable or disable depth buffering
  29004. * @param enable defines the state to set
  29005. */
  29006. setDepthBuffer(enable: boolean): void;
  29007. /**
  29008. * Gets a boolean indicating if depth writing is enabled
  29009. * @returns the current depth writing state
  29010. */
  29011. getDepthWrite(): boolean;
  29012. /**
  29013. * Enable or disable depth writing
  29014. * @param enable defines the state to set
  29015. */
  29016. setDepthWrite(enable: boolean): void;
  29017. /**
  29018. * Enable or disable color writing
  29019. * @param enable defines the state to set
  29020. */
  29021. setColorWrite(enable: boolean): void;
  29022. /**
  29023. * Gets a boolean indicating if color writing is enabled
  29024. * @returns the current color writing state
  29025. */
  29026. getColorWrite(): boolean;
  29027. /**
  29028. * Sets alpha constants used by some alpha blending modes
  29029. * @param r defines the red component
  29030. * @param g defines the green component
  29031. * @param b defines the blue component
  29032. * @param a defines the alpha component
  29033. */
  29034. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29035. /**
  29036. * Sets the current alpha mode
  29037. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29038. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29040. */
  29041. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29042. /**
  29043. * Gets the current alpha mode
  29044. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29045. * @returns the current alpha mode
  29046. */
  29047. getAlphaMode(): number;
  29048. /**
  29049. * Clears the list of texture accessible through engine.
  29050. * This can help preventing texture load conflict due to name collision.
  29051. */
  29052. clearInternalTexturesCache(): void;
  29053. /**
  29054. * Force the entire cache to be cleared
  29055. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29056. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29057. */
  29058. wipeCaches(bruteForce?: boolean): void;
  29059. /**
  29060. * Set the compressed texture format to use, based on the formats you have, and the formats
  29061. * supported by the hardware / browser.
  29062. *
  29063. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29064. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29065. * to API arguments needed to compressed textures. This puts the burden on the container
  29066. * generator to house the arcane code for determining these for current & future formats.
  29067. *
  29068. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29069. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29070. *
  29071. * Note: The result of this call is not taken into account when a texture is base64.
  29072. *
  29073. * @param formatsAvailable defines the list of those format families you have created
  29074. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29075. *
  29076. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29077. * @returns The extension selected.
  29078. */
  29079. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29080. private _getSamplingParameters;
  29081. private _partialLoadImg;
  29082. private _cascadeLoadImgs;
  29083. /** @hidden */
  29084. _createTexture(): WebGLTexture;
  29085. /**
  29086. * Usually called from Texture.ts.
  29087. * Passed information to create a WebGLTexture
  29088. * @param urlArg defines a value which contains one of the following:
  29089. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29090. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29091. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29092. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29093. * @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)
  29094. * @param scene needed for loading to the correct scene
  29095. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29096. * @param onLoad optional callback to be called upon successful completion
  29097. * @param onError optional callback to be called upon failure
  29098. * @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
  29099. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29100. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29101. * @param forcedExtension defines the extension to use to pick the right loader
  29102. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29103. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29104. */
  29105. 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;
  29106. private _rescaleTexture;
  29107. /**
  29108. * Update a raw texture
  29109. * @param texture defines the texture to update
  29110. * @param data defines the data to store in the texture
  29111. * @param format defines the format of the data
  29112. * @param invertY defines if data must be stored with Y axis inverted
  29113. * @param compression defines the compression used (null by default)
  29114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29115. */
  29116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29117. /**
  29118. * Creates a raw texture
  29119. * @param data defines the data to store in the texture
  29120. * @param width defines the width of the texture
  29121. * @param height defines the height of the texture
  29122. * @param format defines the format of the data
  29123. * @param generateMipMaps defines if the engine should generate the mip levels
  29124. * @param invertY defines if data must be stored with Y axis inverted
  29125. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29126. * @param compression defines the compression used (null by default)
  29127. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29128. * @returns the raw texture inside an InternalTexture
  29129. */
  29130. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29131. private _unpackFlipYCached;
  29132. /**
  29133. * In case you are sharing the context with other applications, it might
  29134. * be interested to not cache the unpack flip y state to ensure a consistent
  29135. * value would be set.
  29136. */
  29137. enableUnpackFlipYCached: boolean;
  29138. /** @hidden */
  29139. _unpackFlipY(value: boolean): void;
  29140. /** @hidden */
  29141. _getUnpackAlignement(): number;
  29142. /**
  29143. * Creates a dynamic texture
  29144. * @param width defines the width of the texture
  29145. * @param height defines the height of the texture
  29146. * @param generateMipMaps defines if the engine should generate the mip levels
  29147. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29148. * @returns the dynamic texture inside an InternalTexture
  29149. */
  29150. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29151. /**
  29152. * Update the sampling mode of a given texture
  29153. * @param samplingMode defines the required sampling mode
  29154. * @param texture defines the texture to update
  29155. */
  29156. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29157. /**
  29158. * Update the content of a dynamic texture
  29159. * @param texture defines the texture to update
  29160. * @param canvas defines the canvas containing the source
  29161. * @param invertY defines if data must be stored with Y axis inverted
  29162. * @param premulAlpha defines if alpha is stored as premultiplied
  29163. * @param format defines the format of the data
  29164. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29165. */
  29166. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29167. /**
  29168. * Update a video texture
  29169. * @param texture defines the texture to update
  29170. * @param video defines the video element to use
  29171. * @param invertY defines if data must be stored with Y axis inverted
  29172. */
  29173. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29174. /**
  29175. * Updates a depth texture Comparison Mode and Function.
  29176. * If the comparison Function is equal to 0, the mode will be set to none.
  29177. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29178. * @param texture The texture to set the comparison function for
  29179. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29180. */
  29181. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29182. private _setupDepthStencilTexture;
  29183. /**
  29184. * Creates a depth stencil texture.
  29185. * This is only available in WebGL 2 or with the depth texture extension available.
  29186. * @param size The size of face edge in the texture.
  29187. * @param options The options defining the texture.
  29188. * @returns The texture
  29189. */
  29190. createDepthStencilTexture(size: number | {
  29191. width: number;
  29192. height: number;
  29193. }, options: DepthTextureCreationOptions): InternalTexture;
  29194. /**
  29195. * Creates a depth stencil texture.
  29196. * This is only available in WebGL 2 or with the depth texture extension available.
  29197. * @param size The size of face edge in the texture.
  29198. * @param options The options defining the texture.
  29199. * @returns The texture
  29200. */
  29201. private _createDepthStencilTexture;
  29202. /**
  29203. * Creates a depth stencil cube texture.
  29204. * This is only available in WebGL 2.
  29205. * @param size The size of face edge in the cube texture.
  29206. * @param options The options defining the cube texture.
  29207. * @returns The cube texture
  29208. */
  29209. private _createDepthStencilCubeTexture;
  29210. /**
  29211. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29212. * @param renderTarget The render target to set the frame buffer for
  29213. */
  29214. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29215. /**
  29216. * Creates a new render target texture
  29217. * @param size defines the size of the texture
  29218. * @param options defines the options used to create the texture
  29219. * @returns a new render target texture stored in an InternalTexture
  29220. */
  29221. createRenderTargetTexture(size: number | {
  29222. width: number;
  29223. height: number;
  29224. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29225. /**
  29226. * Create a multi render target texture
  29227. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29228. * @param size defines the size of the texture
  29229. * @param options defines the creation options
  29230. * @returns the cube texture as an InternalTexture
  29231. */
  29232. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29233. private _setupFramebufferDepthAttachments;
  29234. /**
  29235. * Updates the sample count of a render target texture
  29236. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29237. * @param texture defines the texture to update
  29238. * @param samples defines the sample count to set
  29239. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29240. */
  29241. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29242. /**
  29243. * Update the sample count for a given multiple render target texture
  29244. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29245. * @param textures defines the textures to update
  29246. * @param samples defines the sample count to set
  29247. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29248. */
  29249. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29250. /** @hidden */
  29251. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29252. /** @hidden */
  29253. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29254. /** @hidden */
  29255. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29256. /** @hidden */
  29257. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29258. /**
  29259. * Creates a new render target cube texture
  29260. * @param size defines the size of the texture
  29261. * @param options defines the options used to create the texture
  29262. * @returns a new render target cube texture stored in an InternalTexture
  29263. */
  29264. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29265. /**
  29266. * Creates a cube texture
  29267. * @param rootUrl defines the url where the files to load is located
  29268. * @param scene defines the current scene
  29269. * @param files defines the list of files to load (1 per face)
  29270. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29271. * @param onLoad defines an optional callback raised when the texture is loaded
  29272. * @param onError defines an optional callback raised if there is an issue to load the texture
  29273. * @param format defines the format of the data
  29274. * @param forcedExtension defines the extension to use to pick the right loader
  29275. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29276. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29277. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29278. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29279. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29280. * @returns the cube texture as an InternalTexture
  29281. */
  29282. 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;
  29283. /**
  29284. * @hidden
  29285. */
  29286. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29287. /**
  29288. * Update a raw cube texture
  29289. * @param texture defines the texture to udpdate
  29290. * @param data defines the data to store
  29291. * @param format defines the data format
  29292. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29293. * @param invertY defines if data must be stored with Y axis inverted
  29294. * @param compression defines the compression used (null by default)
  29295. * @param level defines which level of the texture to update
  29296. */
  29297. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29298. /**
  29299. * Creates a new raw cube texture
  29300. * @param data defines the array of data to use to create each face
  29301. * @param size defines the size of the textures
  29302. * @param format defines the format of the data
  29303. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29304. * @param generateMipMaps defines if the engine should generate the mip levels
  29305. * @param invertY defines if data must be stored with Y axis inverted
  29306. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29307. * @param compression defines the compression used (null by default)
  29308. * @returns the cube texture as an InternalTexture
  29309. */
  29310. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29311. /**
  29312. * Creates a new raw cube texture from a specified url
  29313. * @param url defines the url where the data is located
  29314. * @param scene defines the current scene
  29315. * @param size defines the size of the textures
  29316. * @param format defines the format of the data
  29317. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29318. * @param noMipmap defines if the engine should avoid generating the mip levels
  29319. * @param callback defines a callback used to extract texture data from loaded data
  29320. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29321. * @param onLoad defines a callback called when texture is loaded
  29322. * @param onError defines a callback called if there is an error
  29323. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29324. * @param invertY defines if data must be stored with Y axis inverted
  29325. * @returns the cube texture as an InternalTexture
  29326. */
  29327. 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;
  29328. /**
  29329. * Update a raw 3D texture
  29330. * @param texture defines the texture to update
  29331. * @param data defines the data to store
  29332. * @param format defines the data format
  29333. * @param invertY defines if data must be stored with Y axis inverted
  29334. * @param compression defines the used compression (can be null)
  29335. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29336. */
  29337. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29338. /**
  29339. * Creates a new raw 3D texture
  29340. * @param data defines the data used to create the texture
  29341. * @param width defines the width of the texture
  29342. * @param height defines the height of the texture
  29343. * @param depth defines the depth of the texture
  29344. * @param format defines the format of the texture
  29345. * @param generateMipMaps defines if the engine must generate mip levels
  29346. * @param invertY defines if data must be stored with Y axis inverted
  29347. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29348. * @param compression defines the compressed used (can be null)
  29349. * @param textureType defines the compressed used (can be null)
  29350. * @returns a new raw 3D texture (stored in an InternalTexture)
  29351. */
  29352. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29353. private _prepareWebGLTextureContinuation;
  29354. private _prepareWebGLTexture;
  29355. private _convertRGBtoRGBATextureData;
  29356. /** @hidden */
  29357. _releaseFramebufferObjects(texture: InternalTexture): void;
  29358. /** @hidden */
  29359. _releaseTexture(texture: InternalTexture): void;
  29360. private setProgram;
  29361. private _boundUniforms;
  29362. /**
  29363. * Binds an effect to the webGL context
  29364. * @param effect defines the effect to bind
  29365. */
  29366. bindSamplers(effect: Effect): void;
  29367. private _moveBoundTextureOnTop;
  29368. private _getCorrectTextureChannel;
  29369. private _linkTrackers;
  29370. private _removeDesignatedSlot;
  29371. private _activateCurrentTexture;
  29372. /** @hidden */
  29373. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29374. /** @hidden */
  29375. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29376. /**
  29377. * Sets a texture to the webGL context from a postprocess
  29378. * @param channel defines the channel to use
  29379. * @param postProcess defines the source postprocess
  29380. */
  29381. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29382. /**
  29383. * Binds the output of the passed in post process to the texture channel specified
  29384. * @param channel The channel the texture should be bound to
  29385. * @param postProcess The post process which's output should be bound
  29386. */
  29387. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29388. /**
  29389. * Unbind all textures from the webGL context
  29390. */
  29391. unbindAllTextures(): void;
  29392. /**
  29393. * Sets a texture to the according uniform.
  29394. * @param channel The texture channel
  29395. * @param uniform The uniform to set
  29396. * @param texture The texture to apply
  29397. */
  29398. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29399. /**
  29400. * Sets a depth stencil texture from a render target to the according uniform.
  29401. * @param channel The texture channel
  29402. * @param uniform The uniform to set
  29403. * @param texture The render target texture containing the depth stencil texture to apply
  29404. */
  29405. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29406. private _bindSamplerUniformToChannel;
  29407. private _getTextureWrapMode;
  29408. private _setTexture;
  29409. /**
  29410. * Sets an array of texture to the webGL context
  29411. * @param channel defines the channel where the texture array must be set
  29412. * @param uniform defines the associated uniform location
  29413. * @param textures defines the array of textures to bind
  29414. */
  29415. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29416. /** @hidden */
  29417. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29418. private _setTextureParameterFloat;
  29419. private _setTextureParameterInteger;
  29420. /**
  29421. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29422. * @param x defines the x coordinate of the rectangle where pixels must be read
  29423. * @param y defines the y coordinate of the rectangle where pixels must be read
  29424. * @param width defines the width of the rectangle where pixels must be read
  29425. * @param height defines the height of the rectangle where pixels must be read
  29426. * @returns a Uint8Array containing RGBA colors
  29427. */
  29428. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29429. /**
  29430. * Add an externaly attached data from its key.
  29431. * This method call will fail and return false, if such key already exists.
  29432. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29433. * @param key the unique key that identifies the data
  29434. * @param data the data object to associate to the key for this Engine instance
  29435. * @return true if no such key were already present and the data was added successfully, false otherwise
  29436. */
  29437. addExternalData<T>(key: string, data: T): boolean;
  29438. /**
  29439. * Get an externaly attached data from its key
  29440. * @param key the unique key that identifies the data
  29441. * @return the associated data, if present (can be null), or undefined if not present
  29442. */
  29443. getExternalData<T>(key: string): T;
  29444. /**
  29445. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29446. * @param key the unique key that identifies the data
  29447. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29448. * @return the associated data, can be null if the factory returned null.
  29449. */
  29450. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29451. /**
  29452. * Remove an externaly attached data from the Engine instance
  29453. * @param key the unique key that identifies the data
  29454. * @return true if the data was successfully removed, false if it doesn't exist
  29455. */
  29456. removeExternalData(key: string): boolean;
  29457. /**
  29458. * Unbind all vertex attributes from the webGL context
  29459. */
  29460. unbindAllAttributes(): void;
  29461. /**
  29462. * 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
  29463. */
  29464. releaseEffects(): void;
  29465. /**
  29466. * Dispose and release all associated resources
  29467. */
  29468. dispose(): void;
  29469. /**
  29470. * Display the loading screen
  29471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29472. */
  29473. displayLoadingUI(): void;
  29474. /**
  29475. * Hide the loading screen
  29476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29477. */
  29478. hideLoadingUI(): void;
  29479. /**
  29480. * Gets the current loading screen object
  29481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29482. */
  29483. /**
  29484. * Sets the current loading screen object
  29485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29486. */
  29487. loadingScreen: ILoadingScreen;
  29488. /**
  29489. * Sets the current loading screen text
  29490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29491. */
  29492. loadingUIText: string;
  29493. /**
  29494. * Sets the current loading screen background color
  29495. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29496. */
  29497. loadingUIBackgroundColor: string;
  29498. /**
  29499. * Attach a new callback raised when context lost event is fired
  29500. * @param callback defines the callback to call
  29501. */
  29502. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29503. /**
  29504. * Attach a new callback raised when context restored event is fired
  29505. * @param callback defines the callback to call
  29506. */
  29507. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29508. /**
  29509. * Gets the source code of the vertex shader associated with a specific webGL program
  29510. * @param program defines the program to use
  29511. * @returns a string containing the source code of the vertex shader associated with the program
  29512. */
  29513. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29514. /**
  29515. * Gets the source code of the fragment shader associated with a specific webGL program
  29516. * @param program defines the program to use
  29517. * @returns a string containing the source code of the fragment shader associated with the program
  29518. */
  29519. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29520. /**
  29521. * Get the current error code of the webGL context
  29522. * @returns the error code
  29523. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29524. */
  29525. getError(): number;
  29526. /**
  29527. * Gets the current framerate
  29528. * @returns a number representing the framerate
  29529. */
  29530. getFps(): number;
  29531. /**
  29532. * Gets the time spent between current and previous frame
  29533. * @returns a number representing the delta time in ms
  29534. */
  29535. getDeltaTime(): number;
  29536. private _measureFps;
  29537. /** @hidden */
  29538. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29539. private _canRenderToFloatFramebuffer;
  29540. private _canRenderToHalfFloatFramebuffer;
  29541. private _canRenderToFramebuffer;
  29542. /** @hidden */
  29543. _getWebGLTextureType(type: number): number;
  29544. private _getInternalFormat;
  29545. /** @hidden */
  29546. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29547. /** @hidden */
  29548. _getRGBAMultiSampleBufferFormat(type: number): number;
  29549. /** @hidden */
  29550. _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;
  29551. /** @hidden */
  29552. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29553. private _partialLoadFile;
  29554. private _cascadeLoadFiles;
  29555. /**
  29556. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29557. * @returns true if the engine can be created
  29558. * @ignorenaming
  29559. */
  29560. static isSupported(): boolean;
  29561. }
  29562. }
  29563. declare module "babylonjs/Materials/effect" {
  29564. import { Observable } from "babylonjs/Misc/observable";
  29565. import { Nullable } from "babylonjs/types";
  29566. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29567. import { Engine } from "babylonjs/Engines/engine";
  29568. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29570. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29573. /**
  29574. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29575. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29576. */
  29577. export class EffectFallbacks {
  29578. private _defines;
  29579. private _currentRank;
  29580. private _maxRank;
  29581. private _mesh;
  29582. /**
  29583. * Removes the fallback from the bound mesh.
  29584. */
  29585. unBindMesh(): void;
  29586. /**
  29587. * Adds a fallback on the specified property.
  29588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29589. * @param define The name of the define in the shader
  29590. */
  29591. addFallback(rank: number, define: string): void;
  29592. /**
  29593. * Sets the mesh to use CPU skinning when needing to fallback.
  29594. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29595. * @param mesh The mesh to use the fallbacks.
  29596. */
  29597. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29598. /**
  29599. * Checks to see if more fallbacks are still availible.
  29600. */
  29601. readonly isMoreFallbacks: boolean;
  29602. /**
  29603. * Removes the defines that shoould be removed when falling back.
  29604. * @param currentDefines defines the current define statements for the shader.
  29605. * @param effect defines the current effect we try to compile
  29606. * @returns The resulting defines with defines of the current rank removed.
  29607. */
  29608. reduce(currentDefines: string, effect: Effect): string;
  29609. }
  29610. /**
  29611. * Options to be used when creating an effect.
  29612. */
  29613. export class EffectCreationOptions {
  29614. /**
  29615. * Atrributes that will be used in the shader.
  29616. */
  29617. attributes: string[];
  29618. /**
  29619. * Uniform varible names that will be set in the shader.
  29620. */
  29621. uniformsNames: string[];
  29622. /**
  29623. * Uniform buffer varible names that will be set in the shader.
  29624. */
  29625. uniformBuffersNames: string[];
  29626. /**
  29627. * Sampler texture variable names that will be set in the shader.
  29628. */
  29629. samplers: string[];
  29630. /**
  29631. * Define statements that will be set in the shader.
  29632. */
  29633. defines: any;
  29634. /**
  29635. * Possible fallbacks for this effect to improve performance when needed.
  29636. */
  29637. fallbacks: Nullable<EffectFallbacks>;
  29638. /**
  29639. * Callback that will be called when the shader is compiled.
  29640. */
  29641. onCompiled: Nullable<(effect: Effect) => void>;
  29642. /**
  29643. * Callback that will be called if an error occurs during shader compilation.
  29644. */
  29645. onError: Nullable<(effect: Effect, errors: string) => void>;
  29646. /**
  29647. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29648. */
  29649. indexParameters: any;
  29650. /**
  29651. * Max number of lights that can be used in the shader.
  29652. */
  29653. maxSimultaneousLights: number;
  29654. /**
  29655. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29656. */
  29657. transformFeedbackVaryings: Nullable<string[]>;
  29658. }
  29659. /**
  29660. * Effect containing vertex and fragment shader that can be executed on an object.
  29661. */
  29662. export class Effect {
  29663. /**
  29664. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29665. */
  29666. static ShadersRepository: string;
  29667. /**
  29668. * Name of the effect.
  29669. */
  29670. name: any;
  29671. /**
  29672. * String container all the define statements that should be set on the shader.
  29673. */
  29674. defines: string;
  29675. /**
  29676. * Callback that will be called when the shader is compiled.
  29677. */
  29678. onCompiled: Nullable<(effect: Effect) => void>;
  29679. /**
  29680. * Callback that will be called if an error occurs during shader compilation.
  29681. */
  29682. onError: Nullable<(effect: Effect, errors: string) => void>;
  29683. /**
  29684. * Callback that will be called when effect is bound.
  29685. */
  29686. onBind: Nullable<(effect: Effect) => void>;
  29687. /**
  29688. * Unique ID of the effect.
  29689. */
  29690. uniqueId: number;
  29691. /**
  29692. * Observable that will be called when the shader is compiled.
  29693. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29694. */
  29695. onCompileObservable: Observable<Effect>;
  29696. /**
  29697. * Observable that will be called if an error occurs during shader compilation.
  29698. */
  29699. onErrorObservable: Observable<Effect>;
  29700. /** @hidden */
  29701. _onBindObservable: Nullable<Observable<Effect>>;
  29702. /**
  29703. * Observable that will be called when effect is bound.
  29704. */
  29705. readonly onBindObservable: Observable<Effect>;
  29706. /** @hidden */
  29707. _bonesComputationForcedToCPU: boolean;
  29708. private static _uniqueIdSeed;
  29709. private _engine;
  29710. private _uniformBuffersNames;
  29711. private _uniformsNames;
  29712. private _samplers;
  29713. private _isReady;
  29714. private _compilationError;
  29715. private _attributesNames;
  29716. private _attributes;
  29717. private _uniforms;
  29718. /**
  29719. * Key for the effect.
  29720. * @hidden
  29721. */
  29722. _key: string;
  29723. private _indexParameters;
  29724. private _fallbacks;
  29725. private _vertexSourceCode;
  29726. private _fragmentSourceCode;
  29727. private _vertexSourceCodeOverride;
  29728. private _fragmentSourceCodeOverride;
  29729. private _transformFeedbackVaryings;
  29730. /**
  29731. * Compiled shader to webGL program.
  29732. * @hidden
  29733. */
  29734. _program: WebGLProgram;
  29735. private _valueCache;
  29736. private static _baseCache;
  29737. /**
  29738. * Instantiates an effect.
  29739. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29740. * @param baseName Name of the effect.
  29741. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29742. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29743. * @param samplers List of sampler variables that will be passed to the shader.
  29744. * @param engine Engine to be used to render the effect
  29745. * @param defines Define statements to be added to the shader.
  29746. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29747. * @param onCompiled Callback that will be called when the shader is compiled.
  29748. * @param onError Callback that will be called if an error occurs during shader compilation.
  29749. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29750. */
  29751. 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);
  29752. /**
  29753. * Unique key for this effect
  29754. */
  29755. readonly key: string;
  29756. /**
  29757. * If the effect has been compiled and prepared.
  29758. * @returns if the effect is compiled and prepared.
  29759. */
  29760. isReady(): boolean;
  29761. /**
  29762. * The engine the effect was initialized with.
  29763. * @returns the engine.
  29764. */
  29765. getEngine(): Engine;
  29766. /**
  29767. * The compiled webGL program for the effect
  29768. * @returns the webGL program.
  29769. */
  29770. getProgram(): WebGLProgram;
  29771. /**
  29772. * The set of names of attribute variables for the shader.
  29773. * @returns An array of attribute names.
  29774. */
  29775. getAttributesNames(): string[];
  29776. /**
  29777. * Returns the attribute at the given index.
  29778. * @param index The index of the attribute.
  29779. * @returns The location of the attribute.
  29780. */
  29781. getAttributeLocation(index: number): number;
  29782. /**
  29783. * Returns the attribute based on the name of the variable.
  29784. * @param name of the attribute to look up.
  29785. * @returns the attribute location.
  29786. */
  29787. getAttributeLocationByName(name: string): number;
  29788. /**
  29789. * The number of attributes.
  29790. * @returns the numnber of attributes.
  29791. */
  29792. getAttributesCount(): number;
  29793. /**
  29794. * Gets the index of a uniform variable.
  29795. * @param uniformName of the uniform to look up.
  29796. * @returns the index.
  29797. */
  29798. getUniformIndex(uniformName: string): number;
  29799. /**
  29800. * Returns the attribute based on the name of the variable.
  29801. * @param uniformName of the uniform to look up.
  29802. * @returns the location of the uniform.
  29803. */
  29804. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29805. /**
  29806. * Returns an array of sampler variable names
  29807. * @returns The array of sampler variable neames.
  29808. */
  29809. getSamplers(): string[];
  29810. /**
  29811. * The error from the last compilation.
  29812. * @returns the error string.
  29813. */
  29814. getCompilationError(): string;
  29815. /**
  29816. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29817. * @param func The callback to be used.
  29818. */
  29819. executeWhenCompiled(func: (effect: Effect) => void): void;
  29820. private _checkIsReady;
  29821. /** @hidden */
  29822. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29823. /** @hidden */
  29824. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29825. /** @hidden */
  29826. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29827. private _processShaderConversion;
  29828. private _processIncludes;
  29829. private _processPrecision;
  29830. /**
  29831. * Recompiles the webGL program
  29832. * @param vertexSourceCode The source code for the vertex shader.
  29833. * @param fragmentSourceCode The source code for the fragment shader.
  29834. * @param onCompiled Callback called when completed.
  29835. * @param onError Callback called on error.
  29836. * @hidden
  29837. */
  29838. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29839. /**
  29840. * Gets the uniform locations of the the specified variable names
  29841. * @param names THe names of the variables to lookup.
  29842. * @returns Array of locations in the same order as variable names.
  29843. */
  29844. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29845. /**
  29846. * Prepares the effect
  29847. * @hidden
  29848. */
  29849. _prepareEffect(): void;
  29850. /**
  29851. * Checks if the effect is supported. (Must be called after compilation)
  29852. */
  29853. readonly isSupported: boolean;
  29854. /**
  29855. * Binds a texture to the engine to be used as output of the shader.
  29856. * @param channel Name of the output variable.
  29857. * @param texture Texture to bind.
  29858. * @hidden
  29859. */
  29860. _bindTexture(channel: string, texture: InternalTexture): void;
  29861. /**
  29862. * Sets a texture on the engine to be used in the shader.
  29863. * @param channel Name of the sampler variable.
  29864. * @param texture Texture to set.
  29865. */
  29866. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29867. /**
  29868. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29869. * @param channel Name of the sampler variable.
  29870. * @param texture Texture to set.
  29871. */
  29872. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29873. /**
  29874. * Sets an array of textures on the engine to be used in the shader.
  29875. * @param channel Name of the variable.
  29876. * @param textures Textures to set.
  29877. */
  29878. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29879. /**
  29880. * 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)
  29881. * @param channel Name of the sampler variable.
  29882. * @param postProcess Post process to get the input texture from.
  29883. */
  29884. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29885. /**
  29886. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29887. * 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)
  29888. * @param channel Name of the sampler variable.
  29889. * @param postProcess Post process to get the output texture from.
  29890. */
  29891. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29892. /** @hidden */
  29893. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29894. /** @hidden */
  29895. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29896. /** @hidden */
  29897. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29898. /** @hidden */
  29899. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29900. /**
  29901. * Binds a buffer to a uniform.
  29902. * @param buffer Buffer to bind.
  29903. * @param name Name of the uniform variable to bind to.
  29904. */
  29905. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29906. /**
  29907. * Binds block to a uniform.
  29908. * @param blockName Name of the block to bind.
  29909. * @param index Index to bind.
  29910. */
  29911. bindUniformBlock(blockName: string, index: number): void;
  29912. /**
  29913. * Sets an interger value on a uniform variable.
  29914. * @param uniformName Name of the variable.
  29915. * @param value Value to be set.
  29916. * @returns this effect.
  29917. */
  29918. setInt(uniformName: string, value: number): Effect;
  29919. /**
  29920. * Sets an int array on a uniform variable.
  29921. * @param uniformName Name of the variable.
  29922. * @param array array to be set.
  29923. * @returns this effect.
  29924. */
  29925. setIntArray(uniformName: string, array: Int32Array): Effect;
  29926. /**
  29927. * 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)
  29928. * @param uniformName Name of the variable.
  29929. * @param array array to be set.
  29930. * @returns this effect.
  29931. */
  29932. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29933. /**
  29934. * 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)
  29935. * @param uniformName Name of the variable.
  29936. * @param array array to be set.
  29937. * @returns this effect.
  29938. */
  29939. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29940. /**
  29941. * 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)
  29942. * @param uniformName Name of the variable.
  29943. * @param array array to be set.
  29944. * @returns this effect.
  29945. */
  29946. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29947. /**
  29948. * Sets an float array on a uniform variable.
  29949. * @param uniformName Name of the variable.
  29950. * @param array array to be set.
  29951. * @returns this effect.
  29952. */
  29953. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29954. /**
  29955. * 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)
  29956. * @param uniformName Name of the variable.
  29957. * @param array array to be set.
  29958. * @returns this effect.
  29959. */
  29960. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29961. /**
  29962. * 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)
  29963. * @param uniformName Name of the variable.
  29964. * @param array array to be set.
  29965. * @returns this effect.
  29966. */
  29967. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29968. /**
  29969. * 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)
  29970. * @param uniformName Name of the variable.
  29971. * @param array array to be set.
  29972. * @returns this effect.
  29973. */
  29974. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29975. /**
  29976. * Sets an array on a uniform variable.
  29977. * @param uniformName Name of the variable.
  29978. * @param array array to be set.
  29979. * @returns this effect.
  29980. */
  29981. setArray(uniformName: string, array: number[]): Effect;
  29982. /**
  29983. * 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)
  29984. * @param uniformName Name of the variable.
  29985. * @param array array to be set.
  29986. * @returns this effect.
  29987. */
  29988. setArray2(uniformName: string, array: number[]): Effect;
  29989. /**
  29990. * 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)
  29991. * @param uniformName Name of the variable.
  29992. * @param array array to be set.
  29993. * @returns this effect.
  29994. */
  29995. setArray3(uniformName: string, array: number[]): Effect;
  29996. /**
  29997. * 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)
  29998. * @param uniformName Name of the variable.
  29999. * @param array array to be set.
  30000. * @returns this effect.
  30001. */
  30002. setArray4(uniformName: string, array: number[]): Effect;
  30003. /**
  30004. * Sets matrices on a uniform variable.
  30005. * @param uniformName Name of the variable.
  30006. * @param matrices matrices to be set.
  30007. * @returns this effect.
  30008. */
  30009. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30010. /**
  30011. * Sets matrix on a uniform variable.
  30012. * @param uniformName Name of the variable.
  30013. * @param matrix matrix to be set.
  30014. * @returns this effect.
  30015. */
  30016. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30017. /**
  30018. * 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)
  30019. * @param uniformName Name of the variable.
  30020. * @param matrix matrix to be set.
  30021. * @returns this effect.
  30022. */
  30023. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30024. /**
  30025. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30026. * @param uniformName Name of the variable.
  30027. * @param matrix matrix to be set.
  30028. * @returns this effect.
  30029. */
  30030. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30031. /**
  30032. * Sets a float on a uniform variable.
  30033. * @param uniformName Name of the variable.
  30034. * @param value value to be set.
  30035. * @returns this effect.
  30036. */
  30037. setFloat(uniformName: string, value: number): Effect;
  30038. /**
  30039. * Sets a boolean on a uniform variable.
  30040. * @param uniformName Name of the variable.
  30041. * @param bool value to be set.
  30042. * @returns this effect.
  30043. */
  30044. setBool(uniformName: string, bool: boolean): Effect;
  30045. /**
  30046. * Sets a Vector2 on a uniform variable.
  30047. * @param uniformName Name of the variable.
  30048. * @param vector2 vector2 to be set.
  30049. * @returns this effect.
  30050. */
  30051. setVector2(uniformName: string, vector2: Vector2): Effect;
  30052. /**
  30053. * Sets a float2 on a uniform variable.
  30054. * @param uniformName Name of the variable.
  30055. * @param x First float in float2.
  30056. * @param y Second float in float2.
  30057. * @returns this effect.
  30058. */
  30059. setFloat2(uniformName: string, x: number, y: number): Effect;
  30060. /**
  30061. * Sets a Vector3 on a uniform variable.
  30062. * @param uniformName Name of the variable.
  30063. * @param vector3 Value to be set.
  30064. * @returns this effect.
  30065. */
  30066. setVector3(uniformName: string, vector3: Vector3): Effect;
  30067. /**
  30068. * Sets a float3 on a uniform variable.
  30069. * @param uniformName Name of the variable.
  30070. * @param x First float in float3.
  30071. * @param y Second float in float3.
  30072. * @param z Third float in float3.
  30073. * @returns this effect.
  30074. */
  30075. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30076. /**
  30077. * Sets a Vector4 on a uniform variable.
  30078. * @param uniformName Name of the variable.
  30079. * @param vector4 Value to be set.
  30080. * @returns this effect.
  30081. */
  30082. setVector4(uniformName: string, vector4: Vector4): Effect;
  30083. /**
  30084. * Sets a float4 on a uniform variable.
  30085. * @param uniformName Name of the variable.
  30086. * @param x First float in float4.
  30087. * @param y Second float in float4.
  30088. * @param z Third float in float4.
  30089. * @param w Fourth float in float4.
  30090. * @returns this effect.
  30091. */
  30092. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30093. /**
  30094. * Sets a Color3 on a uniform variable.
  30095. * @param uniformName Name of the variable.
  30096. * @param color3 Value to be set.
  30097. * @returns this effect.
  30098. */
  30099. setColor3(uniformName: string, color3: Color3): Effect;
  30100. /**
  30101. * Sets a Color4 on a uniform variable.
  30102. * @param uniformName Name of the variable.
  30103. * @param color3 Value to be set.
  30104. * @param alpha Alpha value to be set.
  30105. * @returns this effect.
  30106. */
  30107. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30108. /**
  30109. * Sets a Color4 on a uniform variable
  30110. * @param uniformName defines the name of the variable
  30111. * @param color4 defines the value to be set
  30112. * @returns this effect.
  30113. */
  30114. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30115. /**
  30116. * This function will add a new shader to the shader store
  30117. * @param name the name of the shader
  30118. * @param pixelShader optional pixel shader content
  30119. * @param vertexShader optional vertex shader content
  30120. */
  30121. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30122. /**
  30123. * Store of each shader (The can be looked up using effect.key)
  30124. */
  30125. static ShadersStore: {
  30126. [key: string]: string;
  30127. };
  30128. /**
  30129. * Store of each included file for a shader (The can be looked up using effect.key)
  30130. */
  30131. static IncludesShadersStore: {
  30132. [key: string]: string;
  30133. };
  30134. /**
  30135. * Resets the cache of effects.
  30136. */
  30137. static ResetCache(): void;
  30138. }
  30139. }
  30140. declare module "babylonjs/Materials/colorCurves" {
  30141. import { Effect } from "babylonjs/Materials/effect";
  30142. /**
  30143. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30144. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30145. * 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;
  30146. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30147. */
  30148. export class ColorCurves {
  30149. private _dirty;
  30150. private _tempColor;
  30151. private _globalCurve;
  30152. private _highlightsCurve;
  30153. private _midtonesCurve;
  30154. private _shadowsCurve;
  30155. private _positiveCurve;
  30156. private _negativeCurve;
  30157. private _globalHue;
  30158. private _globalDensity;
  30159. private _globalSaturation;
  30160. private _globalExposure;
  30161. /**
  30162. * Gets the global Hue value.
  30163. * 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).
  30164. */
  30165. /**
  30166. * Sets the global Hue value.
  30167. * 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).
  30168. */
  30169. globalHue: number;
  30170. /**
  30171. * Gets the global Density value.
  30172. * 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.
  30173. * Values less than zero provide a filter of opposite hue.
  30174. */
  30175. /**
  30176. * Sets the global Density value.
  30177. * 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.
  30178. * Values less than zero provide a filter of opposite hue.
  30179. */
  30180. globalDensity: number;
  30181. /**
  30182. * Gets the global Saturation value.
  30183. * 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.
  30184. */
  30185. /**
  30186. * Sets the global Saturation value.
  30187. * 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.
  30188. */
  30189. globalSaturation: number;
  30190. /**
  30191. * Gets the global Exposure value.
  30192. * 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.
  30193. */
  30194. /**
  30195. * Sets the global Exposure value.
  30196. * 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.
  30197. */
  30198. globalExposure: number;
  30199. private _highlightsHue;
  30200. private _highlightsDensity;
  30201. private _highlightsSaturation;
  30202. private _highlightsExposure;
  30203. /**
  30204. * Gets the highlights Hue value.
  30205. * 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).
  30206. */
  30207. /**
  30208. * Sets the highlights Hue value.
  30209. * 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).
  30210. */
  30211. highlightsHue: number;
  30212. /**
  30213. * Gets the highlights Density value.
  30214. * 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.
  30215. * Values less than zero provide a filter of opposite hue.
  30216. */
  30217. /**
  30218. * Sets the highlights Density value.
  30219. * 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.
  30220. * Values less than zero provide a filter of opposite hue.
  30221. */
  30222. highlightsDensity: number;
  30223. /**
  30224. * Gets the highlights Saturation value.
  30225. * 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.
  30226. */
  30227. /**
  30228. * Sets the highlights Saturation value.
  30229. * 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.
  30230. */
  30231. highlightsSaturation: number;
  30232. /**
  30233. * Gets the highlights Exposure value.
  30234. * 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.
  30235. */
  30236. /**
  30237. * Sets the highlights Exposure value.
  30238. * 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.
  30239. */
  30240. highlightsExposure: number;
  30241. private _midtonesHue;
  30242. private _midtonesDensity;
  30243. private _midtonesSaturation;
  30244. private _midtonesExposure;
  30245. /**
  30246. * Gets the midtones Hue value.
  30247. * 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).
  30248. */
  30249. /**
  30250. * Sets the midtones Hue value.
  30251. * 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).
  30252. */
  30253. midtonesHue: number;
  30254. /**
  30255. * Gets the midtones Density value.
  30256. * 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.
  30257. * Values less than zero provide a filter of opposite hue.
  30258. */
  30259. /**
  30260. * Sets the midtones Density value.
  30261. * 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.
  30262. * Values less than zero provide a filter of opposite hue.
  30263. */
  30264. midtonesDensity: number;
  30265. /**
  30266. * Gets the midtones Saturation value.
  30267. * 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.
  30268. */
  30269. /**
  30270. * Sets the midtones Saturation value.
  30271. * 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.
  30272. */
  30273. midtonesSaturation: number;
  30274. /**
  30275. * Gets the midtones Exposure value.
  30276. * 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.
  30277. */
  30278. /**
  30279. * Sets the midtones Exposure value.
  30280. * 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.
  30281. */
  30282. midtonesExposure: number;
  30283. private _shadowsHue;
  30284. private _shadowsDensity;
  30285. private _shadowsSaturation;
  30286. private _shadowsExposure;
  30287. /**
  30288. * Gets the shadows Hue value.
  30289. * 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).
  30290. */
  30291. /**
  30292. * Sets the shadows Hue value.
  30293. * 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).
  30294. */
  30295. shadowsHue: number;
  30296. /**
  30297. * Gets the shadows Density value.
  30298. * 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.
  30299. * Values less than zero provide a filter of opposite hue.
  30300. */
  30301. /**
  30302. * Sets the shadows Density value.
  30303. * 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.
  30304. * Values less than zero provide a filter of opposite hue.
  30305. */
  30306. shadowsDensity: number;
  30307. /**
  30308. * Gets the shadows Saturation value.
  30309. * 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.
  30310. */
  30311. /**
  30312. * Sets the shadows Saturation value.
  30313. * 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.
  30314. */
  30315. shadowsSaturation: number;
  30316. /**
  30317. * Gets the shadows Exposure value.
  30318. * 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.
  30319. */
  30320. /**
  30321. * Sets the shadows Exposure value.
  30322. * 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.
  30323. */
  30324. shadowsExposure: number;
  30325. /**
  30326. * Returns the class name
  30327. * @returns The class name
  30328. */
  30329. getClassName(): string;
  30330. /**
  30331. * Binds the color curves to the shader.
  30332. * @param colorCurves The color curve to bind
  30333. * @param effect The effect to bind to
  30334. * @param positiveUniform The positive uniform shader parameter
  30335. * @param neutralUniform The neutral uniform shader parameter
  30336. * @param negativeUniform The negative uniform shader parameter
  30337. */
  30338. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30339. /**
  30340. * Prepare the list of uniforms associated with the ColorCurves effects.
  30341. * @param uniformsList The list of uniforms used in the effect
  30342. */
  30343. static PrepareUniforms(uniformsList: string[]): void;
  30344. /**
  30345. * Returns color grading data based on a hue, density, saturation and exposure value.
  30346. * @param filterHue The hue of the color filter.
  30347. * @param filterDensity The density of the color filter.
  30348. * @param saturation The saturation.
  30349. * @param exposure The exposure.
  30350. * @param result The result data container.
  30351. */
  30352. private getColorGradingDataToRef;
  30353. /**
  30354. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30355. * @param value The input slider value in range [-100,100].
  30356. * @returns Adjusted value.
  30357. */
  30358. private static applyColorGradingSliderNonlinear;
  30359. /**
  30360. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30361. * @param hue The hue (H) input.
  30362. * @param saturation The saturation (S) input.
  30363. * @param brightness The brightness (B) input.
  30364. * @result An RGBA color represented as Vector4.
  30365. */
  30366. private static fromHSBToRef;
  30367. /**
  30368. * Returns a value clamped between min and max
  30369. * @param value The value to clamp
  30370. * @param min The minimum of value
  30371. * @param max The maximum of value
  30372. * @returns The clamped value.
  30373. */
  30374. private static clamp;
  30375. /**
  30376. * Clones the current color curve instance.
  30377. * @return The cloned curves
  30378. */
  30379. clone(): ColorCurves;
  30380. /**
  30381. * Serializes the current color curve instance to a json representation.
  30382. * @return a JSON representation
  30383. */
  30384. serialize(): any;
  30385. /**
  30386. * Parses the color curve from a json representation.
  30387. * @param source the JSON source to parse
  30388. * @return The parsed curves
  30389. */
  30390. static Parse(source: any): ColorCurves;
  30391. }
  30392. }
  30393. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30394. import { Observable } from "babylonjs/Misc/observable";
  30395. import { Nullable } from "babylonjs/types";
  30396. import { Color4 } from "babylonjs/Maths/math";
  30397. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30398. import { Effect } from "babylonjs/Materials/effect";
  30399. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30400. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30401. /**
  30402. * Interface to follow in your material defines to integrate easily the
  30403. * Image proccessing functions.
  30404. * @hidden
  30405. */
  30406. export interface IImageProcessingConfigurationDefines {
  30407. IMAGEPROCESSING: boolean;
  30408. VIGNETTE: boolean;
  30409. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30410. VIGNETTEBLENDMODEOPAQUE: boolean;
  30411. TONEMAPPING: boolean;
  30412. TONEMAPPING_ACES: boolean;
  30413. CONTRAST: boolean;
  30414. EXPOSURE: boolean;
  30415. COLORCURVES: boolean;
  30416. COLORGRADING: boolean;
  30417. COLORGRADING3D: boolean;
  30418. SAMPLER3DGREENDEPTH: boolean;
  30419. SAMPLER3DBGRMAP: boolean;
  30420. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30421. }
  30422. /**
  30423. * @hidden
  30424. */
  30425. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30426. IMAGEPROCESSING: boolean;
  30427. VIGNETTE: boolean;
  30428. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30429. VIGNETTEBLENDMODEOPAQUE: boolean;
  30430. TONEMAPPING: boolean;
  30431. TONEMAPPING_ACES: boolean;
  30432. CONTRAST: boolean;
  30433. COLORCURVES: boolean;
  30434. COLORGRADING: boolean;
  30435. COLORGRADING3D: boolean;
  30436. SAMPLER3DGREENDEPTH: boolean;
  30437. SAMPLER3DBGRMAP: boolean;
  30438. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30439. EXPOSURE: boolean;
  30440. constructor();
  30441. }
  30442. /**
  30443. * This groups together the common properties used for image processing either in direct forward pass
  30444. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30445. * or not.
  30446. */
  30447. export class ImageProcessingConfiguration {
  30448. /**
  30449. * Default tone mapping applied in BabylonJS.
  30450. */
  30451. static readonly TONEMAPPING_STANDARD: number;
  30452. /**
  30453. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30454. * to other engines rendering to increase portability.
  30455. */
  30456. static readonly TONEMAPPING_ACES: number;
  30457. /**
  30458. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30459. */
  30460. colorCurves: Nullable<ColorCurves>;
  30461. private _colorCurvesEnabled;
  30462. /**
  30463. * Gets wether the color curves effect is enabled.
  30464. */
  30465. /**
  30466. * Sets wether the color curves effect is enabled.
  30467. */
  30468. colorCurvesEnabled: boolean;
  30469. private _colorGradingTexture;
  30470. /**
  30471. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30472. */
  30473. /**
  30474. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30475. */
  30476. colorGradingTexture: Nullable<BaseTexture>;
  30477. private _colorGradingEnabled;
  30478. /**
  30479. * Gets wether the color grading effect is enabled.
  30480. */
  30481. /**
  30482. * Sets wether the color grading effect is enabled.
  30483. */
  30484. colorGradingEnabled: boolean;
  30485. private _colorGradingWithGreenDepth;
  30486. /**
  30487. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30488. */
  30489. /**
  30490. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30491. */
  30492. colorGradingWithGreenDepth: boolean;
  30493. private _colorGradingBGR;
  30494. /**
  30495. * Gets wether the color grading texture contains BGR values.
  30496. */
  30497. /**
  30498. * Sets wether the color grading texture contains BGR values.
  30499. */
  30500. colorGradingBGR: boolean;
  30501. /** @hidden */
  30502. _exposure: number;
  30503. /**
  30504. * Gets the Exposure used in the effect.
  30505. */
  30506. /**
  30507. * Sets the Exposure used in the effect.
  30508. */
  30509. exposure: number;
  30510. private _toneMappingEnabled;
  30511. /**
  30512. * Gets wether the tone mapping effect is enabled.
  30513. */
  30514. /**
  30515. * Sets wether the tone mapping effect is enabled.
  30516. */
  30517. toneMappingEnabled: boolean;
  30518. private _toneMappingType;
  30519. /**
  30520. * Gets the type of tone mapping effect.
  30521. */
  30522. /**
  30523. * Sets the type of tone mapping effect used in BabylonJS.
  30524. */
  30525. toneMappingType: number;
  30526. protected _contrast: number;
  30527. /**
  30528. * Gets the contrast used in the effect.
  30529. */
  30530. /**
  30531. * Sets the contrast used in the effect.
  30532. */
  30533. contrast: number;
  30534. /**
  30535. * Vignette stretch size.
  30536. */
  30537. vignetteStretch: number;
  30538. /**
  30539. * Vignette centre X Offset.
  30540. */
  30541. vignetteCentreX: number;
  30542. /**
  30543. * Vignette centre Y Offset.
  30544. */
  30545. vignetteCentreY: number;
  30546. /**
  30547. * Vignette weight or intensity of the vignette effect.
  30548. */
  30549. vignetteWeight: number;
  30550. /**
  30551. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30552. * if vignetteEnabled is set to true.
  30553. */
  30554. vignetteColor: Color4;
  30555. /**
  30556. * Camera field of view used by the Vignette effect.
  30557. */
  30558. vignetteCameraFov: number;
  30559. private _vignetteBlendMode;
  30560. /**
  30561. * Gets the vignette blend mode allowing different kind of effect.
  30562. */
  30563. /**
  30564. * Sets the vignette blend mode allowing different kind of effect.
  30565. */
  30566. vignetteBlendMode: number;
  30567. private _vignetteEnabled;
  30568. /**
  30569. * Gets wether the vignette effect is enabled.
  30570. */
  30571. /**
  30572. * Sets wether the vignette effect is enabled.
  30573. */
  30574. vignetteEnabled: boolean;
  30575. private _applyByPostProcess;
  30576. /**
  30577. * Gets wether the image processing is applied through a post process or not.
  30578. */
  30579. /**
  30580. * Sets wether the image processing is applied through a post process or not.
  30581. */
  30582. applyByPostProcess: boolean;
  30583. private _isEnabled;
  30584. /**
  30585. * Gets wether the image processing is enabled or not.
  30586. */
  30587. /**
  30588. * Sets wether the image processing is enabled or not.
  30589. */
  30590. isEnabled: boolean;
  30591. /**
  30592. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30593. */
  30594. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30595. /**
  30596. * Method called each time the image processing information changes requires to recompile the effect.
  30597. */
  30598. protected _updateParameters(): void;
  30599. /**
  30600. * Gets the current class name.
  30601. * @return "ImageProcessingConfiguration"
  30602. */
  30603. getClassName(): string;
  30604. /**
  30605. * Prepare the list of uniforms associated with the Image Processing effects.
  30606. * @param uniforms The list of uniforms used in the effect
  30607. * @param defines the list of defines currently in use
  30608. */
  30609. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30610. /**
  30611. * Prepare the list of samplers associated with the Image Processing effects.
  30612. * @param samplersList The list of uniforms used in the effect
  30613. * @param defines the list of defines currently in use
  30614. */
  30615. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30616. /**
  30617. * Prepare the list of defines associated to the shader.
  30618. * @param defines the list of defines to complete
  30619. * @param forPostProcess Define if we are currently in post process mode or not
  30620. */
  30621. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30622. /**
  30623. * Returns true if all the image processing information are ready.
  30624. * @returns True if ready, otherwise, false
  30625. */
  30626. isReady(): boolean;
  30627. /**
  30628. * Binds the image processing to the shader.
  30629. * @param effect The effect to bind to
  30630. * @param aspectRatio Define the current aspect ratio of the effect
  30631. */
  30632. bind(effect: Effect, aspectRatio?: number): void;
  30633. /**
  30634. * Clones the current image processing instance.
  30635. * @return The cloned image processing
  30636. */
  30637. clone(): ImageProcessingConfiguration;
  30638. /**
  30639. * Serializes the current image processing instance to a json representation.
  30640. * @return a JSON representation
  30641. */
  30642. serialize(): any;
  30643. /**
  30644. * Parses the image processing from a json representation.
  30645. * @param source the JSON source to parse
  30646. * @return The parsed image processing
  30647. */
  30648. static Parse(source: any): ImageProcessingConfiguration;
  30649. private static _VIGNETTEMODE_MULTIPLY;
  30650. private static _VIGNETTEMODE_OPAQUE;
  30651. /**
  30652. * Used to apply the vignette as a mix with the pixel color.
  30653. */
  30654. static readonly VIGNETTEMODE_MULTIPLY: number;
  30655. /**
  30656. * Used to apply the vignette as a replacement of the pixel color.
  30657. */
  30658. static readonly VIGNETTEMODE_OPAQUE: number;
  30659. }
  30660. }
  30661. declare module "babylonjs/Materials/fresnelParameters" {
  30662. import { Color3 } from "babylonjs/Maths/math";
  30663. /**
  30664. * This represents all the required information to add a fresnel effect on a material:
  30665. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30666. */
  30667. export class FresnelParameters {
  30668. private _isEnabled;
  30669. /**
  30670. * Define if the fresnel effect is enable or not.
  30671. */
  30672. isEnabled: boolean;
  30673. /**
  30674. * Define the color used on edges (grazing angle)
  30675. */
  30676. leftColor: Color3;
  30677. /**
  30678. * Define the color used on center
  30679. */
  30680. rightColor: Color3;
  30681. /**
  30682. * Define bias applied to computed fresnel term
  30683. */
  30684. bias: number;
  30685. /**
  30686. * Defined the power exponent applied to fresnel term
  30687. */
  30688. power: number;
  30689. /**
  30690. * Clones the current fresnel and its valuues
  30691. * @returns a clone fresnel configuration
  30692. */
  30693. clone(): FresnelParameters;
  30694. /**
  30695. * Serializes the current fresnel parameters to a JSON representation.
  30696. * @return the JSON serialization
  30697. */
  30698. serialize(): any;
  30699. /**
  30700. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30701. * @param parsedFresnelParameters Define the JSON representation
  30702. * @returns the parsed parameters
  30703. */
  30704. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30705. }
  30706. }
  30707. declare module "babylonjs/Misc/decorators" {
  30708. import { Nullable } from "babylonjs/types";
  30709. import { Scene } from "babylonjs/scene";
  30710. import { IAnimatable } from "babylonjs/Misc/tools";
  30711. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30712. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30713. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30714. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30715. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30716. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30717. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30718. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30719. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30720. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30721. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30722. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30723. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30724. /**
  30725. * Decorator used to define property that can be serialized as reference to a camera
  30726. * @param sourceName defines the name of the property to decorate
  30727. */
  30728. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30729. /**
  30730. * Class used to help serialization objects
  30731. */
  30732. export class SerializationHelper {
  30733. /** hidden */
  30734. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30735. /** hidden */
  30736. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30737. /** hidden */
  30738. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30739. /** hidden */
  30740. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30741. /**
  30742. * Appends the serialized animations from the source animations
  30743. * @param source Source containing the animations
  30744. * @param destination Target to store the animations
  30745. */
  30746. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30747. /**
  30748. * Static function used to serialized a specific entity
  30749. * @param entity defines the entity to serialize
  30750. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30751. * @returns a JSON compatible object representing the serialization of the entity
  30752. */
  30753. static Serialize<T>(entity: T, serializationObject?: any): any;
  30754. /**
  30755. * Creates a new entity from a serialization data object
  30756. * @param creationFunction defines a function used to instanciated the new entity
  30757. * @param source defines the source serialization data
  30758. * @param scene defines the hosting scene
  30759. * @param rootUrl defines the root url for resources
  30760. * @returns a new entity
  30761. */
  30762. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30763. /**
  30764. * Clones an object
  30765. * @param creationFunction defines the function used to instanciate the new object
  30766. * @param source defines the source object
  30767. * @returns the cloned object
  30768. */
  30769. static Clone<T>(creationFunction: () => T, source: T): T;
  30770. /**
  30771. * Instanciates a new object based on a source one (some data will be shared between both object)
  30772. * @param creationFunction defines the function used to instanciate the new object
  30773. * @param source defines the source object
  30774. * @returns the new object
  30775. */
  30776. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30777. }
  30778. }
  30779. declare module "babylonjs/Cameras/camera" {
  30780. import { SmartArray } from "babylonjs/Misc/smartArray";
  30781. import { Observable } from "babylonjs/Misc/observable";
  30782. import { Nullable } from "babylonjs/types";
  30783. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30784. import { Scene } from "babylonjs/scene";
  30785. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30786. import { Node } from "babylonjs/node";
  30787. import { Mesh } from "babylonjs/Meshes/mesh";
  30788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30789. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30792. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30793. import { Ray } from "babylonjs/Culling/ray";
  30794. /**
  30795. * This is the base class of all the camera used in the application.
  30796. * @see http://doc.babylonjs.com/features/cameras
  30797. */
  30798. export class Camera extends Node {
  30799. /** @hidden */
  30800. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30801. /**
  30802. * This is the default projection mode used by the cameras.
  30803. * It helps recreating a feeling of perspective and better appreciate depth.
  30804. * This is the best way to simulate real life cameras.
  30805. */
  30806. static readonly PERSPECTIVE_CAMERA: number;
  30807. /**
  30808. * This helps creating camera with an orthographic mode.
  30809. * 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.
  30810. */
  30811. static readonly ORTHOGRAPHIC_CAMERA: number;
  30812. /**
  30813. * This is the default FOV mode for perspective cameras.
  30814. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30815. */
  30816. static readonly FOVMODE_VERTICAL_FIXED: number;
  30817. /**
  30818. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30819. */
  30820. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30821. /**
  30822. * This specifies ther is no need for a camera rig.
  30823. * Basically only one eye is rendered corresponding to the camera.
  30824. */
  30825. static readonly RIG_MODE_NONE: number;
  30826. /**
  30827. * Simulates a camera Rig with one blue eye and one red eye.
  30828. * This can be use with 3d blue and red glasses.
  30829. */
  30830. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30831. /**
  30832. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30833. */
  30834. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30835. /**
  30836. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30837. */
  30838. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30839. /**
  30840. * Defines that both eyes of the camera will be rendered over under each other.
  30841. */
  30842. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30843. /**
  30844. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30845. */
  30846. static readonly RIG_MODE_VR: number;
  30847. /**
  30848. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30849. */
  30850. static readonly RIG_MODE_WEBVR: number;
  30851. /**
  30852. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30853. */
  30854. static readonly RIG_MODE_CUSTOM: number;
  30855. /**
  30856. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30857. */
  30858. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30859. /**
  30860. * Define the input manager associated with the camera.
  30861. */
  30862. inputs: CameraInputsManager<Camera>;
  30863. /** @hidden */
  30864. _position: Vector3;
  30865. /**
  30866. * Define the current local position of the camera in the scene
  30867. */
  30868. position: Vector3;
  30869. /**
  30870. * The vector the camera should consider as up.
  30871. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30872. */
  30873. upVector: Vector3;
  30874. /**
  30875. * Define the current limit on the left side for an orthographic camera
  30876. * In scene unit
  30877. */
  30878. orthoLeft: Nullable<number>;
  30879. /**
  30880. * Define the current limit on the right side for an orthographic camera
  30881. * In scene unit
  30882. */
  30883. orthoRight: Nullable<number>;
  30884. /**
  30885. * Define the current limit on the bottom side for an orthographic camera
  30886. * In scene unit
  30887. */
  30888. orthoBottom: Nullable<number>;
  30889. /**
  30890. * Define the current limit on the top side for an orthographic camera
  30891. * In scene unit
  30892. */
  30893. orthoTop: Nullable<number>;
  30894. /**
  30895. * Field Of View is set in Radians. (default is 0.8)
  30896. */
  30897. fov: number;
  30898. /**
  30899. * Define the minimum distance the camera can see from.
  30900. * This is important to note that the depth buffer are not infinite and the closer it starts
  30901. * the more your scene might encounter depth fighting issue.
  30902. */
  30903. minZ: number;
  30904. /**
  30905. * Define the maximum distance the camera can see to.
  30906. * This is important to note that the depth buffer are not infinite and the further it end
  30907. * the more your scene might encounter depth fighting issue.
  30908. */
  30909. maxZ: number;
  30910. /**
  30911. * Define the default inertia of the camera.
  30912. * This helps giving a smooth feeling to the camera movement.
  30913. */
  30914. inertia: number;
  30915. /**
  30916. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30917. */
  30918. mode: number;
  30919. /**
  30920. * Define wether the camera is intermediate.
  30921. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30922. */
  30923. isIntermediate: boolean;
  30924. /**
  30925. * Define the viewport of the camera.
  30926. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30927. */
  30928. viewport: Viewport;
  30929. /**
  30930. * Restricts the camera to viewing objects with the same layerMask.
  30931. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30932. */
  30933. layerMask: number;
  30934. /**
  30935. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30936. */
  30937. fovMode: number;
  30938. /**
  30939. * Rig mode of the camera.
  30940. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30941. * This is normally controlled byt the camera themselves as internal use.
  30942. */
  30943. cameraRigMode: number;
  30944. /**
  30945. * Defines the distance between both "eyes" in case of a RIG
  30946. */
  30947. interaxialDistance: number;
  30948. /**
  30949. * Defines if stereoscopic rendering is done side by side or over under.
  30950. */
  30951. isStereoscopicSideBySide: boolean;
  30952. /**
  30953. * 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
  30954. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30955. * else in the scene.
  30956. */
  30957. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30958. /**
  30959. * When set, the camera will render to this render target instead of the default canvas
  30960. */
  30961. outputRenderTarget: Nullable<RenderTargetTexture>;
  30962. /**
  30963. * Observable triggered when the camera view matrix has changed.
  30964. */
  30965. onViewMatrixChangedObservable: Observable<Camera>;
  30966. /**
  30967. * Observable triggered when the camera Projection matrix has changed.
  30968. */
  30969. onProjectionMatrixChangedObservable: Observable<Camera>;
  30970. /**
  30971. * Observable triggered when the inputs have been processed.
  30972. */
  30973. onAfterCheckInputsObservable: Observable<Camera>;
  30974. /**
  30975. * Observable triggered when reset has been called and applied to the camera.
  30976. */
  30977. onRestoreStateObservable: Observable<Camera>;
  30978. /** @hidden */
  30979. _cameraRigParams: any;
  30980. /** @hidden */
  30981. _rigCameras: Camera[];
  30982. /** @hidden */
  30983. _rigPostProcess: Nullable<PostProcess>;
  30984. protected _webvrViewMatrix: Matrix;
  30985. /** @hidden */
  30986. _skipRendering: boolean;
  30987. /** @hidden */
  30988. _projectionMatrix: Matrix;
  30989. /** @hidden */
  30990. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30991. /** @hidden */
  30992. _activeMeshes: SmartArray<AbstractMesh>;
  30993. protected _globalPosition: Vector3;
  30994. /** hidden */
  30995. _computedViewMatrix: Matrix;
  30996. private _doNotComputeProjectionMatrix;
  30997. private _transformMatrix;
  30998. private _frustumPlanes;
  30999. private _refreshFrustumPlanes;
  31000. private _storedFov;
  31001. private _stateStored;
  31002. /**
  31003. * Instantiates a new camera object.
  31004. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31005. * @see http://doc.babylonjs.com/features/cameras
  31006. * @param name Defines the name of the camera in the scene
  31007. * @param position Defines the position of the camera
  31008. * @param scene Defines the scene the camera belongs too
  31009. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31010. */
  31011. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31012. /**
  31013. * Store current camera state (fov, position, etc..)
  31014. * @returns the camera
  31015. */
  31016. storeState(): Camera;
  31017. /**
  31018. * Restores the camera state values if it has been stored. You must call storeState() first
  31019. */
  31020. protected _restoreStateValues(): boolean;
  31021. /**
  31022. * Restored camera state. You must call storeState() first.
  31023. * @returns true if restored and false otherwise
  31024. */
  31025. restoreState(): boolean;
  31026. /**
  31027. * Gets the class name of the camera.
  31028. * @returns the class name
  31029. */
  31030. getClassName(): string;
  31031. /** @hidden */
  31032. readonly _isCamera: boolean;
  31033. /**
  31034. * Gets a string representation of the camera useful for debug purpose.
  31035. * @param fullDetails Defines that a more verboe level of logging is required
  31036. * @returns the string representation
  31037. */
  31038. toString(fullDetails?: boolean): string;
  31039. /**
  31040. * Gets the current world space position of the camera.
  31041. */
  31042. readonly globalPosition: Vector3;
  31043. /**
  31044. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31045. * @returns the active meshe list
  31046. */
  31047. getActiveMeshes(): SmartArray<AbstractMesh>;
  31048. /**
  31049. * Check wether a mesh is part of the current active mesh list of the camera
  31050. * @param mesh Defines the mesh to check
  31051. * @returns true if active, false otherwise
  31052. */
  31053. isActiveMesh(mesh: Mesh): boolean;
  31054. /**
  31055. * Is this camera ready to be used/rendered
  31056. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31057. * @return true if the camera is ready
  31058. */
  31059. isReady(completeCheck?: boolean): boolean;
  31060. /** @hidden */
  31061. _initCache(): void;
  31062. /** @hidden */
  31063. _updateCache(ignoreParentClass?: boolean): void;
  31064. /** @hidden */
  31065. _isSynchronized(): boolean;
  31066. /** @hidden */
  31067. _isSynchronizedViewMatrix(): boolean;
  31068. /** @hidden */
  31069. _isSynchronizedProjectionMatrix(): boolean;
  31070. /**
  31071. * Attach the input controls to a specific dom element to get the input from.
  31072. * @param element Defines the element the controls should be listened from
  31073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31074. */
  31075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31076. /**
  31077. * Detach the current controls from the specified dom element.
  31078. * @param element Defines the element to stop listening the inputs from
  31079. */
  31080. detachControl(element: HTMLElement): void;
  31081. /**
  31082. * Update the camera state according to the different inputs gathered during the frame.
  31083. */
  31084. update(): void;
  31085. /** @hidden */
  31086. _checkInputs(): void;
  31087. /** @hidden */
  31088. readonly rigCameras: Camera[];
  31089. /**
  31090. * Gets the post process used by the rig cameras
  31091. */
  31092. readonly rigPostProcess: Nullable<PostProcess>;
  31093. /**
  31094. * Internal, gets the first post proces.
  31095. * @returns the first post process to be run on this camera.
  31096. */
  31097. _getFirstPostProcess(): Nullable<PostProcess>;
  31098. private _cascadePostProcessesToRigCams;
  31099. /**
  31100. * Attach a post process to the camera.
  31101. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31102. * @param postProcess The post process to attach to the camera
  31103. * @param insertAt The position of the post process in case several of them are in use in the scene
  31104. * @returns the position the post process has been inserted at
  31105. */
  31106. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31107. /**
  31108. * Detach a post process to the camera.
  31109. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31110. * @param postProcess The post process to detach from the camera
  31111. */
  31112. detachPostProcess(postProcess: PostProcess): void;
  31113. /**
  31114. * Gets the current world matrix of the camera
  31115. */
  31116. getWorldMatrix(): Matrix;
  31117. /** @hidden */
  31118. _getViewMatrix(): Matrix;
  31119. /**
  31120. * Gets the current view matrix of the camera.
  31121. * @param force forces the camera to recompute the matrix without looking at the cached state
  31122. * @returns the view matrix
  31123. */
  31124. getViewMatrix(force?: boolean): Matrix;
  31125. /**
  31126. * Freeze the projection matrix.
  31127. * It will prevent the cache check of the camera projection compute and can speed up perf
  31128. * if no parameter of the camera are meant to change
  31129. * @param projection Defines manually a projection if necessary
  31130. */
  31131. freezeProjectionMatrix(projection?: Matrix): void;
  31132. /**
  31133. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31134. */
  31135. unfreezeProjectionMatrix(): void;
  31136. /**
  31137. * Gets the current projection matrix of the camera.
  31138. * @param force forces the camera to recompute the matrix without looking at the cached state
  31139. * @returns the projection matrix
  31140. */
  31141. getProjectionMatrix(force?: boolean): Matrix;
  31142. /**
  31143. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31144. * @returns a Matrix
  31145. */
  31146. getTransformationMatrix(): Matrix;
  31147. private _updateFrustumPlanes;
  31148. /**
  31149. * Checks if a cullable object (mesh...) is in the camera frustum
  31150. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31151. * @param target The object to check
  31152. * @returns true if the object is in frustum otherwise false
  31153. */
  31154. isInFrustum(target: ICullable): boolean;
  31155. /**
  31156. * Checks if a cullable object (mesh...) is in the camera frustum
  31157. * Unlike isInFrustum this cheks the full bounding box
  31158. * @param target The object to check
  31159. * @returns true if the object is in frustum otherwise false
  31160. */
  31161. isCompletelyInFrustum(target: ICullable): boolean;
  31162. /**
  31163. * Gets a ray in the forward direction from the camera.
  31164. * @param length Defines the length of the ray to create
  31165. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31166. * @param origin Defines the start point of the ray which defaults to the camera position
  31167. * @returns the forward ray
  31168. */
  31169. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31170. /**
  31171. * Releases resources associated with this node.
  31172. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31173. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31174. */
  31175. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31176. /** @hidden */
  31177. _isLeftCamera: boolean;
  31178. /**
  31179. * Gets the left camera of a rig setup in case of Rigged Camera
  31180. */
  31181. readonly isLeftCamera: boolean;
  31182. /** @hidden */
  31183. _isRightCamera: boolean;
  31184. /**
  31185. * Gets the right camera of a rig setup in case of Rigged Camera
  31186. */
  31187. readonly isRightCamera: boolean;
  31188. /**
  31189. * Gets the left camera of a rig setup in case of Rigged Camera
  31190. */
  31191. readonly leftCamera: Nullable<FreeCamera>;
  31192. /**
  31193. * Gets the right camera of a rig setup in case of Rigged Camera
  31194. */
  31195. readonly rightCamera: Nullable<FreeCamera>;
  31196. /**
  31197. * Gets the left camera target of a rig setup in case of Rigged Camera
  31198. * @returns the target position
  31199. */
  31200. getLeftTarget(): Nullable<Vector3>;
  31201. /**
  31202. * Gets the right camera target of a rig setup in case of Rigged Camera
  31203. * @returns the target position
  31204. */
  31205. getRightTarget(): Nullable<Vector3>;
  31206. /**
  31207. * @hidden
  31208. */
  31209. setCameraRigMode(mode: number, rigParams: any): void;
  31210. /** @hidden */
  31211. static _setStereoscopicRigMode(camera: Camera): void;
  31212. /** @hidden */
  31213. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31214. /** @hidden */
  31215. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31216. /** @hidden */
  31217. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31218. /** @hidden */
  31219. _getVRProjectionMatrix(): Matrix;
  31220. protected _updateCameraRotationMatrix(): void;
  31221. protected _updateWebVRCameraRotationMatrix(): void;
  31222. /**
  31223. * This function MUST be overwritten by the different WebVR cameras available.
  31224. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31225. * @hidden
  31226. */
  31227. _getWebVRProjectionMatrix(): Matrix;
  31228. /**
  31229. * This function MUST be overwritten by the different WebVR cameras available.
  31230. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31231. * @hidden
  31232. */
  31233. _getWebVRViewMatrix(): Matrix;
  31234. /** @hidden */
  31235. setCameraRigParameter(name: string, value: any): void;
  31236. /**
  31237. * needs to be overridden by children so sub has required properties to be copied
  31238. * @hidden
  31239. */
  31240. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31241. /**
  31242. * May need to be overridden by children
  31243. * @hidden
  31244. */
  31245. _updateRigCameras(): void;
  31246. /** @hidden */
  31247. _setupInputs(): void;
  31248. /**
  31249. * Serialiaze the camera setup to a json represention
  31250. * @returns the JSON representation
  31251. */
  31252. serialize(): any;
  31253. /**
  31254. * Clones the current camera.
  31255. * @param name The cloned camera name
  31256. * @returns the cloned camera
  31257. */
  31258. clone(name: string): Camera;
  31259. /**
  31260. * Gets the direction of the camera relative to a given local axis.
  31261. * @param localAxis Defines the reference axis to provide a relative direction.
  31262. * @return the direction
  31263. */
  31264. getDirection(localAxis: Vector3): Vector3;
  31265. /**
  31266. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31267. * @param localAxis Defines the reference axis to provide a relative direction.
  31268. * @param result Defines the vector to store the result in
  31269. */
  31270. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31271. /**
  31272. * Gets a camera constructor for a given camera type
  31273. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31274. * @param name The name of the camera the result will be able to instantiate
  31275. * @param scene The scene the result will construct the camera in
  31276. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31277. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31278. * @returns a factory method to construc the camera
  31279. */
  31280. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31281. /**
  31282. * Compute the world matrix of the camera.
  31283. * @returns the camera workd matrix
  31284. */
  31285. computeWorldMatrix(): Matrix;
  31286. /**
  31287. * Parse a JSON and creates the camera from the parsed information
  31288. * @param parsedCamera The JSON to parse
  31289. * @param scene The scene to instantiate the camera in
  31290. * @returns the newly constructed camera
  31291. */
  31292. static Parse(parsedCamera: any, scene: Scene): Camera;
  31293. }
  31294. }
  31295. declare module "babylonjs/Misc/tools" {
  31296. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31297. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31298. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31299. import { Observable } from "babylonjs/Misc/observable";
  31300. import { DomManagement } from "babylonjs/Misc/domManagement";
  31301. import { WebRequest } from "babylonjs/Misc/webRequest";
  31302. import { Camera } from "babylonjs/Cameras/camera";
  31303. import { Engine } from "babylonjs/Engines/engine";
  31304. import { Animation } from "babylonjs/Animations/animation";
  31305. /**
  31306. * Interface for any object that can request an animation frame
  31307. */
  31308. export interface ICustomAnimationFrameRequester {
  31309. /**
  31310. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31311. */
  31312. renderFunction?: Function;
  31313. /**
  31314. * Called to request the next frame to render to
  31315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31316. */
  31317. requestAnimationFrame: Function;
  31318. /**
  31319. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31320. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31321. */
  31322. requestID?: number;
  31323. }
  31324. /**
  31325. * Interface containing an array of animations
  31326. */
  31327. export interface IAnimatable {
  31328. /**
  31329. * Array of animations
  31330. */
  31331. animations: Array<Animation>;
  31332. }
  31333. /** Interface used by value gradients (color, factor, ...) */
  31334. export interface IValueGradient {
  31335. /**
  31336. * Gets or sets the gradient value (between 0 and 1)
  31337. */
  31338. gradient: number;
  31339. }
  31340. /** Class used to store color4 gradient */
  31341. export class ColorGradient 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 color
  31348. */
  31349. color1: Color4;
  31350. /**
  31351. * Gets or sets second associated color
  31352. */
  31353. color2?: Color4;
  31354. /**
  31355. * Will get a color picked randomly between color1 and color2.
  31356. * If color2 is undefined then color1 will be used
  31357. * @param result defines the target Color4 to store the result in
  31358. */
  31359. getColorToRef(result: Color4): void;
  31360. }
  31361. /** Class used to store color 3 gradient */
  31362. export class Color3Gradient implements IValueGradient {
  31363. /**
  31364. * Gets or sets the gradient value (between 0 and 1)
  31365. */
  31366. gradient: number;
  31367. /**
  31368. * Gets or sets the associated color
  31369. */
  31370. color: Color3;
  31371. }
  31372. /** Class used to store factor gradient */
  31373. export class FactorGradient implements IValueGradient {
  31374. /**
  31375. * Gets or sets the gradient value (between 0 and 1)
  31376. */
  31377. gradient: number;
  31378. /**
  31379. * Gets or sets first associated factor
  31380. */
  31381. factor1: number;
  31382. /**
  31383. * Gets or sets second associated factor
  31384. */
  31385. factor2?: number;
  31386. /**
  31387. * Will get a number picked randomly between factor1 and factor2.
  31388. * If factor2 is undefined then factor1 will be used
  31389. * @returns the picked number
  31390. */
  31391. getFactor(): number;
  31392. }
  31393. /**
  31394. * @ignore
  31395. * Application error to support additional information when loading a file
  31396. */
  31397. export class LoadFileError extends Error {
  31398. /** defines the optional web request */
  31399. request?: WebRequest | undefined;
  31400. private static _setPrototypeOf;
  31401. /**
  31402. * Creates a new LoadFileError
  31403. * @param message defines the message of the error
  31404. * @param request defines the optional web request
  31405. */
  31406. constructor(message: string,
  31407. /** defines the optional web request */
  31408. request?: WebRequest | undefined);
  31409. }
  31410. /**
  31411. * Class used to define a retry strategy when error happens while loading assets
  31412. */
  31413. export class RetryStrategy {
  31414. /**
  31415. * Function used to defines an exponential back off strategy
  31416. * @param maxRetries defines the maximum number of retries (3 by default)
  31417. * @param baseInterval defines the interval between retries
  31418. * @returns the strategy function to use
  31419. */
  31420. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31421. }
  31422. /**
  31423. * File request interface
  31424. */
  31425. export interface IFileRequest {
  31426. /**
  31427. * Raised when the request is complete (success or error).
  31428. */
  31429. onCompleteObservable: Observable<IFileRequest>;
  31430. /**
  31431. * Aborts the request for a file.
  31432. */
  31433. abort: () => void;
  31434. }
  31435. /**
  31436. * Class containing a set of static utilities functions
  31437. */
  31438. export class Tools {
  31439. /**
  31440. * Gets or sets the base URL to use to load assets
  31441. */
  31442. static BaseUrl: string;
  31443. /**
  31444. * Enable/Disable Custom HTTP Request Headers globally.
  31445. * default = false
  31446. * @see CustomRequestHeaders
  31447. */
  31448. static UseCustomRequestHeaders: boolean;
  31449. /**
  31450. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31451. * i.e. when loading files, where the server/service expects an Authorization header
  31452. */
  31453. static CustomRequestHeaders: {
  31454. [key: string]: string;
  31455. };
  31456. /**
  31457. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31458. */
  31459. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31460. /**
  31461. * Default behaviour for cors in the application.
  31462. * It can be a string if the expected behavior is identical in the entire app.
  31463. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31464. */
  31465. static CorsBehavior: string | ((url: string | string[]) => string);
  31466. /**
  31467. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31468. * @ignorenaming
  31469. */
  31470. static UseFallbackTexture: boolean;
  31471. /**
  31472. * Use this object to register external classes like custom textures or material
  31473. * to allow the laoders to instantiate them
  31474. */
  31475. static RegisteredExternalClasses: {
  31476. [key: string]: Object;
  31477. };
  31478. /**
  31479. * Texture content used if a texture cannot loaded
  31480. * @ignorenaming
  31481. */
  31482. static fallbackTexture: string;
  31483. /**
  31484. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31485. * @param u defines the coordinate on X axis
  31486. * @param v defines the coordinate on Y axis
  31487. * @param width defines the width of the source data
  31488. * @param height defines the height of the source data
  31489. * @param pixels defines the source byte array
  31490. * @param color defines the output color
  31491. */
  31492. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31493. /**
  31494. * Interpolates between a and b via alpha
  31495. * @param a The lower value (returned when alpha = 0)
  31496. * @param b The upper value (returned when alpha = 1)
  31497. * @param alpha The interpolation-factor
  31498. * @return The mixed value
  31499. */
  31500. static Mix(a: number, b: number, alpha: number): number;
  31501. /**
  31502. * Tries to instantiate a new object from a given class name
  31503. * @param className defines the class name to instantiate
  31504. * @returns the new object or null if the system was not able to do the instantiation
  31505. */
  31506. static Instantiate(className: string): any;
  31507. /**
  31508. * Provides a slice function that will work even on IE
  31509. * @param data defines the array to slice
  31510. * @param start defines the start of the data (optional)
  31511. * @param end defines the end of the data (optional)
  31512. * @returns the new sliced array
  31513. */
  31514. static Slice<T>(data: T, start?: number, end?: number): T;
  31515. /**
  31516. * Polyfill for setImmediate
  31517. * @param action defines the action to execute after the current execution block
  31518. */
  31519. static SetImmediate(action: () => void): void;
  31520. /**
  31521. * Function indicating if a number is an exponent of 2
  31522. * @param value defines the value to test
  31523. * @returns true if the value is an exponent of 2
  31524. */
  31525. static IsExponentOfTwo(value: number): boolean;
  31526. private static _tmpFloatArray;
  31527. /**
  31528. * Returns the nearest 32-bit single precision float representation of a Number
  31529. * @param value A Number. If the parameter is of a different type, it will get converted
  31530. * to a number or to NaN if it cannot be converted
  31531. * @returns number
  31532. */
  31533. static FloatRound(value: number): number;
  31534. /**
  31535. * Find the next highest power of two.
  31536. * @param x Number to start search from.
  31537. * @return Next highest power of two.
  31538. */
  31539. static CeilingPOT(x: number): number;
  31540. /**
  31541. * Find the next lowest power of two.
  31542. * @param x Number to start search from.
  31543. * @return Next lowest power of two.
  31544. */
  31545. static FloorPOT(x: number): number;
  31546. /**
  31547. * Find the nearest power of two.
  31548. * @param x Number to start search from.
  31549. * @return Next nearest power of two.
  31550. */
  31551. static NearestPOT(x: number): number;
  31552. /**
  31553. * Get the closest exponent of two
  31554. * @param value defines the value to approximate
  31555. * @param max defines the maximum value to return
  31556. * @param mode defines how to define the closest value
  31557. * @returns closest exponent of two of the given value
  31558. */
  31559. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31560. /**
  31561. * Extracts the filename from a path
  31562. * @param path defines the path to use
  31563. * @returns the filename
  31564. */
  31565. static GetFilename(path: string): string;
  31566. /**
  31567. * Extracts the "folder" part of a path (everything before the filename).
  31568. * @param uri The URI to extract the info from
  31569. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31570. * @returns The "folder" part of the path
  31571. */
  31572. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31573. /**
  31574. * Extracts text content from a DOM element hierarchy
  31575. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31576. */
  31577. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31578. /**
  31579. * Convert an angle in radians to degrees
  31580. * @param angle defines the angle to convert
  31581. * @returns the angle in degrees
  31582. */
  31583. static ToDegrees(angle: number): number;
  31584. /**
  31585. * Convert an angle in degrees to radians
  31586. * @param angle defines the angle to convert
  31587. * @returns the angle in radians
  31588. */
  31589. static ToRadians(angle: number): number;
  31590. /**
  31591. * Encode a buffer to a base64 string
  31592. * @param buffer defines the buffer to encode
  31593. * @returns the encoded string
  31594. */
  31595. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31596. /**
  31597. * Extracts minimum and maximum values from a list of indexed positions
  31598. * @param positions defines the positions to use
  31599. * @param indices defines the indices to the positions
  31600. * @param indexStart defines the start index
  31601. * @param indexCount defines the end index
  31602. * @param bias defines bias value to add to the result
  31603. * @return minimum and maximum values
  31604. */
  31605. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31606. minimum: Vector3;
  31607. maximum: Vector3;
  31608. };
  31609. /**
  31610. * Extracts minimum and maximum values from a list of positions
  31611. * @param positions defines the positions to use
  31612. * @param start defines the start index in the positions array
  31613. * @param count defines the number of positions to handle
  31614. * @param bias defines bias value to add to the result
  31615. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31616. * @return minimum and maximum values
  31617. */
  31618. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31619. minimum: Vector3;
  31620. maximum: Vector3;
  31621. };
  31622. /**
  31623. * Returns an array if obj is not an array
  31624. * @param obj defines the object to evaluate as an array
  31625. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31626. * @returns either obj directly if obj is an array or a new array containing obj
  31627. */
  31628. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31629. /**
  31630. * Gets the pointer prefix to use
  31631. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31632. */
  31633. static GetPointerPrefix(): string;
  31634. /**
  31635. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31636. * @param func - the function to be called
  31637. * @param requester - the object that will request the next frame. Falls back to window.
  31638. * @returns frame number
  31639. */
  31640. static QueueNewFrame(func: () => void, requester?: any): number;
  31641. /**
  31642. * Ask the browser to promote the current element to fullscreen rendering mode
  31643. * @param element defines the DOM element to promote
  31644. */
  31645. static RequestFullscreen(element: HTMLElement): void;
  31646. /**
  31647. * Asks the browser to exit fullscreen mode
  31648. */
  31649. static ExitFullscreen(): void;
  31650. /**
  31651. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31652. * @param url define the url we are trying
  31653. * @param element define the dom element where to configure the cors policy
  31654. */
  31655. static SetCorsBehavior(url: string | string[], element: {
  31656. crossOrigin: string | null;
  31657. }): void;
  31658. /**
  31659. * Removes unwanted characters from an url
  31660. * @param url defines the url to clean
  31661. * @returns the cleaned url
  31662. */
  31663. static CleanUrl(url: string): string;
  31664. /**
  31665. * Gets or sets a function used to pre-process url before using them to load assets
  31666. */
  31667. static PreprocessUrl: (url: string) => string;
  31668. /**
  31669. * Loads an image as an HTMLImageElement.
  31670. * @param input url string, ArrayBuffer, or Blob to load
  31671. * @param onLoad callback called when the image successfully loads
  31672. * @param onError callback called when the image fails to load
  31673. * @param offlineProvider offline provider for caching
  31674. * @returns the HTMLImageElement of the loaded image
  31675. */
  31676. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31677. /**
  31678. * Loads a file
  31679. * @param url url string, ArrayBuffer, or Blob to load
  31680. * @param onSuccess callback called when the file successfully loads
  31681. * @param onProgress callback called while file is loading (if the server supports this mode)
  31682. * @param offlineProvider defines the offline provider for caching
  31683. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31684. * @param onError callback called when the file fails to load
  31685. * @returns a file request object
  31686. */
  31687. 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;
  31688. /**
  31689. * Load a script (identified by an url). When the url returns, the
  31690. * content of this file is added into a new script element, attached to the DOM (body element)
  31691. * @param scriptUrl defines the url of the script to laod
  31692. * @param onSuccess defines the callback called when the script is loaded
  31693. * @param onError defines the callback to call if an error occurs
  31694. * @param scriptId defines the id of the script element
  31695. */
  31696. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31697. /**
  31698. * Load an asynchronous script (identified by an url). When the url returns, the
  31699. * content of this file is added into a new script element, attached to the DOM (body element)
  31700. * @param scriptUrl defines the url of the script to laod
  31701. * @param scriptId defines the id of the script element
  31702. * @returns a promise request object
  31703. */
  31704. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31705. /**
  31706. * Loads a file from a blob
  31707. * @param fileToLoad defines the blob to use
  31708. * @param callback defines the callback to call when data is loaded
  31709. * @param progressCallback defines the callback to call during loading process
  31710. * @returns a file request object
  31711. */
  31712. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31713. /**
  31714. * Loads a file
  31715. * @param fileToLoad defines the file to load
  31716. * @param callback defines the callback to call when data is loaded
  31717. * @param progressCallBack defines the callback to call during loading process
  31718. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31719. * @returns a file request object
  31720. */
  31721. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31722. /**
  31723. * Creates a data url from a given string content
  31724. * @param content defines the content to convert
  31725. * @returns the new data url link
  31726. */
  31727. static FileAsURL(content: string): string;
  31728. /**
  31729. * Format the given number to a specific decimal format
  31730. * @param value defines the number to format
  31731. * @param decimals defines the number of decimals to use
  31732. * @returns the formatted string
  31733. */
  31734. static Format(value: number, decimals?: number): string;
  31735. /**
  31736. * Checks if a given vector is inside a specific range
  31737. * @param v defines the vector to test
  31738. * @param min defines the minimum range
  31739. * @param max defines the maximum range
  31740. */
  31741. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31742. /**
  31743. * Tries to copy an object by duplicating every property
  31744. * @param source defines the source object
  31745. * @param destination defines the target object
  31746. * @param doNotCopyList defines a list of properties to avoid
  31747. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31748. */
  31749. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31750. /**
  31751. * Gets a boolean indicating if the given object has no own property
  31752. * @param obj defines the object to test
  31753. * @returns true if object has no own property
  31754. */
  31755. static IsEmpty(obj: any): boolean;
  31756. /**
  31757. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31758. * @param str Source string
  31759. * @param suffix Suffix to search for in the source string
  31760. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31761. */
  31762. static EndsWith(str: string, suffix: string): boolean;
  31763. /**
  31764. * Function used to register events at window level
  31765. * @param events defines the events to register
  31766. */
  31767. static RegisterTopRootEvents(events: {
  31768. name: string;
  31769. handler: Nullable<(e: FocusEvent) => any>;
  31770. }[]): void;
  31771. /**
  31772. * Function used to unregister events from window level
  31773. * @param events defines the events to unregister
  31774. */
  31775. static UnregisterTopRootEvents(events: {
  31776. name: string;
  31777. handler: Nullable<(e: FocusEvent) => any>;
  31778. }[]): void;
  31779. /**
  31780. * @ignore
  31781. */
  31782. static _ScreenshotCanvas: HTMLCanvasElement;
  31783. /**
  31784. * Dumps the current bound framebuffer
  31785. * @param width defines the rendering width
  31786. * @param height defines the rendering height
  31787. * @param engine defines the hosting engine
  31788. * @param successCallback defines the callback triggered once the data are available
  31789. * @param mimeType defines the mime type of the result
  31790. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31791. */
  31792. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31793. /**
  31794. * Converts the canvas data to blob.
  31795. * This acts as a polyfill for browsers not supporting the to blob function.
  31796. * @param canvas Defines the canvas to extract the data from
  31797. * @param successCallback Defines the callback triggered once the data are available
  31798. * @param mimeType Defines the mime type of the result
  31799. */
  31800. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31801. /**
  31802. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31803. * @param successCallback defines the callback triggered once the data are available
  31804. * @param mimeType defines the mime type of the result
  31805. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31806. */
  31807. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31808. /**
  31809. * Downloads a blob in the browser
  31810. * @param blob defines the blob to download
  31811. * @param fileName defines the name of the downloaded file
  31812. */
  31813. static Download(blob: Blob, fileName: string): void;
  31814. /**
  31815. * Captures a screenshot of the current rendering
  31816. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31817. * @param engine defines the rendering engine
  31818. * @param camera defines the source camera
  31819. * @param size This parameter can be set to a single number or to an object with the
  31820. * following (optional) properties: precision, width, height. If a single number is passed,
  31821. * it will be used for both width and height. If an object is passed, the screenshot size
  31822. * will be derived from the parameters. The precision property is a multiplier allowing
  31823. * rendering at a higher or lower resolution
  31824. * @param successCallback defines the callback receives a single parameter which contains the
  31825. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31826. * src parameter of an <img> to display it
  31827. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31828. * Check your browser for supported MIME types
  31829. */
  31830. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31831. /**
  31832. * Generates an image screenshot from the specified camera.
  31833. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31834. * @param engine The engine to use for rendering
  31835. * @param camera The camera to use for rendering
  31836. * @param size This parameter can be set to a single number or to an object with the
  31837. * following (optional) properties: precision, width, height. If a single number is passed,
  31838. * it will be used for both width and height. If an object is passed, the screenshot size
  31839. * will be derived from the parameters. The precision property is a multiplier allowing
  31840. * rendering at a higher or lower resolution
  31841. * @param successCallback The callback receives a single parameter which contains the
  31842. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31843. * src parameter of an <img> to display it
  31844. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31845. * Check your browser for supported MIME types
  31846. * @param samples Texture samples (default: 1)
  31847. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31848. * @param fileName A name for for the downloaded file.
  31849. */
  31850. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31851. /**
  31852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31853. * Be aware Math.random() could cause collisions, but:
  31854. * "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"
  31855. * @returns a pseudo random id
  31856. */
  31857. static RandomId(): string;
  31858. /**
  31859. * Test if the given uri is a base64 string
  31860. * @param uri The uri to test
  31861. * @return True if the uri is a base64 string or false otherwise
  31862. */
  31863. static IsBase64(uri: string): boolean;
  31864. /**
  31865. * Decode the given base64 uri.
  31866. * @param uri The uri to decode
  31867. * @return The decoded base64 data.
  31868. */
  31869. static DecodeBase64(uri: string): ArrayBuffer;
  31870. /**
  31871. * No log
  31872. */
  31873. static readonly NoneLogLevel: number;
  31874. /**
  31875. * Only message logs
  31876. */
  31877. static readonly MessageLogLevel: number;
  31878. /**
  31879. * Only warning logs
  31880. */
  31881. static readonly WarningLogLevel: number;
  31882. /**
  31883. * Only error logs
  31884. */
  31885. static readonly ErrorLogLevel: number;
  31886. /**
  31887. * All logs
  31888. */
  31889. static readonly AllLogLevel: number;
  31890. /**
  31891. * Gets a value indicating the number of loading errors
  31892. * @ignorenaming
  31893. */
  31894. static readonly errorsCount: number;
  31895. /**
  31896. * Callback called when a new log is added
  31897. */
  31898. static OnNewCacheEntry: (entry: string) => void;
  31899. /**
  31900. * Log a message to the console
  31901. * @param message defines the message to log
  31902. */
  31903. static Log(message: string): void;
  31904. /**
  31905. * Write a warning message to the console
  31906. * @param message defines the message to log
  31907. */
  31908. static Warn(message: string): void;
  31909. /**
  31910. * Write an error message to the console
  31911. * @param message defines the message to log
  31912. */
  31913. static Error(message: string): void;
  31914. /**
  31915. * Gets current log cache (list of logs)
  31916. */
  31917. static readonly LogCache: string;
  31918. /**
  31919. * Clears the log cache
  31920. */
  31921. static ClearLogCache(): void;
  31922. /**
  31923. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31924. */
  31925. static LogLevels: number;
  31926. /**
  31927. * Checks if the loaded document was accessed via `file:`-Protocol.
  31928. * @returns boolean
  31929. */
  31930. static IsFileURL(): boolean;
  31931. /**
  31932. * Checks if the window object exists
  31933. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31934. */
  31935. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31936. /**
  31937. * No performance log
  31938. */
  31939. static readonly PerformanceNoneLogLevel: number;
  31940. /**
  31941. * Use user marks to log performance
  31942. */
  31943. static readonly PerformanceUserMarkLogLevel: number;
  31944. /**
  31945. * Log performance to the console
  31946. */
  31947. static readonly PerformanceConsoleLogLevel: number;
  31948. private static _performance;
  31949. /**
  31950. * Sets the current performance log level
  31951. */
  31952. static PerformanceLogLevel: number;
  31953. private static _StartPerformanceCounterDisabled;
  31954. private static _EndPerformanceCounterDisabled;
  31955. private static _StartUserMark;
  31956. private static _EndUserMark;
  31957. private static _StartPerformanceConsole;
  31958. private static _EndPerformanceConsole;
  31959. /**
  31960. * Starts a performance counter
  31961. */
  31962. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31963. /**
  31964. * Ends a specific performance coutner
  31965. */
  31966. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31967. /**
  31968. * Gets either window.performance.now() if supported or Date.now() else
  31969. */
  31970. static readonly Now: number;
  31971. /**
  31972. * This method will return the name of the class used to create the instance of the given object.
  31973. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31974. * @param object the object to get the class name from
  31975. * @param isType defines if the object is actually a type
  31976. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31977. */
  31978. static GetClassName(object: any, isType?: boolean): string;
  31979. /**
  31980. * Gets the first element of an array satisfying a given predicate
  31981. * @param array defines the array to browse
  31982. * @param predicate defines the predicate to use
  31983. * @returns null if not found or the element
  31984. */
  31985. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31986. /**
  31987. * This method will return the name of the full name of the class, including its owning module (if any).
  31988. * 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).
  31989. * @param object the object to get the class name from
  31990. * @param isType defines if the object is actually a type
  31991. * @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.
  31992. * @ignorenaming
  31993. */
  31994. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31995. /**
  31996. * Returns a promise that resolves after the given amount of time.
  31997. * @param delay Number of milliseconds to delay
  31998. * @returns Promise that resolves after the given amount of time
  31999. */
  32000. static DelayAsync(delay: number): Promise<void>;
  32001. /**
  32002. * Gets the current gradient from an array of IValueGradient
  32003. * @param ratio defines the current ratio to get
  32004. * @param gradients defines the array of IValueGradient
  32005. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32006. */
  32007. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32008. }
  32009. /**
  32010. * This class is used to track a performance counter which is number based.
  32011. * The user has access to many properties which give statistics of different nature.
  32012. *
  32013. * The implementer can track two kinds of Performance Counter: time and count.
  32014. * 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.
  32015. * 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.
  32016. */
  32017. export class PerfCounter {
  32018. /**
  32019. * Gets or sets a global boolean to turn on and off all the counters
  32020. */
  32021. static Enabled: boolean;
  32022. /**
  32023. * Returns the smallest value ever
  32024. */
  32025. readonly min: number;
  32026. /**
  32027. * Returns the biggest value ever
  32028. */
  32029. readonly max: number;
  32030. /**
  32031. * Returns the average value since the performance counter is running
  32032. */
  32033. readonly average: number;
  32034. /**
  32035. * Returns the average value of the last second the counter was monitored
  32036. */
  32037. readonly lastSecAverage: number;
  32038. /**
  32039. * Returns the current value
  32040. */
  32041. readonly current: number;
  32042. /**
  32043. * Gets the accumulated total
  32044. */
  32045. readonly total: number;
  32046. /**
  32047. * Gets the total value count
  32048. */
  32049. readonly count: number;
  32050. /**
  32051. * Creates a new counter
  32052. */
  32053. constructor();
  32054. /**
  32055. * Call this method to start monitoring a new frame.
  32056. * 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.
  32057. */
  32058. fetchNewFrame(): void;
  32059. /**
  32060. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32061. * @param newCount the count value to add to the monitored count
  32062. * @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.
  32063. */
  32064. addCount(newCount: number, fetchResult: boolean): void;
  32065. /**
  32066. * Start monitoring this performance counter
  32067. */
  32068. beginMonitoring(): void;
  32069. /**
  32070. * Compute the time lapsed since the previous beginMonitoring() call.
  32071. * @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
  32072. */
  32073. endMonitoring(newFrame?: boolean): void;
  32074. private _fetchResult;
  32075. private _startMonitoringTime;
  32076. private _min;
  32077. private _max;
  32078. private _average;
  32079. private _current;
  32080. private _totalValueCount;
  32081. private _totalAccumulated;
  32082. private _lastSecAverage;
  32083. private _lastSecAccumulated;
  32084. private _lastSecTime;
  32085. private _lastSecValueCount;
  32086. }
  32087. /**
  32088. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32089. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32090. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32091. * @param name The name of the class, case should be preserved
  32092. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32093. */
  32094. export function className(name: string, module?: string): (target: Object) => void;
  32095. /**
  32096. * An implementation of a loop for asynchronous functions.
  32097. */
  32098. export class AsyncLoop {
  32099. /**
  32100. * Defines the number of iterations for the loop
  32101. */
  32102. iterations: number;
  32103. /**
  32104. * Defines the current index of the loop.
  32105. */
  32106. index: number;
  32107. private _done;
  32108. private _fn;
  32109. private _successCallback;
  32110. /**
  32111. * Constructor.
  32112. * @param iterations the number of iterations.
  32113. * @param func the function to run each iteration
  32114. * @param successCallback the callback that will be called upon succesful execution
  32115. * @param offset starting offset.
  32116. */
  32117. constructor(
  32118. /**
  32119. * Defines the number of iterations for the loop
  32120. */
  32121. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32122. /**
  32123. * Execute the next iteration. Must be called after the last iteration was finished.
  32124. */
  32125. executeNext(): void;
  32126. /**
  32127. * Break the loop and run the success callback.
  32128. */
  32129. breakLoop(): void;
  32130. /**
  32131. * Create and run an async loop.
  32132. * @param iterations the number of iterations.
  32133. * @param fn the function to run each iteration
  32134. * @param successCallback the callback that will be called upon succesful execution
  32135. * @param offset starting offset.
  32136. * @returns the created async loop object
  32137. */
  32138. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32139. /**
  32140. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32141. * @param iterations total number of iterations
  32142. * @param syncedIterations number of synchronous iterations in each async iteration.
  32143. * @param fn the function to call each iteration.
  32144. * @param callback a success call back that will be called when iterating stops.
  32145. * @param breakFunction a break condition (optional)
  32146. * @param timeout timeout settings for the setTimeout function. default - 0.
  32147. * @returns the created async loop object
  32148. */
  32149. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32150. }
  32151. }
  32152. declare module "babylonjs/Collisions/collisionCoordinator" {
  32153. import { Nullable } from "babylonjs/types";
  32154. import { Scene } from "babylonjs/scene";
  32155. import { Vector3 } from "babylonjs/Maths/math";
  32156. import { Collider } from "babylonjs/Collisions/collider";
  32157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32158. /** @hidden */
  32159. export interface ICollisionCoordinator {
  32160. createCollider(): Collider;
  32161. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32162. init(scene: Scene): void;
  32163. }
  32164. /** @hidden */
  32165. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32166. private _scene;
  32167. private _scaledPosition;
  32168. private _scaledVelocity;
  32169. private _finalPosition;
  32170. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32171. createCollider(): Collider;
  32172. init(scene: Scene): void;
  32173. private _collideWithWorld;
  32174. }
  32175. }
  32176. declare module "babylonjs/Animations/animationGroup" {
  32177. import { Animatable } from "babylonjs/Animations/animatable";
  32178. import { Animation } from "babylonjs/Animations/animation";
  32179. import { Scene, IDisposable } from "babylonjs/scene";
  32180. import { Observable } from "babylonjs/Misc/observable";
  32181. import { Nullable } from "babylonjs/types";
  32182. /**
  32183. * This class defines the direct association between an animation and a target
  32184. */
  32185. export class TargetedAnimation {
  32186. /**
  32187. * Animation to perform
  32188. */
  32189. animation: Animation;
  32190. /**
  32191. * Target to animate
  32192. */
  32193. target: any;
  32194. }
  32195. /**
  32196. * Use this class to create coordinated animations on multiple targets
  32197. */
  32198. export class AnimationGroup implements IDisposable {
  32199. /** The name of the animation group */
  32200. name: string;
  32201. private _scene;
  32202. private _targetedAnimations;
  32203. private _animatables;
  32204. private _from;
  32205. private _to;
  32206. private _isStarted;
  32207. private _isPaused;
  32208. private _speedRatio;
  32209. /**
  32210. * Gets or sets the unique id of the node
  32211. */
  32212. uniqueId: number;
  32213. /**
  32214. * This observable will notify when one animation have ended
  32215. */
  32216. onAnimationEndObservable: Observable<TargetedAnimation>;
  32217. /**
  32218. * Observer raised when one animation loops
  32219. */
  32220. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32221. /**
  32222. * This observable will notify when all animations have ended.
  32223. */
  32224. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32225. /**
  32226. * This observable will notify when all animations have paused.
  32227. */
  32228. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32229. /**
  32230. * This observable will notify when all animations are playing.
  32231. */
  32232. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32233. /**
  32234. * Gets the first frame
  32235. */
  32236. readonly from: number;
  32237. /**
  32238. * Gets the last frame
  32239. */
  32240. readonly to: number;
  32241. /**
  32242. * Define if the animations are started
  32243. */
  32244. readonly isStarted: boolean;
  32245. /**
  32246. * Gets a value indicating that the current group is playing
  32247. */
  32248. readonly isPlaying: boolean;
  32249. /**
  32250. * Gets or sets the speed ratio to use for all animations
  32251. */
  32252. /**
  32253. * Gets or sets the speed ratio to use for all animations
  32254. */
  32255. speedRatio: number;
  32256. /**
  32257. * Gets the targeted animations for this animation group
  32258. */
  32259. readonly targetedAnimations: Array<TargetedAnimation>;
  32260. /**
  32261. * returning the list of animatables controlled by this animation group.
  32262. */
  32263. readonly animatables: Array<Animatable>;
  32264. /**
  32265. * Instantiates a new Animation Group.
  32266. * This helps managing several animations at once.
  32267. * @see http://doc.babylonjs.com/how_to/group
  32268. * @param name Defines the name of the group
  32269. * @param scene Defines the scene the group belongs to
  32270. */
  32271. constructor(
  32272. /** The name of the animation group */
  32273. name: string, scene?: Nullable<Scene>);
  32274. /**
  32275. * Add an animation (with its target) in the group
  32276. * @param animation defines the animation we want to add
  32277. * @param target defines the target of the animation
  32278. * @returns the TargetedAnimation object
  32279. */
  32280. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32281. /**
  32282. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32283. * It can add constant keys at begin or end
  32284. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32285. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32286. * @returns the animation group
  32287. */
  32288. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32289. /**
  32290. * Start all animations on given targets
  32291. * @param loop defines if animations must loop
  32292. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32293. * @param from defines the from key (optional)
  32294. * @param to defines the to key (optional)
  32295. * @returns the current animation group
  32296. */
  32297. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32298. /**
  32299. * Pause all animations
  32300. * @returns the animation group
  32301. */
  32302. pause(): AnimationGroup;
  32303. /**
  32304. * Play all animations to initial state
  32305. * This function will start() the animations if they were not started or will restart() them if they were paused
  32306. * @param loop defines if animations must loop
  32307. * @returns the animation group
  32308. */
  32309. play(loop?: boolean): AnimationGroup;
  32310. /**
  32311. * Reset all animations to initial state
  32312. * @returns the animation group
  32313. */
  32314. reset(): AnimationGroup;
  32315. /**
  32316. * Restart animations from key 0
  32317. * @returns the animation group
  32318. */
  32319. restart(): AnimationGroup;
  32320. /**
  32321. * Stop all animations
  32322. * @returns the animation group
  32323. */
  32324. stop(): AnimationGroup;
  32325. /**
  32326. * Set animation weight for all animatables
  32327. * @param weight defines the weight to use
  32328. * @return the animationGroup
  32329. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32330. */
  32331. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32332. /**
  32333. * Synchronize and normalize all animatables with a source animatable
  32334. * @param root defines the root animatable to synchronize with
  32335. * @return the animationGroup
  32336. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32337. */
  32338. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32339. /**
  32340. * Goes to a specific frame in this animation group
  32341. * @param frame the frame number to go to
  32342. * @return the animationGroup
  32343. */
  32344. goToFrame(frame: number): AnimationGroup;
  32345. /**
  32346. * Dispose all associated resources
  32347. */
  32348. dispose(): void;
  32349. private _checkAnimationGroupEnded;
  32350. /**
  32351. * Clone the current animation group and returns a copy
  32352. * @param newName defines the name of the new group
  32353. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32354. * @returns the new aniamtion group
  32355. */
  32356. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32357. /**
  32358. * Returns a new AnimationGroup object parsed from the source provided.
  32359. * @param parsedAnimationGroup defines the source
  32360. * @param scene defines the scene that will receive the animationGroup
  32361. * @returns a new AnimationGroup
  32362. */
  32363. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32364. /**
  32365. * Returns the string "AnimationGroup"
  32366. * @returns "AnimationGroup"
  32367. */
  32368. getClassName(): string;
  32369. /**
  32370. * Creates a detailled string about the object
  32371. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32372. * @returns a string representing the object
  32373. */
  32374. toString(fullDetails?: boolean): string;
  32375. }
  32376. }
  32377. declare module "babylonjs/scene" {
  32378. import { Nullable } from "babylonjs/types";
  32379. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32380. import { Observable } from "babylonjs/Misc/observable";
  32381. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32382. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32383. import { Geometry } from "babylonjs/Meshes/geometry";
  32384. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32387. import { Mesh } from "babylonjs/Meshes/mesh";
  32388. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32389. import { Bone } from "babylonjs/Bones/bone";
  32390. import { Skeleton } from "babylonjs/Bones/skeleton";
  32391. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32392. import { Camera } from "babylonjs/Cameras/camera";
  32393. import { AbstractScene } from "babylonjs/abstractScene";
  32394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32396. import { Material } from "babylonjs/Materials/material";
  32397. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32398. import { Effect } from "babylonjs/Materials/effect";
  32399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32400. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32401. import { Light } from "babylonjs/Lights/light";
  32402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32403. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32404. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32405. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32407. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32408. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32409. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32410. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32411. import { Engine } from "babylonjs/Engines/engine";
  32412. import { Node } from "babylonjs/node";
  32413. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32414. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32415. import { WebRequest } from "babylonjs/Misc/webRequest";
  32416. import { Ray } from "babylonjs/Culling/ray";
  32417. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32418. import { Animation } from "babylonjs/Animations/animation";
  32419. import { Animatable } from "babylonjs/Animations/animatable";
  32420. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32421. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32422. import { Collider } from "babylonjs/Collisions/collider";
  32423. /**
  32424. * Define an interface for all classes that will hold resources
  32425. */
  32426. export interface IDisposable {
  32427. /**
  32428. * Releases all held resources
  32429. */
  32430. dispose(): void;
  32431. }
  32432. /** Interface defining initialization parameters for Scene class */
  32433. export interface SceneOptions {
  32434. /**
  32435. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32436. * It will improve performance when the number of geometries becomes important.
  32437. */
  32438. useGeometryUniqueIdsMap?: boolean;
  32439. /**
  32440. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32441. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32442. */
  32443. useMaterialMeshMap?: boolean;
  32444. /**
  32445. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32446. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32447. */
  32448. useClonedMeshhMap?: boolean;
  32449. }
  32450. /**
  32451. * Represents a scene to be rendered by the engine.
  32452. * @see http://doc.babylonjs.com/features/scene
  32453. */
  32454. export class Scene extends AbstractScene implements IAnimatable {
  32455. private static _uniqueIdCounter;
  32456. /** The fog is deactivated */
  32457. static readonly FOGMODE_NONE: number;
  32458. /** The fog density is following an exponential function */
  32459. static readonly FOGMODE_EXP: number;
  32460. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32461. static readonly FOGMODE_EXP2: number;
  32462. /** The fog density is following a linear function. */
  32463. static readonly FOGMODE_LINEAR: number;
  32464. /**
  32465. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32467. */
  32468. static MinDeltaTime: number;
  32469. /**
  32470. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32471. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32472. */
  32473. static MaxDeltaTime: number;
  32474. /**
  32475. * Factory used to create the default material.
  32476. * @param name The name of the material to create
  32477. * @param scene The scene to create the material for
  32478. * @returns The default material
  32479. */
  32480. static DefaultMaterialFactory(scene: Scene): Material;
  32481. /**
  32482. * Factory used to create the a collision coordinator.
  32483. * @returns The collision coordinator
  32484. */
  32485. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32486. /** @hidden */
  32487. readonly _isScene: boolean;
  32488. /**
  32489. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32490. */
  32491. autoClear: boolean;
  32492. /**
  32493. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32494. */
  32495. autoClearDepthAndStencil: boolean;
  32496. /**
  32497. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32498. */
  32499. clearColor: Color4;
  32500. /**
  32501. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32502. */
  32503. ambientColor: Color3;
  32504. /**
  32505. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32506. * It should only be one of the following (if not the default embedded one):
  32507. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32508. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32509. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32510. * The material properties need to be setup according to the type of texture in use.
  32511. */
  32512. environmentBRDFTexture: BaseTexture;
  32513. /** @hidden */
  32514. protected _environmentTexture: Nullable<BaseTexture>;
  32515. /**
  32516. * Texture used in all pbr material as the reflection texture.
  32517. * As in the majority of the scene they are the same (exception for multi room and so on),
  32518. * this is easier to reference from here than from all the materials.
  32519. */
  32520. /**
  32521. * Texture used in all pbr material as the reflection texture.
  32522. * As in the majority of the scene they are the same (exception for multi room and so on),
  32523. * this is easier to set here than in all the materials.
  32524. */
  32525. environmentTexture: Nullable<BaseTexture>;
  32526. /** @hidden */
  32527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32528. /**
  32529. * Default image processing configuration used either in the rendering
  32530. * Forward main pass or through the imageProcessingPostProcess if present.
  32531. * As in the majority of the scene they are the same (exception for multi camera),
  32532. * this is easier to reference from here than from all the materials and post process.
  32533. *
  32534. * No setter as we it is a shared configuration, you can set the values instead.
  32535. */
  32536. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32537. private _forceWireframe;
  32538. /**
  32539. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32540. */
  32541. forceWireframe: boolean;
  32542. private _forcePointsCloud;
  32543. /**
  32544. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32545. */
  32546. forcePointsCloud: boolean;
  32547. /**
  32548. * Gets or sets the active clipplane 1
  32549. */
  32550. clipPlane: Nullable<Plane>;
  32551. /**
  32552. * Gets or sets the active clipplane 2
  32553. */
  32554. clipPlane2: Nullable<Plane>;
  32555. /**
  32556. * Gets or sets the active clipplane 3
  32557. */
  32558. clipPlane3: Nullable<Plane>;
  32559. /**
  32560. * Gets or sets the active clipplane 4
  32561. */
  32562. clipPlane4: Nullable<Plane>;
  32563. /**
  32564. * Gets or sets a boolean indicating if animations are enabled
  32565. */
  32566. animationsEnabled: boolean;
  32567. private _animationPropertiesOverride;
  32568. /**
  32569. * Gets or sets the animation properties override
  32570. */
  32571. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32572. /**
  32573. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32574. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32575. */
  32576. useConstantAnimationDeltaTime: boolean;
  32577. /**
  32578. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32579. * Please note that it requires to run a ray cast through the scene on every frame
  32580. */
  32581. constantlyUpdateMeshUnderPointer: boolean;
  32582. /**
  32583. * Defines the HTML cursor to use when hovering over interactive elements
  32584. */
  32585. hoverCursor: string;
  32586. /**
  32587. * Defines the HTML default cursor to use (empty by default)
  32588. */
  32589. defaultCursor: string;
  32590. /**
  32591. * This is used to call preventDefault() on pointer down
  32592. * in order to block unwanted artifacts like system double clicks
  32593. */
  32594. preventDefaultOnPointerDown: boolean;
  32595. /**
  32596. * This is used to call preventDefault() on pointer up
  32597. * in order to block unwanted artifacts like system double clicks
  32598. */
  32599. preventDefaultOnPointerUp: boolean;
  32600. /**
  32601. * Gets or sets user defined metadata
  32602. */
  32603. metadata: any;
  32604. /**
  32605. * For internal use only. Please do not use.
  32606. */
  32607. reservedDataStore: any;
  32608. /**
  32609. * Gets the name of the plugin used to load this scene (null by default)
  32610. */
  32611. loadingPluginName: string;
  32612. /**
  32613. * Use this array to add regular expressions used to disable offline support for specific urls
  32614. */
  32615. disableOfflineSupportExceptionRules: RegExp[];
  32616. /**
  32617. * An event triggered when the scene is disposed.
  32618. */
  32619. onDisposeObservable: Observable<Scene>;
  32620. private _onDisposeObserver;
  32621. /** Sets a function to be executed when this scene is disposed. */
  32622. onDispose: () => void;
  32623. /**
  32624. * An event triggered before rendering the scene (right after animations and physics)
  32625. */
  32626. onBeforeRenderObservable: Observable<Scene>;
  32627. private _onBeforeRenderObserver;
  32628. /** Sets a function to be executed before rendering this scene */
  32629. beforeRender: Nullable<() => void>;
  32630. /**
  32631. * An event triggered after rendering the scene
  32632. */
  32633. onAfterRenderObservable: Observable<Scene>;
  32634. private _onAfterRenderObserver;
  32635. /** Sets a function to be executed after rendering this scene */
  32636. afterRender: Nullable<() => void>;
  32637. /**
  32638. * An event triggered before animating the scene
  32639. */
  32640. onBeforeAnimationsObservable: Observable<Scene>;
  32641. /**
  32642. * An event triggered after animations processing
  32643. */
  32644. onAfterAnimationsObservable: Observable<Scene>;
  32645. /**
  32646. * An event triggered before draw calls are ready to be sent
  32647. */
  32648. onBeforeDrawPhaseObservable: Observable<Scene>;
  32649. /**
  32650. * An event triggered after draw calls have been sent
  32651. */
  32652. onAfterDrawPhaseObservable: Observable<Scene>;
  32653. /**
  32654. * An event triggered when the scene is ready
  32655. */
  32656. onReadyObservable: Observable<Scene>;
  32657. /**
  32658. * An event triggered before rendering a camera
  32659. */
  32660. onBeforeCameraRenderObservable: Observable<Camera>;
  32661. private _onBeforeCameraRenderObserver;
  32662. /** Sets a function to be executed before rendering a camera*/
  32663. beforeCameraRender: () => void;
  32664. /**
  32665. * An event triggered after rendering a camera
  32666. */
  32667. onAfterCameraRenderObservable: Observable<Camera>;
  32668. private _onAfterCameraRenderObserver;
  32669. /** Sets a function to be executed after rendering a camera*/
  32670. afterCameraRender: () => void;
  32671. /**
  32672. * An event triggered when active meshes evaluation is about to start
  32673. */
  32674. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32675. /**
  32676. * An event triggered when active meshes evaluation is done
  32677. */
  32678. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered when particles rendering is about to start
  32681. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32682. */
  32683. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered when particles rendering is done
  32686. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32687. */
  32688. onAfterParticlesRenderingObservable: Observable<Scene>;
  32689. /**
  32690. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32691. */
  32692. onDataLoadedObservable: Observable<Scene>;
  32693. /**
  32694. * An event triggered when a camera is created
  32695. */
  32696. onNewCameraAddedObservable: Observable<Camera>;
  32697. /**
  32698. * An event triggered when a camera is removed
  32699. */
  32700. onCameraRemovedObservable: Observable<Camera>;
  32701. /**
  32702. * An event triggered when a light is created
  32703. */
  32704. onNewLightAddedObservable: Observable<Light>;
  32705. /**
  32706. * An event triggered when a light is removed
  32707. */
  32708. onLightRemovedObservable: Observable<Light>;
  32709. /**
  32710. * An event triggered when a geometry is created
  32711. */
  32712. onNewGeometryAddedObservable: Observable<Geometry>;
  32713. /**
  32714. * An event triggered when a geometry is removed
  32715. */
  32716. onGeometryRemovedObservable: Observable<Geometry>;
  32717. /**
  32718. * An event triggered when a transform node is created
  32719. */
  32720. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32721. /**
  32722. * An event triggered when a transform node is removed
  32723. */
  32724. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32725. /**
  32726. * An event triggered when a mesh is created
  32727. */
  32728. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32729. /**
  32730. * An event triggered when a mesh is removed
  32731. */
  32732. onMeshRemovedObservable: Observable<AbstractMesh>;
  32733. /**
  32734. * An event triggered when a skeleton is created
  32735. */
  32736. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32737. /**
  32738. * An event triggered when a skeleton is removed
  32739. */
  32740. onSkeletonRemovedObservable: Observable<Skeleton>;
  32741. /**
  32742. * An event triggered when a material is created
  32743. */
  32744. onNewMaterialAddedObservable: Observable<Material>;
  32745. /**
  32746. * An event triggered when a material is removed
  32747. */
  32748. onMaterialRemovedObservable: Observable<Material>;
  32749. /**
  32750. * An event triggered when a texture is created
  32751. */
  32752. onNewTextureAddedObservable: Observable<BaseTexture>;
  32753. /**
  32754. * An event triggered when a texture is removed
  32755. */
  32756. onTextureRemovedObservable: Observable<BaseTexture>;
  32757. /**
  32758. * An event triggered when render targets are about to be rendered
  32759. * Can happen multiple times per frame.
  32760. */
  32761. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32762. /**
  32763. * An event triggered when render targets were rendered.
  32764. * Can happen multiple times per frame.
  32765. */
  32766. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32767. /**
  32768. * An event triggered before calculating deterministic simulation step
  32769. */
  32770. onBeforeStepObservable: Observable<Scene>;
  32771. /**
  32772. * An event triggered after calculating deterministic simulation step
  32773. */
  32774. onAfterStepObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered when the activeCamera property is updated
  32777. */
  32778. onActiveCameraChanged: Observable<Scene>;
  32779. /**
  32780. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32781. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32782. * 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)
  32783. */
  32784. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32785. /**
  32786. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32787. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32788. * 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)
  32789. */
  32790. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32791. /**
  32792. * This Observable will when a mesh has been imported into the scene.
  32793. */
  32794. onMeshImportedObservable: Observable<AbstractMesh>;
  32795. /**
  32796. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32797. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32798. */
  32799. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32800. /** @hidden */
  32801. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32802. /**
  32803. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32804. */
  32805. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32806. /**
  32807. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32808. */
  32809. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32810. /**
  32811. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32812. */
  32813. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32814. private _onPointerMove;
  32815. private _onPointerDown;
  32816. private _onPointerUp;
  32817. /** Callback called when a pointer move is detected */
  32818. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32819. /** Callback called when a pointer down is detected */
  32820. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32821. /** Callback called when a pointer up is detected */
  32822. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32823. /** Callback called when a pointer pick is detected */
  32824. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32825. /**
  32826. * 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).
  32827. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32828. */
  32829. onPrePointerObservable: Observable<PointerInfoPre>;
  32830. /**
  32831. * Observable event triggered each time an input event is received from the rendering canvas
  32832. */
  32833. onPointerObservable: Observable<PointerInfo>;
  32834. /**
  32835. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32836. */
  32837. readonly unTranslatedPointer: Vector2;
  32838. /** The distance in pixel that you have to move to prevent some events */
  32839. static DragMovementThreshold: number;
  32840. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32841. static LongPressDelay: number;
  32842. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32843. static DoubleClickDelay: number;
  32844. /** If you need to check double click without raising a single click at first click, enable this flag */
  32845. static ExclusiveDoubleClickMode: boolean;
  32846. private _initClickEvent;
  32847. private _initActionManager;
  32848. private _delayedSimpleClick;
  32849. private _delayedSimpleClickTimeout;
  32850. private _previousDelayedSimpleClickTimeout;
  32851. private _meshPickProceed;
  32852. private _previousButtonPressed;
  32853. private _currentPickResult;
  32854. private _previousPickResult;
  32855. private _totalPointersPressed;
  32856. private _doubleClickOccured;
  32857. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32858. cameraToUseForPointers: Nullable<Camera>;
  32859. private _pointerX;
  32860. private _pointerY;
  32861. private _unTranslatedPointerX;
  32862. private _unTranslatedPointerY;
  32863. private _startingPointerPosition;
  32864. private _previousStartingPointerPosition;
  32865. private _startingPointerTime;
  32866. private _previousStartingPointerTime;
  32867. private _pointerCaptures;
  32868. private _timeAccumulator;
  32869. private _currentStepId;
  32870. private _currentInternalStep;
  32871. /** @hidden */
  32872. _mirroredCameraPosition: Nullable<Vector3>;
  32873. /**
  32874. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32875. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32876. */
  32877. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32878. /**
  32879. * Observable event triggered each time an keyboard event is received from the hosting window
  32880. */
  32881. onKeyboardObservable: Observable<KeyboardInfo>;
  32882. private _onKeyDown;
  32883. private _onKeyUp;
  32884. private _onCanvasFocusObserver;
  32885. private _onCanvasBlurObserver;
  32886. private _useRightHandedSystem;
  32887. /**
  32888. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32889. */
  32890. useRightHandedSystem: boolean;
  32891. /**
  32892. * Sets the step Id used by deterministic lock step
  32893. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32894. * @param newStepId defines the step Id
  32895. */
  32896. setStepId(newStepId: number): void;
  32897. /**
  32898. * Gets the step Id used by deterministic lock step
  32899. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32900. * @returns the step Id
  32901. */
  32902. getStepId(): number;
  32903. /**
  32904. * Gets the internal step used by deterministic lock step
  32905. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32906. * @returns the internal step
  32907. */
  32908. getInternalStep(): number;
  32909. private _fogEnabled;
  32910. /**
  32911. * Gets or sets a boolean indicating if fog is enabled on this scene
  32912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32913. * (Default is true)
  32914. */
  32915. fogEnabled: boolean;
  32916. private _fogMode;
  32917. /**
  32918. * Gets or sets the fog mode to use
  32919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32920. * | mode | value |
  32921. * | --- | --- |
  32922. * | FOGMODE_NONE | 0 |
  32923. * | FOGMODE_EXP | 1 |
  32924. * | FOGMODE_EXP2 | 2 |
  32925. * | FOGMODE_LINEAR | 3 |
  32926. */
  32927. fogMode: number;
  32928. /**
  32929. * Gets or sets the fog color to use
  32930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32931. * (Default is Color3(0.2, 0.2, 0.3))
  32932. */
  32933. fogColor: Color3;
  32934. /**
  32935. * Gets or sets the fog density to use
  32936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32937. * (Default is 0.1)
  32938. */
  32939. fogDensity: number;
  32940. /**
  32941. * Gets or sets the fog start distance to use
  32942. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32943. * (Default is 0)
  32944. */
  32945. fogStart: number;
  32946. /**
  32947. * Gets or sets the fog end distance to use
  32948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32949. * (Default is 1000)
  32950. */
  32951. fogEnd: number;
  32952. private _shadowsEnabled;
  32953. /**
  32954. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32955. */
  32956. shadowsEnabled: boolean;
  32957. private _lightsEnabled;
  32958. /**
  32959. * Gets or sets a boolean indicating if lights are enabled on this scene
  32960. */
  32961. lightsEnabled: boolean;
  32962. /** All of the active cameras added to this scene. */
  32963. activeCameras: Camera[];
  32964. /** @hidden */
  32965. _activeCamera: Nullable<Camera>;
  32966. /** Gets or sets the current active camera */
  32967. activeCamera: Nullable<Camera>;
  32968. private _defaultMaterial;
  32969. /** The default material used on meshes when no material is affected */
  32970. /** The default material used on meshes when no material is affected */
  32971. defaultMaterial: Material;
  32972. private _texturesEnabled;
  32973. /**
  32974. * Gets or sets a boolean indicating if textures are enabled on this scene
  32975. */
  32976. texturesEnabled: boolean;
  32977. /**
  32978. * Gets or sets a boolean indicating if particles are enabled on this scene
  32979. */
  32980. particlesEnabled: boolean;
  32981. /**
  32982. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32983. */
  32984. spritesEnabled: boolean;
  32985. private _skeletonsEnabled;
  32986. /**
  32987. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32988. */
  32989. skeletonsEnabled: boolean;
  32990. /**
  32991. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32992. */
  32993. lensFlaresEnabled: boolean;
  32994. /**
  32995. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32997. */
  32998. collisionsEnabled: boolean;
  32999. private _collisionCoordinator;
  33000. /** @hidden */
  33001. readonly collisionCoordinator: ICollisionCoordinator;
  33002. /**
  33003. * Defines the gravity applied to this scene (used only for collisions)
  33004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33005. */
  33006. gravity: Vector3;
  33007. /**
  33008. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33009. */
  33010. postProcessesEnabled: boolean;
  33011. /**
  33012. * The list of postprocesses added to the scene
  33013. */
  33014. postProcesses: PostProcess[];
  33015. /**
  33016. * Gets the current postprocess manager
  33017. */
  33018. postProcessManager: PostProcessManager;
  33019. /**
  33020. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33021. */
  33022. renderTargetsEnabled: boolean;
  33023. /**
  33024. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33025. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33026. */
  33027. dumpNextRenderTargets: boolean;
  33028. /**
  33029. * The list of user defined render targets added to the scene
  33030. */
  33031. customRenderTargets: RenderTargetTexture[];
  33032. /**
  33033. * Defines if texture loading must be delayed
  33034. * If true, textures will only be loaded when they need to be rendered
  33035. */
  33036. useDelayedTextureLoading: boolean;
  33037. /**
  33038. * Gets the list of meshes imported to the scene through SceneLoader
  33039. */
  33040. importedMeshesFiles: String[];
  33041. /**
  33042. * Gets or sets a boolean indicating if probes are enabled on this scene
  33043. */
  33044. probesEnabled: boolean;
  33045. /**
  33046. * Gets or sets the current offline provider to use to store scene data
  33047. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33048. */
  33049. offlineProvider: IOfflineProvider;
  33050. /**
  33051. * Gets or sets the action manager associated with the scene
  33052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33053. */
  33054. actionManager: AbstractActionManager;
  33055. private _meshesForIntersections;
  33056. /**
  33057. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33058. */
  33059. proceduralTexturesEnabled: boolean;
  33060. private _engine;
  33061. private _totalVertices;
  33062. /** @hidden */
  33063. _activeIndices: PerfCounter;
  33064. /** @hidden */
  33065. _activeParticles: PerfCounter;
  33066. /** @hidden */
  33067. _activeBones: PerfCounter;
  33068. private _animationRatio;
  33069. /** @hidden */
  33070. _animationTimeLast: number;
  33071. /** @hidden */
  33072. _animationTime: number;
  33073. /**
  33074. * Gets or sets a general scale for animation speed
  33075. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33076. */
  33077. animationTimeScale: number;
  33078. /** @hidden */
  33079. _cachedMaterial: Nullable<Material>;
  33080. /** @hidden */
  33081. _cachedEffect: Nullable<Effect>;
  33082. /** @hidden */
  33083. _cachedVisibility: Nullable<number>;
  33084. private _renderId;
  33085. private _frameId;
  33086. private _executeWhenReadyTimeoutId;
  33087. private _intermediateRendering;
  33088. private _viewUpdateFlag;
  33089. private _projectionUpdateFlag;
  33090. /** @hidden */
  33091. _toBeDisposed: Nullable<IDisposable>[];
  33092. private _activeRequests;
  33093. /** @hidden */
  33094. _pendingData: any[];
  33095. private _isDisposed;
  33096. /**
  33097. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33098. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33099. */
  33100. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33101. private _activeMeshes;
  33102. private _processedMaterials;
  33103. private _renderTargets;
  33104. /** @hidden */
  33105. _activeParticleSystems: SmartArray<IParticleSystem>;
  33106. private _activeSkeletons;
  33107. private _softwareSkinnedMeshes;
  33108. private _renderingManager;
  33109. /** @hidden */
  33110. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33111. private _transformMatrix;
  33112. private _sceneUbo;
  33113. /** @hidden */
  33114. _viewMatrix: Matrix;
  33115. private _projectionMatrix;
  33116. private _wheelEventName;
  33117. /** @hidden */
  33118. _forcedViewPosition: Nullable<Vector3>;
  33119. /** @hidden */
  33120. _frustumPlanes: Plane[];
  33121. /**
  33122. * Gets the list of frustum planes (built from the active camera)
  33123. */
  33124. readonly frustumPlanes: Plane[];
  33125. /**
  33126. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33127. * This is useful if there are more lights that the maximum simulteanous authorized
  33128. */
  33129. requireLightSorting: boolean;
  33130. /** @hidden */
  33131. readonly useMaterialMeshMap: boolean;
  33132. /** @hidden */
  33133. readonly useClonedMeshhMap: boolean;
  33134. private _pointerOverMesh;
  33135. private _pickedDownMesh;
  33136. private _pickedUpMesh;
  33137. private _externalData;
  33138. private _uid;
  33139. /**
  33140. * @hidden
  33141. * Backing store of defined scene components.
  33142. */
  33143. _components: ISceneComponent[];
  33144. /**
  33145. * @hidden
  33146. * Backing store of defined scene components.
  33147. */
  33148. _serializableComponents: ISceneSerializableComponent[];
  33149. /**
  33150. * List of components to register on the next registration step.
  33151. */
  33152. private _transientComponents;
  33153. /**
  33154. * Registers the transient components if needed.
  33155. */
  33156. private _registerTransientComponents;
  33157. /**
  33158. * @hidden
  33159. * Add a component to the scene.
  33160. * Note that the ccomponent could be registered on th next frame if this is called after
  33161. * the register component stage.
  33162. * @param component Defines the component to add to the scene
  33163. */
  33164. _addComponent(component: ISceneComponent): void;
  33165. /**
  33166. * @hidden
  33167. * Gets a component from the scene.
  33168. * @param name defines the name of the component to retrieve
  33169. * @returns the component or null if not present
  33170. */
  33171. _getComponent(name: string): Nullable<ISceneComponent>;
  33172. /**
  33173. * @hidden
  33174. * Defines the actions happening before camera updates.
  33175. */
  33176. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33177. /**
  33178. * @hidden
  33179. * Defines the actions happening before clear the canvas.
  33180. */
  33181. _beforeClearStage: Stage<SimpleStageAction>;
  33182. /**
  33183. * @hidden
  33184. * Defines the actions when collecting render targets for the frame.
  33185. */
  33186. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33187. /**
  33188. * @hidden
  33189. * Defines the actions happening for one camera in the frame.
  33190. */
  33191. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33192. /**
  33193. * @hidden
  33194. * Defines the actions happening during the per mesh ready checks.
  33195. */
  33196. _isReadyForMeshStage: Stage<MeshStageAction>;
  33197. /**
  33198. * @hidden
  33199. * Defines the actions happening before evaluate active mesh checks.
  33200. */
  33201. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33202. /**
  33203. * @hidden
  33204. * Defines the actions happening during the evaluate sub mesh checks.
  33205. */
  33206. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33207. /**
  33208. * @hidden
  33209. * Defines the actions happening during the active mesh stage.
  33210. */
  33211. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33212. /**
  33213. * @hidden
  33214. * Defines the actions happening during the per camera render target step.
  33215. */
  33216. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33217. /**
  33218. * @hidden
  33219. * Defines the actions happening just before the active camera is drawing.
  33220. */
  33221. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33222. /**
  33223. * @hidden
  33224. * Defines the actions happening just before a render target is drawing.
  33225. */
  33226. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33227. /**
  33228. * @hidden
  33229. * Defines the actions happening just before a rendering group is drawing.
  33230. */
  33231. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33232. /**
  33233. * @hidden
  33234. * Defines the actions happening just before a mesh is drawing.
  33235. */
  33236. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33237. /**
  33238. * @hidden
  33239. * Defines the actions happening just after a mesh has been drawn.
  33240. */
  33241. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33242. /**
  33243. * @hidden
  33244. * Defines the actions happening just after a rendering group has been drawn.
  33245. */
  33246. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33247. /**
  33248. * @hidden
  33249. * Defines the actions happening just after the active camera has been drawn.
  33250. */
  33251. _afterCameraDrawStage: Stage<CameraStageAction>;
  33252. /**
  33253. * @hidden
  33254. * Defines the actions happening just after a render target has been drawn.
  33255. */
  33256. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33257. /**
  33258. * @hidden
  33259. * Defines the actions happening just after rendering all cameras and computing intersections.
  33260. */
  33261. _afterRenderStage: Stage<SimpleStageAction>;
  33262. /**
  33263. * @hidden
  33264. * Defines the actions happening when a pointer move event happens.
  33265. */
  33266. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33267. /**
  33268. * @hidden
  33269. * Defines the actions happening when a pointer down event happens.
  33270. */
  33271. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33272. /**
  33273. * @hidden
  33274. * Defines the actions happening when a pointer up event happens.
  33275. */
  33276. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33277. /**
  33278. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33279. */
  33280. private geometriesByUniqueId;
  33281. /**
  33282. * Creates a new Scene
  33283. * @param engine defines the engine to use to render this scene
  33284. * @param options defines the scene options
  33285. */
  33286. constructor(engine: Engine, options?: SceneOptions);
  33287. /**
  33288. * Gets a string idenfifying the name of the class
  33289. * @returns "Scene" string
  33290. */
  33291. getClassName(): string;
  33292. private _defaultMeshCandidates;
  33293. /**
  33294. * @hidden
  33295. */
  33296. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33297. private _defaultSubMeshCandidates;
  33298. /**
  33299. * @hidden
  33300. */
  33301. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33302. /**
  33303. * Sets the default candidate providers for the scene.
  33304. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33305. * and getCollidingSubMeshCandidates to their default function
  33306. */
  33307. setDefaultCandidateProviders(): void;
  33308. /**
  33309. * Gets the mesh that is currently under the pointer
  33310. */
  33311. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33312. /**
  33313. * Gets or sets the current on-screen X position of the pointer
  33314. */
  33315. pointerX: number;
  33316. /**
  33317. * Gets or sets the current on-screen Y position of the pointer
  33318. */
  33319. pointerY: number;
  33320. /**
  33321. * Gets the cached material (ie. the latest rendered one)
  33322. * @returns the cached material
  33323. */
  33324. getCachedMaterial(): Nullable<Material>;
  33325. /**
  33326. * Gets the cached effect (ie. the latest rendered one)
  33327. * @returns the cached effect
  33328. */
  33329. getCachedEffect(): Nullable<Effect>;
  33330. /**
  33331. * Gets the cached visibility state (ie. the latest rendered one)
  33332. * @returns the cached visibility state
  33333. */
  33334. getCachedVisibility(): Nullable<number>;
  33335. /**
  33336. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33337. * @param material defines the current material
  33338. * @param effect defines the current effect
  33339. * @param visibility defines the current visibility state
  33340. * @returns true if one parameter is not cached
  33341. */
  33342. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33343. /**
  33344. * Gets the engine associated with the scene
  33345. * @returns an Engine
  33346. */
  33347. getEngine(): Engine;
  33348. /**
  33349. * Gets the total number of vertices rendered per frame
  33350. * @returns the total number of vertices rendered per frame
  33351. */
  33352. getTotalVertices(): number;
  33353. /**
  33354. * Gets the performance counter for total vertices
  33355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33356. */
  33357. readonly totalVerticesPerfCounter: PerfCounter;
  33358. /**
  33359. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33360. * @returns the total number of active indices rendered per frame
  33361. */
  33362. getActiveIndices(): number;
  33363. /**
  33364. * Gets the performance counter for active indices
  33365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33366. */
  33367. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33368. /**
  33369. * Gets the total number of active particles rendered per frame
  33370. * @returns the total number of active particles rendered per frame
  33371. */
  33372. getActiveParticles(): number;
  33373. /**
  33374. * Gets the performance counter for active particles
  33375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33376. */
  33377. readonly activeParticlesPerfCounter: PerfCounter;
  33378. /**
  33379. * Gets the total number of active bones rendered per frame
  33380. * @returns the total number of active bones rendered per frame
  33381. */
  33382. getActiveBones(): number;
  33383. /**
  33384. * Gets the performance counter for active bones
  33385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33386. */
  33387. readonly activeBonesPerfCounter: PerfCounter;
  33388. /**
  33389. * Gets the array of active meshes
  33390. * @returns an array of AbstractMesh
  33391. */
  33392. getActiveMeshes(): SmartArray<AbstractMesh>;
  33393. /**
  33394. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33395. * @returns a number
  33396. */
  33397. getAnimationRatio(): number;
  33398. /**
  33399. * Gets an unique Id for the current render phase
  33400. * @returns a number
  33401. */
  33402. getRenderId(): number;
  33403. /**
  33404. * Gets an unique Id for the current frame
  33405. * @returns a number
  33406. */
  33407. getFrameId(): number;
  33408. /** Call this function if you want to manually increment the render Id*/
  33409. incrementRenderId(): void;
  33410. private _updatePointerPosition;
  33411. private _createUbo;
  33412. private _setRayOnPointerInfo;
  33413. /**
  33414. * Use this method to simulate a pointer move on a mesh
  33415. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33416. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33417. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33418. * @returns the current scene
  33419. */
  33420. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33421. private _processPointerMove;
  33422. private _checkPrePointerObservable;
  33423. /**
  33424. * Use this method to simulate a pointer down on a mesh
  33425. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33426. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33427. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33428. * @returns the current scene
  33429. */
  33430. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33431. private _processPointerDown;
  33432. /**
  33433. * Use this method to simulate a pointer up on a mesh
  33434. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33435. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33436. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33437. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33438. * @returns the current scene
  33439. */
  33440. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33441. private _processPointerUp;
  33442. /**
  33443. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33444. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33445. * @returns true if the pointer was captured
  33446. */
  33447. isPointerCaptured(pointerId?: number): boolean;
  33448. /** @hidden */
  33449. _isPointerSwiping(): boolean;
  33450. /**
  33451. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33452. * @param attachUp defines if you want to attach events to pointerup
  33453. * @param attachDown defines if you want to attach events to pointerdown
  33454. * @param attachMove defines if you want to attach events to pointermove
  33455. */
  33456. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33457. /** Detaches all event handlers*/
  33458. detachControl(): void;
  33459. /**
  33460. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33461. * Delay loaded resources are not taking in account
  33462. * @return true if all required resources are ready
  33463. */
  33464. isReady(): boolean;
  33465. /** Resets all cached information relative to material (including effect and visibility) */
  33466. resetCachedMaterial(): void;
  33467. /**
  33468. * Registers a function to be called before every frame render
  33469. * @param func defines the function to register
  33470. */
  33471. registerBeforeRender(func: () => void): void;
  33472. /**
  33473. * Unregisters a function called before every frame render
  33474. * @param func defines the function to unregister
  33475. */
  33476. unregisterBeforeRender(func: () => void): void;
  33477. /**
  33478. * Registers a function to be called after every frame render
  33479. * @param func defines the function to register
  33480. */
  33481. registerAfterRender(func: () => void): void;
  33482. /**
  33483. * Unregisters a function called after every frame render
  33484. * @param func defines the function to unregister
  33485. */
  33486. unregisterAfterRender(func: () => void): void;
  33487. private _executeOnceBeforeRender;
  33488. /**
  33489. * The provided function will run before render once and will be disposed afterwards.
  33490. * A timeout delay can be provided so that the function will be executed in N ms.
  33491. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33492. * @param func The function to be executed.
  33493. * @param timeout optional delay in ms
  33494. */
  33495. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33496. /** @hidden */
  33497. _addPendingData(data: any): void;
  33498. /** @hidden */
  33499. _removePendingData(data: any): void;
  33500. /**
  33501. * Returns the number of items waiting to be loaded
  33502. * @returns the number of items waiting to be loaded
  33503. */
  33504. getWaitingItemsCount(): number;
  33505. /**
  33506. * Returns a boolean indicating if the scene is still loading data
  33507. */
  33508. readonly isLoading: boolean;
  33509. /**
  33510. * Registers a function to be executed when the scene is ready
  33511. * @param {Function} func - the function to be executed
  33512. */
  33513. executeWhenReady(func: () => void): void;
  33514. /**
  33515. * Returns a promise that resolves when the scene is ready
  33516. * @returns A promise that resolves when the scene is ready
  33517. */
  33518. whenReadyAsync(): Promise<void>;
  33519. /** @hidden */
  33520. _checkIsReady(): void;
  33521. /**
  33522. * Gets all animatable attached to the scene
  33523. */
  33524. readonly animatables: Animatable[];
  33525. /**
  33526. * Resets the last animation time frame.
  33527. * Useful to override when animations start running when loading a scene for the first time.
  33528. */
  33529. resetLastAnimationTimeFrame(): void;
  33530. /**
  33531. * Gets the current view matrix
  33532. * @returns a Matrix
  33533. */
  33534. getViewMatrix(): Matrix;
  33535. /**
  33536. * Gets the current projection matrix
  33537. * @returns a Matrix
  33538. */
  33539. getProjectionMatrix(): Matrix;
  33540. /**
  33541. * Gets the current transform matrix
  33542. * @returns a Matrix made of View * Projection
  33543. */
  33544. getTransformMatrix(): Matrix;
  33545. /**
  33546. * Sets the current transform matrix
  33547. * @param viewL defines the View matrix to use
  33548. * @param projectionL defines the Projection matrix to use
  33549. * @param viewR defines the right View matrix to use (if provided)
  33550. * @param projectionR defines the right Projection matrix to use (if provided)
  33551. */
  33552. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33553. /**
  33554. * Gets the uniform buffer used to store scene data
  33555. * @returns a UniformBuffer
  33556. */
  33557. getSceneUniformBuffer(): UniformBuffer;
  33558. /**
  33559. * Gets an unique (relatively to the current scene) Id
  33560. * @returns an unique number for the scene
  33561. */
  33562. getUniqueId(): number;
  33563. /**
  33564. * Add a mesh to the list of scene's meshes
  33565. * @param newMesh defines the mesh to add
  33566. * @param recursive if all child meshes should also be added to the scene
  33567. */
  33568. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33569. /**
  33570. * Remove a mesh for the list of scene's meshes
  33571. * @param toRemove defines the mesh to remove
  33572. * @param recursive if all child meshes should also be removed from the scene
  33573. * @returns the index where the mesh was in the mesh list
  33574. */
  33575. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33576. /**
  33577. * Add a transform node to the list of scene's transform nodes
  33578. * @param newTransformNode defines the transform node to add
  33579. */
  33580. addTransformNode(newTransformNode: TransformNode): void;
  33581. /**
  33582. * Remove a transform node for the list of scene's transform nodes
  33583. * @param toRemove defines the transform node to remove
  33584. * @returns the index where the transform node was in the transform node list
  33585. */
  33586. removeTransformNode(toRemove: TransformNode): number;
  33587. /**
  33588. * Remove a skeleton for the list of scene's skeletons
  33589. * @param toRemove defines the skeleton to remove
  33590. * @returns the index where the skeleton was in the skeleton list
  33591. */
  33592. removeSkeleton(toRemove: Skeleton): number;
  33593. /**
  33594. * Remove a morph target for the list of scene's morph targets
  33595. * @param toRemove defines the morph target to remove
  33596. * @returns the index where the morph target was in the morph target list
  33597. */
  33598. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33599. /**
  33600. * Remove a light for the list of scene's lights
  33601. * @param toRemove defines the light to remove
  33602. * @returns the index where the light was in the light list
  33603. */
  33604. removeLight(toRemove: Light): number;
  33605. /**
  33606. * Remove a camera for the list of scene's cameras
  33607. * @param toRemove defines the camera to remove
  33608. * @returns the index where the camera was in the camera list
  33609. */
  33610. removeCamera(toRemove: Camera): number;
  33611. /**
  33612. * Remove a particle system for the list of scene's particle systems
  33613. * @param toRemove defines the particle system to remove
  33614. * @returns the index where the particle system was in the particle system list
  33615. */
  33616. removeParticleSystem(toRemove: IParticleSystem): number;
  33617. /**
  33618. * Remove a animation for the list of scene's animations
  33619. * @param toRemove defines the animation to remove
  33620. * @returns the index where the animation was in the animation list
  33621. */
  33622. removeAnimation(toRemove: Animation): number;
  33623. /**
  33624. * Removes the given animation group from this scene.
  33625. * @param toRemove The animation group to remove
  33626. * @returns The index of the removed animation group
  33627. */
  33628. removeAnimationGroup(toRemove: AnimationGroup): number;
  33629. /**
  33630. * Removes the given multi-material from this scene.
  33631. * @param toRemove The multi-material to remove
  33632. * @returns The index of the removed multi-material
  33633. */
  33634. removeMultiMaterial(toRemove: MultiMaterial): number;
  33635. /**
  33636. * Removes the given material from this scene.
  33637. * @param toRemove The material to remove
  33638. * @returns The index of the removed material
  33639. */
  33640. removeMaterial(toRemove: Material): number;
  33641. /**
  33642. * Removes the given action manager from this scene.
  33643. * @param toRemove The action manager to remove
  33644. * @returns The index of the removed action manager
  33645. */
  33646. removeActionManager(toRemove: AbstractActionManager): number;
  33647. /**
  33648. * Removes the given texture from this scene.
  33649. * @param toRemove The texture to remove
  33650. * @returns The index of the removed texture
  33651. */
  33652. removeTexture(toRemove: BaseTexture): number;
  33653. /**
  33654. * Adds the given light to this scene
  33655. * @param newLight The light to add
  33656. */
  33657. addLight(newLight: Light): void;
  33658. /**
  33659. * Sorts the list list based on light priorities
  33660. */
  33661. sortLightsByPriority(): void;
  33662. /**
  33663. * Adds the given camera to this scene
  33664. * @param newCamera The camera to add
  33665. */
  33666. addCamera(newCamera: Camera): void;
  33667. /**
  33668. * Adds the given skeleton to this scene
  33669. * @param newSkeleton The skeleton to add
  33670. */
  33671. addSkeleton(newSkeleton: Skeleton): void;
  33672. /**
  33673. * Adds the given particle system to this scene
  33674. * @param newParticleSystem The particle system to add
  33675. */
  33676. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33677. /**
  33678. * Adds the given animation to this scene
  33679. * @param newAnimation The animation to add
  33680. */
  33681. addAnimation(newAnimation: Animation): void;
  33682. /**
  33683. * Adds the given animation group to this scene.
  33684. * @param newAnimationGroup The animation group to add
  33685. */
  33686. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33687. /**
  33688. * Adds the given multi-material to this scene
  33689. * @param newMultiMaterial The multi-material to add
  33690. */
  33691. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33692. /**
  33693. * Adds the given material to this scene
  33694. * @param newMaterial The material to add
  33695. */
  33696. addMaterial(newMaterial: Material): void;
  33697. /**
  33698. * Adds the given morph target to this scene
  33699. * @param newMorphTargetManager The morph target to add
  33700. */
  33701. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33702. /**
  33703. * Adds the given geometry to this scene
  33704. * @param newGeometry The geometry to add
  33705. */
  33706. addGeometry(newGeometry: Geometry): void;
  33707. /**
  33708. * Adds the given action manager to this scene
  33709. * @param newActionManager The action manager to add
  33710. */
  33711. addActionManager(newActionManager: AbstractActionManager): void;
  33712. /**
  33713. * Adds the given texture to this scene.
  33714. * @param newTexture The texture to add
  33715. */
  33716. addTexture(newTexture: BaseTexture): void;
  33717. /**
  33718. * Switch active camera
  33719. * @param newCamera defines the new active camera
  33720. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33721. */
  33722. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33723. /**
  33724. * sets the active camera of the scene using its ID
  33725. * @param id defines the camera's ID
  33726. * @return the new active camera or null if none found.
  33727. */
  33728. setActiveCameraByID(id: string): Nullable<Camera>;
  33729. /**
  33730. * sets the active camera of the scene using its name
  33731. * @param name defines the camera's name
  33732. * @returns the new active camera or null if none found.
  33733. */
  33734. setActiveCameraByName(name: string): Nullable<Camera>;
  33735. /**
  33736. * get an animation group using its name
  33737. * @param name defines the material's name
  33738. * @return the animation group or null if none found.
  33739. */
  33740. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33741. /**
  33742. * Get a material using its unique id
  33743. * @param uniqueId defines the material's unique id
  33744. * @return the material or null if none found.
  33745. */
  33746. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33747. /**
  33748. * get a material using its id
  33749. * @param id defines the material's ID
  33750. * @return the material or null if none found.
  33751. */
  33752. getMaterialByID(id: string): Nullable<Material>;
  33753. /**
  33754. * Gets a material using its name
  33755. * @param name defines the material's name
  33756. * @return the material or null if none found.
  33757. */
  33758. getMaterialByName(name: string): Nullable<Material>;
  33759. /**
  33760. * Gets a camera using its id
  33761. * @param id defines the id to look for
  33762. * @returns the camera or null if not found
  33763. */
  33764. getCameraByID(id: string): Nullable<Camera>;
  33765. /**
  33766. * Gets a camera using its unique id
  33767. * @param uniqueId defines the unique id to look for
  33768. * @returns the camera or null if not found
  33769. */
  33770. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33771. /**
  33772. * Gets a camera using its name
  33773. * @param name defines the camera's name
  33774. * @return the camera or null if none found.
  33775. */
  33776. getCameraByName(name: string): Nullable<Camera>;
  33777. /**
  33778. * Gets a bone using its id
  33779. * @param id defines the bone's id
  33780. * @return the bone or null if not found
  33781. */
  33782. getBoneByID(id: string): Nullable<Bone>;
  33783. /**
  33784. * Gets a bone using its id
  33785. * @param name defines the bone's name
  33786. * @return the bone or null if not found
  33787. */
  33788. getBoneByName(name: string): Nullable<Bone>;
  33789. /**
  33790. * Gets a light node using its name
  33791. * @param name defines the the light's name
  33792. * @return the light or null if none found.
  33793. */
  33794. getLightByName(name: string): Nullable<Light>;
  33795. /**
  33796. * Gets a light node using its id
  33797. * @param id defines the light's id
  33798. * @return the light or null if none found.
  33799. */
  33800. getLightByID(id: string): Nullable<Light>;
  33801. /**
  33802. * Gets a light node using its scene-generated unique ID
  33803. * @param uniqueId defines the light's unique id
  33804. * @return the light or null if none found.
  33805. */
  33806. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33807. /**
  33808. * Gets a particle system by id
  33809. * @param id defines the particle system id
  33810. * @return the corresponding system or null if none found
  33811. */
  33812. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33813. /**
  33814. * Gets a geometry using its ID
  33815. * @param id defines the geometry's id
  33816. * @return the geometry or null if none found.
  33817. */
  33818. getGeometryByID(id: string): Nullable<Geometry>;
  33819. private _getGeometryByUniqueID;
  33820. /**
  33821. * Add a new geometry to this scene
  33822. * @param geometry defines the geometry to be added to the scene.
  33823. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33824. * @return a boolean defining if the geometry was added or not
  33825. */
  33826. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33827. /**
  33828. * Removes an existing geometry
  33829. * @param geometry defines the geometry to be removed from the scene
  33830. * @return a boolean defining if the geometry was removed or not
  33831. */
  33832. removeGeometry(geometry: Geometry): boolean;
  33833. /**
  33834. * Gets the list of geometries attached to the scene
  33835. * @returns an array of Geometry
  33836. */
  33837. getGeometries(): Geometry[];
  33838. /**
  33839. * Gets the first added mesh found of a given ID
  33840. * @param id defines the id to search for
  33841. * @return the mesh found or null if not found at all
  33842. */
  33843. getMeshByID(id: string): Nullable<AbstractMesh>;
  33844. /**
  33845. * Gets a list of meshes using their id
  33846. * @param id defines the id to search for
  33847. * @returns a list of meshes
  33848. */
  33849. getMeshesByID(id: string): Array<AbstractMesh>;
  33850. /**
  33851. * Gets the first added transform node found of a given ID
  33852. * @param id defines the id to search for
  33853. * @return the found transform node or null if not found at all.
  33854. */
  33855. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33856. /**
  33857. * Gets a transform node with its auto-generated unique id
  33858. * @param uniqueId efines the unique id to search for
  33859. * @return the found transform node or null if not found at all.
  33860. */
  33861. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33862. /**
  33863. * Gets a list of transform nodes using their id
  33864. * @param id defines the id to search for
  33865. * @returns a list of transform nodes
  33866. */
  33867. getTransformNodesByID(id: string): Array<TransformNode>;
  33868. /**
  33869. * Gets a mesh with its auto-generated unique id
  33870. * @param uniqueId defines the unique id to search for
  33871. * @return the found mesh or null if not found at all.
  33872. */
  33873. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33874. /**
  33875. * Gets a the last added mesh using a given id
  33876. * @param id defines the id to search for
  33877. * @return the found mesh or null if not found at all.
  33878. */
  33879. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33880. /**
  33881. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33882. * @param id defines the id to search for
  33883. * @return the found node or null if not found at all
  33884. */
  33885. getLastEntryByID(id: string): Nullable<Node>;
  33886. /**
  33887. * Gets a node (Mesh, Camera, Light) using a given id
  33888. * @param id defines the id to search for
  33889. * @return the found node or null if not found at all
  33890. */
  33891. getNodeByID(id: string): Nullable<Node>;
  33892. /**
  33893. * Gets a node (Mesh, Camera, Light) using a given name
  33894. * @param name defines the name to search for
  33895. * @return the found node or null if not found at all.
  33896. */
  33897. getNodeByName(name: string): Nullable<Node>;
  33898. /**
  33899. * Gets a mesh using a given name
  33900. * @param name defines the name to search for
  33901. * @return the found mesh or null if not found at all.
  33902. */
  33903. getMeshByName(name: string): Nullable<AbstractMesh>;
  33904. /**
  33905. * Gets a transform node using a given name
  33906. * @param name defines the name to search for
  33907. * @return the found transform node or null if not found at all.
  33908. */
  33909. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33910. /**
  33911. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33912. * @param id defines the id to search for
  33913. * @return the found skeleton or null if not found at all.
  33914. */
  33915. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33916. /**
  33917. * Gets a skeleton using a given auto generated unique id
  33918. * @param uniqueId defines the unique id to search for
  33919. * @return the found skeleton or null if not found at all.
  33920. */
  33921. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33922. /**
  33923. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33924. * @param id defines the id to search for
  33925. * @return the found skeleton or null if not found at all.
  33926. */
  33927. getSkeletonById(id: string): Nullable<Skeleton>;
  33928. /**
  33929. * Gets a skeleton using a given name
  33930. * @param name defines the name to search for
  33931. * @return the found skeleton or null if not found at all.
  33932. */
  33933. getSkeletonByName(name: string): Nullable<Skeleton>;
  33934. /**
  33935. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33936. * @param id defines the id to search for
  33937. * @return the found morph target manager or null if not found at all.
  33938. */
  33939. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33940. /**
  33941. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33942. * @param id defines the id to search for
  33943. * @return the found morph target or null if not found at all.
  33944. */
  33945. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33946. /**
  33947. * Gets a boolean indicating if the given mesh is active
  33948. * @param mesh defines the mesh to look for
  33949. * @returns true if the mesh is in the active list
  33950. */
  33951. isActiveMesh(mesh: AbstractMesh): boolean;
  33952. /**
  33953. * Return a unique id as a string which can serve as an identifier for the scene
  33954. */
  33955. readonly uid: string;
  33956. /**
  33957. * Add an externaly attached data from its key.
  33958. * This method call will fail and return false, if such key already exists.
  33959. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33960. * @param key the unique key that identifies the data
  33961. * @param data the data object to associate to the key for this Engine instance
  33962. * @return true if no such key were already present and the data was added successfully, false otherwise
  33963. */
  33964. addExternalData<T>(key: string, data: T): boolean;
  33965. /**
  33966. * Get an externaly attached data from its key
  33967. * @param key the unique key that identifies the data
  33968. * @return the associated data, if present (can be null), or undefined if not present
  33969. */
  33970. getExternalData<T>(key: string): Nullable<T>;
  33971. /**
  33972. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33973. * @param key the unique key that identifies the data
  33974. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33975. * @return the associated data, can be null if the factory returned null.
  33976. */
  33977. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33978. /**
  33979. * Remove an externaly attached data from the Engine instance
  33980. * @param key the unique key that identifies the data
  33981. * @return true if the data was successfully removed, false if it doesn't exist
  33982. */
  33983. removeExternalData(key: string): boolean;
  33984. private _evaluateSubMesh;
  33985. /**
  33986. * Clear the processed materials smart array preventing retention point in material dispose.
  33987. */
  33988. freeProcessedMaterials(): void;
  33989. private _preventFreeActiveMeshesAndRenderingGroups;
  33990. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33991. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33992. * when disposing several meshes in a row or a hierarchy of meshes.
  33993. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33994. */
  33995. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33996. /**
  33997. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33998. */
  33999. freeActiveMeshes(): void;
  34000. /**
  34001. * Clear the info related to rendering groups preventing retention points during dispose.
  34002. */
  34003. freeRenderingGroups(): void;
  34004. /** @hidden */
  34005. _isInIntermediateRendering(): boolean;
  34006. /**
  34007. * Lambda returning the list of potentially active meshes.
  34008. */
  34009. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34010. /**
  34011. * Lambda returning the list of potentially active sub meshes.
  34012. */
  34013. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34014. /**
  34015. * Lambda returning the list of potentially intersecting sub meshes.
  34016. */
  34017. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34018. /**
  34019. * Lambda returning the list of potentially colliding sub meshes.
  34020. */
  34021. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34022. private _activeMeshesFrozen;
  34023. /**
  34024. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34025. * @returns the current scene
  34026. */
  34027. freezeActiveMeshes(): Scene;
  34028. /**
  34029. * Use this function to restart evaluating active meshes on every frame
  34030. * @returns the current scene
  34031. */
  34032. unfreezeActiveMeshes(): Scene;
  34033. private _evaluateActiveMeshes;
  34034. private _activeMesh;
  34035. /**
  34036. * Update the transform matrix to update from the current active camera
  34037. * @param force defines a boolean used to force the update even if cache is up to date
  34038. */
  34039. updateTransformMatrix(force?: boolean): void;
  34040. private _bindFrameBuffer;
  34041. /** @hidden */
  34042. _allowPostProcessClearColor: boolean;
  34043. /** @hidden */
  34044. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34045. private _processSubCameras;
  34046. private _checkIntersections;
  34047. /** @hidden */
  34048. _advancePhysicsEngineStep(step: number): void;
  34049. /**
  34050. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34051. */
  34052. getDeterministicFrameTime: () => number;
  34053. /** @hidden */
  34054. _animate(): void;
  34055. /**
  34056. * Render the scene
  34057. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34058. */
  34059. render(updateCameras?: boolean): void;
  34060. /**
  34061. * Freeze all materials
  34062. * A frozen material will not be updatable but should be faster to render
  34063. */
  34064. freezeMaterials(): void;
  34065. /**
  34066. * Unfreeze all materials
  34067. * A frozen material will not be updatable but should be faster to render
  34068. */
  34069. unfreezeMaterials(): void;
  34070. /**
  34071. * Releases all held ressources
  34072. */
  34073. dispose(): void;
  34074. /**
  34075. * Gets if the scene is already disposed
  34076. */
  34077. readonly isDisposed: boolean;
  34078. /**
  34079. * Call this function to reduce memory footprint of the scene.
  34080. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34081. */
  34082. clearCachedVertexData(): void;
  34083. /**
  34084. * This function will remove the local cached buffer data from texture.
  34085. * It will save memory but will prevent the texture from being rebuilt
  34086. */
  34087. cleanCachedTextureBuffer(): void;
  34088. /**
  34089. * Get the world extend vectors with an optional filter
  34090. *
  34091. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34092. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34093. */
  34094. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34095. min: Vector3;
  34096. max: Vector3;
  34097. };
  34098. /**
  34099. * Creates a ray that can be used to pick in the scene
  34100. * @param x defines the x coordinate of the origin (on-screen)
  34101. * @param y defines the y coordinate of the origin (on-screen)
  34102. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34103. * @param camera defines the camera to use for the picking
  34104. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34105. * @returns a Ray
  34106. */
  34107. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34108. /**
  34109. * Creates a ray that can be used to pick in the scene
  34110. * @param x defines the x coordinate of the origin (on-screen)
  34111. * @param y defines the y coordinate of the origin (on-screen)
  34112. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34113. * @param result defines the ray where to store the picking ray
  34114. * @param camera defines the camera to use for the picking
  34115. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34116. * @returns the current scene
  34117. */
  34118. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34119. /**
  34120. * Creates a ray that can be used to pick in the scene
  34121. * @param x defines the x coordinate of the origin (on-screen)
  34122. * @param y defines the y coordinate of the origin (on-screen)
  34123. * @param camera defines the camera to use for the picking
  34124. * @returns a Ray
  34125. */
  34126. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34127. /**
  34128. * Creates a ray that can be used to pick in the scene
  34129. * @param x defines the x coordinate of the origin (on-screen)
  34130. * @param y defines the y coordinate of the origin (on-screen)
  34131. * @param result defines the ray where to store the picking ray
  34132. * @param camera defines the camera to use for the picking
  34133. * @returns the current scene
  34134. */
  34135. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34136. /** Launch a ray to try to pick a mesh in the scene
  34137. * @param x position on screen
  34138. * @param y position on screen
  34139. * @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
  34140. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34141. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34143. * @returns a PickingInfo
  34144. */
  34145. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34146. /** Use the given ray to pick a mesh in the scene
  34147. * @param ray The ray to use to pick meshes
  34148. * @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
  34149. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34150. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34151. * @returns a PickingInfo
  34152. */
  34153. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34154. /**
  34155. * Launch a ray to try to pick a mesh in the scene
  34156. * @param x X position on screen
  34157. * @param y Y position on screen
  34158. * @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
  34159. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34160. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34161. * @returns an array of PickingInfo
  34162. */
  34163. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34164. /**
  34165. * Launch a ray to try to pick a mesh in the scene
  34166. * @param ray Ray to use
  34167. * @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
  34168. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34169. * @returns an array of PickingInfo
  34170. */
  34171. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34172. /**
  34173. * Force the value of meshUnderPointer
  34174. * @param mesh defines the mesh to use
  34175. */
  34176. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34177. /**
  34178. * Gets the mesh under the pointer
  34179. * @returns a Mesh or null if no mesh is under the pointer
  34180. */
  34181. getPointerOverMesh(): Nullable<AbstractMesh>;
  34182. /** @hidden */
  34183. _rebuildGeometries(): void;
  34184. /** @hidden */
  34185. _rebuildTextures(): void;
  34186. private _getByTags;
  34187. /**
  34188. * Get a list of meshes by tags
  34189. * @param tagsQuery defines the tags query to use
  34190. * @param forEach defines a predicate used to filter results
  34191. * @returns an array of Mesh
  34192. */
  34193. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34194. /**
  34195. * Get a list of cameras by tags
  34196. * @param tagsQuery defines the tags query to use
  34197. * @param forEach defines a predicate used to filter results
  34198. * @returns an array of Camera
  34199. */
  34200. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34201. /**
  34202. * Get a list of lights by tags
  34203. * @param tagsQuery defines the tags query to use
  34204. * @param forEach defines a predicate used to filter results
  34205. * @returns an array of Light
  34206. */
  34207. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34208. /**
  34209. * Get a list of materials by tags
  34210. * @param tagsQuery defines the tags query to use
  34211. * @param forEach defines a predicate used to filter results
  34212. * @returns an array of Material
  34213. */
  34214. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34215. /**
  34216. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34217. * This allowed control for front to back rendering or reversly depending of the special needs.
  34218. *
  34219. * @param renderingGroupId The rendering group id corresponding to its index
  34220. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34221. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34222. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34223. */
  34224. 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;
  34225. /**
  34226. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34227. *
  34228. * @param renderingGroupId The rendering group id corresponding to its index
  34229. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34230. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34231. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34232. */
  34233. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34234. /**
  34235. * Gets the current auto clear configuration for one rendering group of the rendering
  34236. * manager.
  34237. * @param index the rendering group index to get the information for
  34238. * @returns The auto clear setup for the requested rendering group
  34239. */
  34240. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34241. private _blockMaterialDirtyMechanism;
  34242. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34243. blockMaterialDirtyMechanism: boolean;
  34244. /**
  34245. * Will flag all materials as dirty to trigger new shader compilation
  34246. * @param flag defines the flag used to specify which material part must be marked as dirty
  34247. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34248. */
  34249. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34250. /** @hidden */
  34251. _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;
  34252. /** @hidden */
  34253. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34254. }
  34255. }
  34256. declare module "babylonjs/assetContainer" {
  34257. import { AbstractScene } from "babylonjs/abstractScene";
  34258. import { Scene } from "babylonjs/scene";
  34259. import { Mesh } from "babylonjs/Meshes/mesh";
  34260. /**
  34261. * Set of assets to keep when moving a scene into an asset container.
  34262. */
  34263. export class KeepAssets extends AbstractScene {
  34264. }
  34265. /**
  34266. * Container with a set of assets that can be added or removed from a scene.
  34267. */
  34268. export class AssetContainer extends AbstractScene {
  34269. /**
  34270. * The scene the AssetContainer belongs to.
  34271. */
  34272. scene: Scene;
  34273. /**
  34274. * Instantiates an AssetContainer.
  34275. * @param scene The scene the AssetContainer belongs to.
  34276. */
  34277. constructor(scene: Scene);
  34278. /**
  34279. * Adds all the assets from the container to the scene.
  34280. */
  34281. addAllToScene(): void;
  34282. /**
  34283. * Removes all the assets in the container from the scene
  34284. */
  34285. removeAllFromScene(): void;
  34286. /**
  34287. * Disposes all the assets in the container
  34288. */
  34289. dispose(): void;
  34290. private _moveAssets;
  34291. /**
  34292. * Removes all the assets contained in the scene and adds them to the container.
  34293. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34294. */
  34295. moveAllFromScene(keepAssets?: KeepAssets): void;
  34296. /**
  34297. * 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.
  34298. * @returns the root mesh
  34299. */
  34300. createRootMesh(): Mesh;
  34301. }
  34302. }
  34303. declare module "babylonjs/abstractScene" {
  34304. import { Scene } from "babylonjs/scene";
  34305. import { Nullable } from "babylonjs/types";
  34306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34307. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34308. import { Geometry } from "babylonjs/Meshes/geometry";
  34309. import { Skeleton } from "babylonjs/Bones/skeleton";
  34310. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34311. import { AssetContainer } from "babylonjs/assetContainer";
  34312. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34313. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34315. import { Material } from "babylonjs/Materials/material";
  34316. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34317. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34318. import { Camera } from "babylonjs/Cameras/camera";
  34319. import { Light } from "babylonjs/Lights/light";
  34320. import { Node } from "babylonjs/node";
  34321. import { Animation } from "babylonjs/Animations/animation";
  34322. /**
  34323. * Defines how the parser contract is defined.
  34324. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34325. */
  34326. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34327. /**
  34328. * Defines how the individual parser contract is defined.
  34329. * These parser can parse an individual asset
  34330. */
  34331. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34332. /**
  34333. * Base class of the scene acting as a container for the different elements composing a scene.
  34334. * This class is dynamically extended by the different components of the scene increasing
  34335. * flexibility and reducing coupling
  34336. */
  34337. export abstract class AbstractScene {
  34338. /**
  34339. * Stores the list of available parsers in the application.
  34340. */
  34341. private static _BabylonFileParsers;
  34342. /**
  34343. * Stores the list of available individual parsers in the application.
  34344. */
  34345. private static _IndividualBabylonFileParsers;
  34346. /**
  34347. * Adds a parser in the list of available ones
  34348. * @param name Defines the name of the parser
  34349. * @param parser Defines the parser to add
  34350. */
  34351. static AddParser(name: string, parser: BabylonFileParser): void;
  34352. /**
  34353. * Gets a general parser from the list of avaialble ones
  34354. * @param name Defines the name of the parser
  34355. * @returns the requested parser or null
  34356. */
  34357. static GetParser(name: string): Nullable<BabylonFileParser>;
  34358. /**
  34359. * Adds n individual parser in the list of available ones
  34360. * @param name Defines the name of the parser
  34361. * @param parser Defines the parser to add
  34362. */
  34363. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34364. /**
  34365. * Gets an individual parser from the list of avaialble ones
  34366. * @param name Defines the name of the parser
  34367. * @returns the requested parser or null
  34368. */
  34369. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34370. /**
  34371. * Parser json data and populate both a scene and its associated container object
  34372. * @param jsonData Defines the data to parse
  34373. * @param scene Defines the scene to parse the data for
  34374. * @param container Defines the container attached to the parsing sequence
  34375. * @param rootUrl Defines the root url of the data
  34376. */
  34377. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34378. /**
  34379. * Gets the list of root nodes (ie. nodes with no parent)
  34380. */
  34381. rootNodes: Node[];
  34382. /** All of the cameras added to this scene
  34383. * @see http://doc.babylonjs.com/babylon101/cameras
  34384. */
  34385. cameras: Camera[];
  34386. /**
  34387. * All of the lights added to this scene
  34388. * @see http://doc.babylonjs.com/babylon101/lights
  34389. */
  34390. lights: Light[];
  34391. /**
  34392. * All of the (abstract) meshes added to this scene
  34393. */
  34394. meshes: AbstractMesh[];
  34395. /**
  34396. * The list of skeletons added to the scene
  34397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34398. */
  34399. skeletons: Skeleton[];
  34400. /**
  34401. * All of the particle systems added to this scene
  34402. * @see http://doc.babylonjs.com/babylon101/particles
  34403. */
  34404. particleSystems: IParticleSystem[];
  34405. /**
  34406. * Gets a list of Animations associated with the scene
  34407. */
  34408. animations: Animation[];
  34409. /**
  34410. * All of the animation groups added to this scene
  34411. * @see http://doc.babylonjs.com/how_to/group
  34412. */
  34413. animationGroups: AnimationGroup[];
  34414. /**
  34415. * All of the multi-materials added to this scene
  34416. * @see http://doc.babylonjs.com/how_to/multi_materials
  34417. */
  34418. multiMaterials: MultiMaterial[];
  34419. /**
  34420. * All of the materials added to this scene
  34421. * In the context of a Scene, it is not supposed to be modified manually.
  34422. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34423. * Note also that the order of the Material wihin the array is not significant and might change.
  34424. * @see http://doc.babylonjs.com/babylon101/materials
  34425. */
  34426. materials: Material[];
  34427. /**
  34428. * The list of morph target managers added to the scene
  34429. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34430. */
  34431. morphTargetManagers: MorphTargetManager[];
  34432. /**
  34433. * The list of geometries used in the scene.
  34434. */
  34435. geometries: Geometry[];
  34436. /**
  34437. * All of the tranform nodes added to this scene
  34438. * In the context of a Scene, it is not supposed to be modified manually.
  34439. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34440. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34441. * @see http://doc.babylonjs.com/how_to/transformnode
  34442. */
  34443. transformNodes: TransformNode[];
  34444. /**
  34445. * ActionManagers available on the scene.
  34446. */
  34447. actionManagers: AbstractActionManager[];
  34448. /**
  34449. * Textures to keep.
  34450. */
  34451. textures: BaseTexture[];
  34452. /**
  34453. * Environment texture for the scene
  34454. */
  34455. environmentTexture: Nullable<BaseTexture>;
  34456. }
  34457. }
  34458. declare module "babylonjs/Audio/sound" {
  34459. import { Observable } from "babylonjs/Misc/observable";
  34460. import { Vector3 } from "babylonjs/Maths/math";
  34461. import { Nullable } from "babylonjs/types";
  34462. import { Scene } from "babylonjs/scene";
  34463. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34464. /**
  34465. * Defines a sound that can be played in the application.
  34466. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34468. */
  34469. export class Sound {
  34470. /**
  34471. * The name of the sound in the scene.
  34472. */
  34473. name: string;
  34474. /**
  34475. * Does the sound autoplay once loaded.
  34476. */
  34477. autoplay: boolean;
  34478. /**
  34479. * Does the sound loop after it finishes playing once.
  34480. */
  34481. loop: boolean;
  34482. /**
  34483. * Does the sound use a custom attenuation curve to simulate the falloff
  34484. * happening when the source gets further away from the camera.
  34485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34486. */
  34487. useCustomAttenuation: boolean;
  34488. /**
  34489. * The sound track id this sound belongs to.
  34490. */
  34491. soundTrackId: number;
  34492. /**
  34493. * Is this sound currently played.
  34494. */
  34495. isPlaying: boolean;
  34496. /**
  34497. * Is this sound currently paused.
  34498. */
  34499. isPaused: boolean;
  34500. /**
  34501. * Does this sound enables spatial sound.
  34502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34503. */
  34504. spatialSound: boolean;
  34505. /**
  34506. * Define the reference distance the sound should be heard perfectly.
  34507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34508. */
  34509. refDistance: number;
  34510. /**
  34511. * Define the roll off factor of spatial sounds.
  34512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34513. */
  34514. rolloffFactor: number;
  34515. /**
  34516. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34518. */
  34519. maxDistance: number;
  34520. /**
  34521. * Define the distance attenuation model the sound will follow.
  34522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34523. */
  34524. distanceModel: string;
  34525. /**
  34526. * @hidden
  34527. * Back Compat
  34528. **/
  34529. onended: () => any;
  34530. /**
  34531. * Observable event when the current playing sound finishes.
  34532. */
  34533. onEndedObservable: Observable<Sound>;
  34534. private _panningModel;
  34535. private _playbackRate;
  34536. private _streaming;
  34537. private _startTime;
  34538. private _startOffset;
  34539. private _position;
  34540. /** @hidden */
  34541. _positionInEmitterSpace: boolean;
  34542. private _localDirection;
  34543. private _volume;
  34544. private _isReadyToPlay;
  34545. private _isDirectional;
  34546. private _readyToPlayCallback;
  34547. private _audioBuffer;
  34548. private _soundSource;
  34549. private _streamingSource;
  34550. private _soundPanner;
  34551. private _soundGain;
  34552. private _inputAudioNode;
  34553. private _outputAudioNode;
  34554. private _coneInnerAngle;
  34555. private _coneOuterAngle;
  34556. private _coneOuterGain;
  34557. private _scene;
  34558. private _connectedTransformNode;
  34559. private _customAttenuationFunction;
  34560. private _registerFunc;
  34561. private _isOutputConnected;
  34562. private _htmlAudioElement;
  34563. private _urlType;
  34564. /** @hidden */
  34565. static _SceneComponentInitialization: (scene: Scene) => void;
  34566. /**
  34567. * Create a sound and attach it to a scene
  34568. * @param name Name of your sound
  34569. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34570. * @param scene defines the scene the sound belongs to
  34571. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34572. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34573. */
  34574. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34575. /**
  34576. * Release the sound and its associated resources
  34577. */
  34578. dispose(): void;
  34579. /**
  34580. * Gets if the sounds is ready to be played or not.
  34581. * @returns true if ready, otherwise false
  34582. */
  34583. isReady(): boolean;
  34584. private _soundLoaded;
  34585. /**
  34586. * Sets the data of the sound from an audiobuffer
  34587. * @param audioBuffer The audioBuffer containing the data
  34588. */
  34589. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34590. /**
  34591. * Updates the current sounds options such as maxdistance, loop...
  34592. * @param options A JSON object containing values named as the object properties
  34593. */
  34594. updateOptions(options: any): void;
  34595. private _createSpatialParameters;
  34596. private _updateSpatialParameters;
  34597. /**
  34598. * Switch the panning model to HRTF:
  34599. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34601. */
  34602. switchPanningModelToHRTF(): void;
  34603. /**
  34604. * Switch the panning model to Equal Power:
  34605. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34607. */
  34608. switchPanningModelToEqualPower(): void;
  34609. private _switchPanningModel;
  34610. /**
  34611. * Connect this sound to a sound track audio node like gain...
  34612. * @param soundTrackAudioNode the sound track audio node to connect to
  34613. */
  34614. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34615. /**
  34616. * Transform this sound into a directional source
  34617. * @param coneInnerAngle Size of the inner cone in degree
  34618. * @param coneOuterAngle Size of the outer cone in degree
  34619. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34620. */
  34621. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34622. /**
  34623. * Gets or sets the inner angle for the directional cone.
  34624. */
  34625. /**
  34626. * Gets or sets the inner angle for the directional cone.
  34627. */
  34628. directionalConeInnerAngle: number;
  34629. /**
  34630. * Gets or sets the outer angle for the directional cone.
  34631. */
  34632. /**
  34633. * Gets or sets the outer angle for the directional cone.
  34634. */
  34635. directionalConeOuterAngle: number;
  34636. /**
  34637. * Sets the position of the emitter if spatial sound is enabled
  34638. * @param newPosition Defines the new posisiton
  34639. */
  34640. setPosition(newPosition: Vector3): void;
  34641. /**
  34642. * Sets the local direction of the emitter if spatial sound is enabled
  34643. * @param newLocalDirection Defines the new local direction
  34644. */
  34645. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34646. private _updateDirection;
  34647. /** @hidden */
  34648. updateDistanceFromListener(): void;
  34649. /**
  34650. * Sets a new custom attenuation function for the sound.
  34651. * @param callback Defines the function used for the attenuation
  34652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34653. */
  34654. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34655. /**
  34656. * Play the sound
  34657. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34658. * @param offset (optional) Start the sound setting it at a specific time
  34659. */
  34660. play(time?: number, offset?: number): void;
  34661. private _onended;
  34662. /**
  34663. * Stop the sound
  34664. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34665. */
  34666. stop(time?: number): void;
  34667. /**
  34668. * Put the sound in pause
  34669. */
  34670. pause(): void;
  34671. /**
  34672. * Sets a dedicated volume for this sounds
  34673. * @param newVolume Define the new volume of the sound
  34674. * @param time Define in how long the sound should be at this value
  34675. */
  34676. setVolume(newVolume: number, time?: number): void;
  34677. /**
  34678. * Set the sound play back rate
  34679. * @param newPlaybackRate Define the playback rate the sound should be played at
  34680. */
  34681. setPlaybackRate(newPlaybackRate: number): void;
  34682. /**
  34683. * Gets the volume of the sound.
  34684. * @returns the volume of the sound
  34685. */
  34686. getVolume(): number;
  34687. /**
  34688. * Attach the sound to a dedicated mesh
  34689. * @param transformNode The transform node to connect the sound with
  34690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34691. */
  34692. attachToMesh(transformNode: TransformNode): void;
  34693. /**
  34694. * Detach the sound from the previously attached mesh
  34695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34696. */
  34697. detachFromMesh(): void;
  34698. private _onRegisterAfterWorldMatrixUpdate;
  34699. /**
  34700. * Clone the current sound in the scene.
  34701. * @returns the new sound clone
  34702. */
  34703. clone(): Nullable<Sound>;
  34704. /**
  34705. * Gets the current underlying audio buffer containing the data
  34706. * @returns the audio buffer
  34707. */
  34708. getAudioBuffer(): Nullable<AudioBuffer>;
  34709. /**
  34710. * Serializes the Sound in a JSON representation
  34711. * @returns the JSON representation of the sound
  34712. */
  34713. serialize(): any;
  34714. /**
  34715. * Parse a JSON representation of a sound to innstantiate in a given scene
  34716. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34717. * @param scene Define the scene the new parsed sound should be created in
  34718. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34719. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34720. * @returns the newly parsed sound
  34721. */
  34722. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34723. }
  34724. }
  34725. declare module "babylonjs/Actions/directAudioActions" {
  34726. import { Action } from "babylonjs/Actions/action";
  34727. import { Condition } from "babylonjs/Actions/condition";
  34728. import { Sound } from "babylonjs/Audio/sound";
  34729. /**
  34730. * This defines an action helpful to play a defined sound on a triggered action.
  34731. */
  34732. export class PlaySoundAction extends Action {
  34733. private _sound;
  34734. /**
  34735. * Instantiate the action
  34736. * @param triggerOptions defines the trigger options
  34737. * @param sound defines the sound to play
  34738. * @param condition defines the trigger related conditions
  34739. */
  34740. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34741. /** @hidden */
  34742. _prepare(): void;
  34743. /**
  34744. * Execute the action and play the sound.
  34745. */
  34746. execute(): void;
  34747. /**
  34748. * Serializes the actions and its related information.
  34749. * @param parent defines the object to serialize in
  34750. * @returns the serialized object
  34751. */
  34752. serialize(parent: any): any;
  34753. }
  34754. /**
  34755. * This defines an action helpful to stop a defined sound on a triggered action.
  34756. */
  34757. export class StopSoundAction extends Action {
  34758. private _sound;
  34759. /**
  34760. * Instantiate the action
  34761. * @param triggerOptions defines the trigger options
  34762. * @param sound defines the sound to stop
  34763. * @param condition defines the trigger related conditions
  34764. */
  34765. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34766. /** @hidden */
  34767. _prepare(): void;
  34768. /**
  34769. * Execute the action and stop the sound.
  34770. */
  34771. execute(): void;
  34772. /**
  34773. * Serializes the actions and its related information.
  34774. * @param parent defines the object to serialize in
  34775. * @returns the serialized object
  34776. */
  34777. serialize(parent: any): any;
  34778. }
  34779. }
  34780. declare module "babylonjs/Actions/interpolateValueAction" {
  34781. import { Action } from "babylonjs/Actions/action";
  34782. import { Condition } from "babylonjs/Actions/condition";
  34783. import { Observable } from "babylonjs/Misc/observable";
  34784. /**
  34785. * This defines an action responsible to change the value of a property
  34786. * by interpolating between its current value and the newly set one once triggered.
  34787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34788. */
  34789. export class InterpolateValueAction extends Action {
  34790. /**
  34791. * Defines the path of the property where the value should be interpolated
  34792. */
  34793. propertyPath: string;
  34794. /**
  34795. * Defines the target value at the end of the interpolation.
  34796. */
  34797. value: any;
  34798. /**
  34799. * Defines the time it will take for the property to interpolate to the value.
  34800. */
  34801. duration: number;
  34802. /**
  34803. * Defines if the other scene animations should be stopped when the action has been triggered
  34804. */
  34805. stopOtherAnimations?: boolean;
  34806. /**
  34807. * Defines a callback raised once the interpolation animation has been done.
  34808. */
  34809. onInterpolationDone?: () => void;
  34810. /**
  34811. * Observable triggered once the interpolation animation has been done.
  34812. */
  34813. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34814. private _target;
  34815. private _effectiveTarget;
  34816. private _property;
  34817. /**
  34818. * Instantiate the action
  34819. * @param triggerOptions defines the trigger options
  34820. * @param target defines the object containing the value to interpolate
  34821. * @param propertyPath defines the path to the property in the target object
  34822. * @param value defines the target value at the end of the interpolation
  34823. * @param duration deines the time it will take for the property to interpolate to the value.
  34824. * @param condition defines the trigger related conditions
  34825. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34826. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34827. */
  34828. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34829. /** @hidden */
  34830. _prepare(): void;
  34831. /**
  34832. * Execute the action starts the value interpolation.
  34833. */
  34834. execute(): void;
  34835. /**
  34836. * Serializes the actions and its related information.
  34837. * @param parent defines the object to serialize in
  34838. * @returns the serialized object
  34839. */
  34840. serialize(parent: any): any;
  34841. }
  34842. }
  34843. declare module "babylonjs/Actions/index" {
  34844. export * from "babylonjs/Actions/action";
  34845. export * from "babylonjs/Actions/actionEvent";
  34846. export * from "babylonjs/Actions/actionManager";
  34847. export * from "babylonjs/Actions/condition";
  34848. export * from "babylonjs/Actions/directActions";
  34849. export * from "babylonjs/Actions/directAudioActions";
  34850. export * from "babylonjs/Actions/interpolateValueAction";
  34851. }
  34852. declare module "babylonjs/Animations/index" {
  34853. export * from "babylonjs/Animations/animatable";
  34854. export * from "babylonjs/Animations/animation";
  34855. export * from "babylonjs/Animations/animationGroup";
  34856. export * from "babylonjs/Animations/animationPropertiesOverride";
  34857. export * from "babylonjs/Animations/easing";
  34858. export * from "babylonjs/Animations/runtimeAnimation";
  34859. export * from "babylonjs/Animations/animationEvent";
  34860. export * from "babylonjs/Animations/animationGroup";
  34861. export * from "babylonjs/Animations/animationKey";
  34862. export * from "babylonjs/Animations/animationRange";
  34863. }
  34864. declare module "babylonjs/Audio/soundTrack" {
  34865. import { Sound } from "babylonjs/Audio/sound";
  34866. import { Analyser } from "babylonjs/Audio/analyser";
  34867. import { Scene } from "babylonjs/scene";
  34868. /**
  34869. * Options allowed during the creation of a sound track.
  34870. */
  34871. export interface ISoundTrackOptions {
  34872. /**
  34873. * The volume the sound track should take during creation
  34874. */
  34875. volume?: number;
  34876. /**
  34877. * Define if the sound track is the main sound track of the scene
  34878. */
  34879. mainTrack?: boolean;
  34880. }
  34881. /**
  34882. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34883. * It will be also used in a future release to apply effects on a specific track.
  34884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34885. */
  34886. export class SoundTrack {
  34887. /**
  34888. * The unique identifier of the sound track in the scene.
  34889. */
  34890. id: number;
  34891. /**
  34892. * The list of sounds included in the sound track.
  34893. */
  34894. soundCollection: Array<Sound>;
  34895. private _outputAudioNode;
  34896. private _scene;
  34897. private _isMainTrack;
  34898. private _connectedAnalyser;
  34899. private _options;
  34900. private _isInitialized;
  34901. /**
  34902. * Creates a new sound track.
  34903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34904. * @param scene Define the scene the sound track belongs to
  34905. * @param options
  34906. */
  34907. constructor(scene: Scene, options?: ISoundTrackOptions);
  34908. private _initializeSoundTrackAudioGraph;
  34909. /**
  34910. * Release the sound track and its associated resources
  34911. */
  34912. dispose(): void;
  34913. /**
  34914. * Adds a sound to this sound track
  34915. * @param sound define the cound to add
  34916. * @ignoreNaming
  34917. */
  34918. AddSound(sound: Sound): void;
  34919. /**
  34920. * Removes a sound to this sound track
  34921. * @param sound define the cound to remove
  34922. * @ignoreNaming
  34923. */
  34924. RemoveSound(sound: Sound): void;
  34925. /**
  34926. * Set a global volume for the full sound track.
  34927. * @param newVolume Define the new volume of the sound track
  34928. */
  34929. setVolume(newVolume: number): void;
  34930. /**
  34931. * Switch the panning model to HRTF:
  34932. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34934. */
  34935. switchPanningModelToHRTF(): void;
  34936. /**
  34937. * Switch the panning model to Equal Power:
  34938. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34940. */
  34941. switchPanningModelToEqualPower(): void;
  34942. /**
  34943. * Connect the sound track to an audio analyser allowing some amazing
  34944. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34946. * @param analyser The analyser to connect to the engine
  34947. */
  34948. connectToAnalyser(analyser: Analyser): void;
  34949. }
  34950. }
  34951. declare module "babylonjs/Audio/audioSceneComponent" {
  34952. import { Sound } from "babylonjs/Audio/sound";
  34953. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34954. import { Nullable } from "babylonjs/types";
  34955. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34956. import { Scene } from "babylonjs/scene";
  34957. import { AbstractScene } from "babylonjs/abstractScene";
  34958. module "babylonjs/abstractScene" {
  34959. interface AbstractScene {
  34960. /**
  34961. * The list of sounds used in the scene.
  34962. */
  34963. sounds: Nullable<Array<Sound>>;
  34964. }
  34965. }
  34966. module "babylonjs/scene" {
  34967. interface Scene {
  34968. /**
  34969. * @hidden
  34970. * Backing field
  34971. */
  34972. _mainSoundTrack: SoundTrack;
  34973. /**
  34974. * The main sound track played by the scene.
  34975. * It cotains your primary collection of sounds.
  34976. */
  34977. mainSoundTrack: SoundTrack;
  34978. /**
  34979. * The list of sound tracks added to the scene
  34980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34981. */
  34982. soundTracks: Nullable<Array<SoundTrack>>;
  34983. /**
  34984. * Gets a sound using a given name
  34985. * @param name defines the name to search for
  34986. * @return the found sound or null if not found at all.
  34987. */
  34988. getSoundByName(name: string): Nullable<Sound>;
  34989. /**
  34990. * Gets or sets if audio support is enabled
  34991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34992. */
  34993. audioEnabled: boolean;
  34994. /**
  34995. * Gets or sets if audio will be output to headphones
  34996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34997. */
  34998. headphone: boolean;
  34999. }
  35000. }
  35001. /**
  35002. * Defines the sound scene component responsible to manage any sounds
  35003. * in a given scene.
  35004. */
  35005. export class AudioSceneComponent implements ISceneSerializableComponent {
  35006. /**
  35007. * The component name helpfull to identify the component in the list of scene components.
  35008. */
  35009. readonly name: string;
  35010. /**
  35011. * The scene the component belongs to.
  35012. */
  35013. scene: Scene;
  35014. private _audioEnabled;
  35015. /**
  35016. * Gets whether audio is enabled or not.
  35017. * Please use related enable/disable method to switch state.
  35018. */
  35019. readonly audioEnabled: boolean;
  35020. private _headphone;
  35021. /**
  35022. * Gets whether audio is outputing to headphone or not.
  35023. * Please use the according Switch methods to change output.
  35024. */
  35025. readonly headphone: boolean;
  35026. /**
  35027. * Creates a new instance of the component for the given scene
  35028. * @param scene Defines the scene to register the component in
  35029. */
  35030. constructor(scene: Scene);
  35031. /**
  35032. * Registers the component in a given scene
  35033. */
  35034. register(): void;
  35035. /**
  35036. * Rebuilds the elements related to this component in case of
  35037. * context lost for instance.
  35038. */
  35039. rebuild(): void;
  35040. /**
  35041. * Serializes the component data to the specified json object
  35042. * @param serializationObject The object to serialize to
  35043. */
  35044. serialize(serializationObject: any): void;
  35045. /**
  35046. * Adds all the element from the container to the scene
  35047. * @param container the container holding the elements
  35048. */
  35049. addFromContainer(container: AbstractScene): void;
  35050. /**
  35051. * Removes all the elements in the container from the scene
  35052. * @param container contains the elements to remove
  35053. * @param dispose if the removed element should be disposed (default: false)
  35054. */
  35055. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35056. /**
  35057. * Disposes the component and the associated ressources.
  35058. */
  35059. dispose(): void;
  35060. /**
  35061. * Disables audio in the associated scene.
  35062. */
  35063. disableAudio(): void;
  35064. /**
  35065. * Enables audio in the associated scene.
  35066. */
  35067. enableAudio(): void;
  35068. /**
  35069. * Switch audio to headphone output.
  35070. */
  35071. switchAudioModeForHeadphones(): void;
  35072. /**
  35073. * Switch audio to normal speakers.
  35074. */
  35075. switchAudioModeForNormalSpeakers(): void;
  35076. private _afterRender;
  35077. }
  35078. }
  35079. declare module "babylonjs/Audio/weightedsound" {
  35080. import { Sound } from "babylonjs/Audio/sound";
  35081. /**
  35082. * Wraps one or more Sound objects and selects one with random weight for playback.
  35083. */
  35084. export class WeightedSound {
  35085. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35086. loop: boolean;
  35087. private _coneInnerAngle;
  35088. private _coneOuterAngle;
  35089. private _volume;
  35090. /** A Sound is currently playing. */
  35091. isPlaying: boolean;
  35092. /** A Sound is currently paused. */
  35093. isPaused: boolean;
  35094. private _sounds;
  35095. private _weights;
  35096. private _currentIndex?;
  35097. /**
  35098. * Creates a new WeightedSound from the list of sounds given.
  35099. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35100. * @param sounds Array of Sounds that will be selected from.
  35101. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35102. */
  35103. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35104. /**
  35105. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35106. */
  35107. /**
  35108. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35109. */
  35110. directionalConeInnerAngle: number;
  35111. /**
  35112. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35113. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35114. */
  35115. /**
  35116. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35117. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35118. */
  35119. directionalConeOuterAngle: number;
  35120. /**
  35121. * Playback volume.
  35122. */
  35123. /**
  35124. * Playback volume.
  35125. */
  35126. volume: number;
  35127. private _onended;
  35128. /**
  35129. * Suspend playback
  35130. */
  35131. pause(): void;
  35132. /**
  35133. * Stop playback
  35134. */
  35135. stop(): void;
  35136. /**
  35137. * Start playback.
  35138. * @param startOffset Position the clip head at a specific time in seconds.
  35139. */
  35140. play(startOffset?: number): void;
  35141. }
  35142. }
  35143. declare module "babylonjs/Audio/index" {
  35144. export * from "babylonjs/Audio/analyser";
  35145. export * from "babylonjs/Audio/audioEngine";
  35146. export * from "babylonjs/Audio/audioSceneComponent";
  35147. export * from "babylonjs/Audio/sound";
  35148. export * from "babylonjs/Audio/soundTrack";
  35149. export * from "babylonjs/Audio/weightedsound";
  35150. }
  35151. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35152. import { Behavior } from "babylonjs/Behaviors/behavior";
  35153. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35154. import { BackEase } from "babylonjs/Animations/easing";
  35155. /**
  35156. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35158. */
  35159. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35160. /**
  35161. * Gets the name of the behavior.
  35162. */
  35163. readonly name: string;
  35164. /**
  35165. * The easing function used by animations
  35166. */
  35167. static EasingFunction: BackEase;
  35168. /**
  35169. * The easing mode used by animations
  35170. */
  35171. static EasingMode: number;
  35172. /**
  35173. * The duration of the animation, in milliseconds
  35174. */
  35175. transitionDuration: number;
  35176. /**
  35177. * Length of the distance animated by the transition when lower radius is reached
  35178. */
  35179. lowerRadiusTransitionRange: number;
  35180. /**
  35181. * Length of the distance animated by the transition when upper radius is reached
  35182. */
  35183. upperRadiusTransitionRange: number;
  35184. private _autoTransitionRange;
  35185. /**
  35186. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35187. */
  35188. /**
  35189. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35190. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35191. */
  35192. autoTransitionRange: boolean;
  35193. private _attachedCamera;
  35194. private _onAfterCheckInputsObserver;
  35195. private _onMeshTargetChangedObserver;
  35196. /**
  35197. * Initializes the behavior.
  35198. */
  35199. init(): void;
  35200. /**
  35201. * Attaches the behavior to its arc rotate camera.
  35202. * @param camera Defines the camera to attach the behavior to
  35203. */
  35204. attach(camera: ArcRotateCamera): void;
  35205. /**
  35206. * Detaches the behavior from its current arc rotate camera.
  35207. */
  35208. detach(): void;
  35209. private _radiusIsAnimating;
  35210. private _radiusBounceTransition;
  35211. private _animatables;
  35212. private _cachedWheelPrecision;
  35213. /**
  35214. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35215. * @param radiusLimit The limit to check against.
  35216. * @return Bool to indicate if at limit.
  35217. */
  35218. private _isRadiusAtLimit;
  35219. /**
  35220. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35221. * @param radiusDelta The delta by which to animate to. Can be negative.
  35222. */
  35223. private _applyBoundRadiusAnimation;
  35224. /**
  35225. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35226. */
  35227. protected _clearAnimationLocks(): void;
  35228. /**
  35229. * Stops and removes all animations that have been applied to the camera
  35230. */
  35231. stopAllAnimations(): void;
  35232. }
  35233. }
  35234. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35235. import { Behavior } from "babylonjs/Behaviors/behavior";
  35236. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35237. import { ExponentialEase } from "babylonjs/Animations/easing";
  35238. import { Nullable } from "babylonjs/types";
  35239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35240. import { Vector3 } from "babylonjs/Maths/math";
  35241. /**
  35242. * 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.
  35243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35244. */
  35245. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35246. /**
  35247. * Gets the name of the behavior.
  35248. */
  35249. readonly name: string;
  35250. private _mode;
  35251. private _radiusScale;
  35252. private _positionScale;
  35253. private _defaultElevation;
  35254. private _elevationReturnTime;
  35255. private _elevationReturnWaitTime;
  35256. private _zoomStopsAnimation;
  35257. private _framingTime;
  35258. /**
  35259. * The easing function used by animations
  35260. */
  35261. static EasingFunction: ExponentialEase;
  35262. /**
  35263. * The easing mode used by animations
  35264. */
  35265. static EasingMode: number;
  35266. /**
  35267. * Sets the current mode used by the behavior
  35268. */
  35269. /**
  35270. * Gets current mode used by the behavior.
  35271. */
  35272. mode: number;
  35273. /**
  35274. * Sets the scale applied to the radius (1 by default)
  35275. */
  35276. /**
  35277. * Gets the scale applied to the radius
  35278. */
  35279. radiusScale: number;
  35280. /**
  35281. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35282. */
  35283. /**
  35284. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35285. */
  35286. positionScale: number;
  35287. /**
  35288. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35289. * behaviour is triggered, in radians.
  35290. */
  35291. /**
  35292. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35293. * behaviour is triggered, in radians.
  35294. */
  35295. defaultElevation: number;
  35296. /**
  35297. * Sets the time (in milliseconds) taken to return to the default beta position.
  35298. * Negative value indicates camera should not return to default.
  35299. */
  35300. /**
  35301. * Gets the time (in milliseconds) taken to return to the default beta position.
  35302. * Negative value indicates camera should not return to default.
  35303. */
  35304. elevationReturnTime: number;
  35305. /**
  35306. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35307. */
  35308. /**
  35309. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35310. */
  35311. elevationReturnWaitTime: number;
  35312. /**
  35313. * Sets the flag that indicates if user zooming should stop animation.
  35314. */
  35315. /**
  35316. * Gets the flag that indicates if user zooming should stop animation.
  35317. */
  35318. zoomStopsAnimation: boolean;
  35319. /**
  35320. * Sets the transition time when framing the mesh, in milliseconds
  35321. */
  35322. /**
  35323. * Gets the transition time when framing the mesh, in milliseconds
  35324. */
  35325. framingTime: number;
  35326. /**
  35327. * Define if the behavior should automatically change the configured
  35328. * camera limits and sensibilities.
  35329. */
  35330. autoCorrectCameraLimitsAndSensibility: boolean;
  35331. private _onPrePointerObservableObserver;
  35332. private _onAfterCheckInputsObserver;
  35333. private _onMeshTargetChangedObserver;
  35334. private _attachedCamera;
  35335. private _isPointerDown;
  35336. private _lastInteractionTime;
  35337. /**
  35338. * Initializes the behavior.
  35339. */
  35340. init(): void;
  35341. /**
  35342. * Attaches the behavior to its arc rotate camera.
  35343. * @param camera Defines the camera to attach the behavior to
  35344. */
  35345. attach(camera: ArcRotateCamera): void;
  35346. /**
  35347. * Detaches the behavior from its current arc rotate camera.
  35348. */
  35349. detach(): void;
  35350. private _animatables;
  35351. private _betaIsAnimating;
  35352. private _betaTransition;
  35353. private _radiusTransition;
  35354. private _vectorTransition;
  35355. /**
  35356. * Targets the given mesh and updates zoom level accordingly.
  35357. * @param mesh The mesh to target.
  35358. * @param radius Optional. If a cached radius position already exists, overrides default.
  35359. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35364. /**
  35365. * Targets the given mesh with its children and updates zoom level accordingly.
  35366. * @param mesh The mesh to target.
  35367. * @param radius Optional. If a cached radius position already exists, overrides default.
  35368. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35369. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35370. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35371. */
  35372. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35373. /**
  35374. * Targets the given meshes with their children and updates zoom level accordingly.
  35375. * @param meshes The mesh to target.
  35376. * @param radius Optional. If a cached radius position already exists, overrides default.
  35377. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35380. */
  35381. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35382. /**
  35383. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35384. * @param minimumWorld Determines the smaller position of the bounding box extend
  35385. * @param maximumWorld Determines the bigger position of the bounding box extend
  35386. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35387. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35388. */
  35389. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35390. /**
  35391. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35392. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35393. * frustum width.
  35394. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35395. * to fully enclose the mesh in the viewing frustum.
  35396. */
  35397. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35398. /**
  35399. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35400. * is automatically returned to its default position (expected to be above ground plane).
  35401. */
  35402. private _maintainCameraAboveGround;
  35403. /**
  35404. * Returns the frustum slope based on the canvas ratio and camera FOV
  35405. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35406. */
  35407. private _getFrustumSlope;
  35408. /**
  35409. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35410. */
  35411. private _clearAnimationLocks;
  35412. /**
  35413. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35414. */
  35415. private _applyUserInteraction;
  35416. /**
  35417. * Stops and removes all animations that have been applied to the camera
  35418. */
  35419. stopAllAnimations(): void;
  35420. /**
  35421. * Gets a value indicating if the user is moving the camera
  35422. */
  35423. readonly isUserIsMoving: boolean;
  35424. /**
  35425. * The camera can move all the way towards the mesh.
  35426. */
  35427. static IgnoreBoundsSizeMode: number;
  35428. /**
  35429. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35430. */
  35431. static FitFrustumSidesMode: number;
  35432. }
  35433. }
  35434. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35435. import { Nullable } from "babylonjs/types";
  35436. import { Camera } from "babylonjs/Cameras/camera";
  35437. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35438. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35439. /**
  35440. * Base class for Camera Pointer Inputs.
  35441. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35442. * for example usage.
  35443. */
  35444. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35445. /**
  35446. * Defines the camera the input is attached to.
  35447. */
  35448. abstract camera: Camera;
  35449. /**
  35450. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35451. */
  35452. protected _altKey: boolean;
  35453. protected _ctrlKey: boolean;
  35454. protected _metaKey: boolean;
  35455. protected _shiftKey: boolean;
  35456. /**
  35457. * Which mouse buttons were pressed at time of last mouse event.
  35458. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35459. */
  35460. protected _buttonsPressed: number;
  35461. /**
  35462. * Defines the buttons associated with the input to handle camera move.
  35463. */
  35464. buttons: number[];
  35465. /**
  35466. * Attach the input controls to a specific dom element to get the input from.
  35467. * @param element Defines the element the controls should be listened from
  35468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35469. */
  35470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35471. /**
  35472. * Detach the current controls from the specified dom element.
  35473. * @param element Defines the element to stop listening the inputs from
  35474. */
  35475. detachControl(element: Nullable<HTMLElement>): void;
  35476. /**
  35477. * Gets the class name of the current input.
  35478. * @returns the class name
  35479. */
  35480. getClassName(): string;
  35481. /**
  35482. * Get the friendly name associated with the input class.
  35483. * @returns the input friendly name
  35484. */
  35485. getSimpleName(): string;
  35486. /**
  35487. * Called on pointer POINTERDOUBLETAP event.
  35488. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35489. */
  35490. protected onDoubleTap(type: string): void;
  35491. /**
  35492. * Called on pointer POINTERMOVE event if only a single touch is active.
  35493. * Override this method to provide functionality.
  35494. */
  35495. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35496. /**
  35497. * Called on pointer POINTERMOVE event if multiple touches are active.
  35498. * Override this method to provide functionality.
  35499. */
  35500. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35501. /**
  35502. * Called on JS contextmenu event.
  35503. * Override this method to provide functionality.
  35504. */
  35505. protected onContextMenu(evt: PointerEvent): void;
  35506. /**
  35507. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35508. * press.
  35509. * Override this method to provide functionality.
  35510. */
  35511. protected onButtonDown(evt: PointerEvent): void;
  35512. /**
  35513. * Called each time a new POINTERUP event occurs. Ie, for each button
  35514. * release.
  35515. * Override this method to provide functionality.
  35516. */
  35517. protected onButtonUp(evt: PointerEvent): void;
  35518. /**
  35519. * Called when window becomes inactive.
  35520. * Override this method to provide functionality.
  35521. */
  35522. protected onLostFocus(): void;
  35523. private _pointerInput;
  35524. private _observer;
  35525. private _onLostFocus;
  35526. private pointA;
  35527. private pointB;
  35528. }
  35529. }
  35530. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35531. import { Nullable } from "babylonjs/types";
  35532. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35533. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35534. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35535. /**
  35536. * Manage the pointers inputs to control an arc rotate camera.
  35537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35538. */
  35539. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35540. /**
  35541. * Defines the camera the input is attached to.
  35542. */
  35543. camera: ArcRotateCamera;
  35544. /**
  35545. * Gets the class name of the current input.
  35546. * @returns the class name
  35547. */
  35548. getClassName(): string;
  35549. /**
  35550. * Defines the buttons associated with the input to handle camera move.
  35551. */
  35552. buttons: number[];
  35553. /**
  35554. * Defines the pointer angular sensibility along the X axis or how fast is
  35555. * the camera rotating.
  35556. */
  35557. angularSensibilityX: number;
  35558. /**
  35559. * Defines the pointer angular sensibility along the Y axis or how fast is
  35560. * the camera rotating.
  35561. */
  35562. angularSensibilityY: number;
  35563. /**
  35564. * Defines the pointer pinch precision or how fast is the camera zooming.
  35565. */
  35566. pinchPrecision: number;
  35567. /**
  35568. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35569. * from 0.
  35570. * It defines the percentage of current camera.radius to use as delta when
  35571. * pinch zoom is used.
  35572. */
  35573. pinchDeltaPercentage: number;
  35574. /**
  35575. * Defines the pointer panning sensibility or how fast is the camera moving.
  35576. */
  35577. panningSensibility: number;
  35578. /**
  35579. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35580. */
  35581. multiTouchPanning: boolean;
  35582. /**
  35583. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35584. * zoom (pinch) through multitouch.
  35585. */
  35586. multiTouchPanAndZoom: boolean;
  35587. /**
  35588. * Revers pinch action direction.
  35589. */
  35590. pinchInwards: boolean;
  35591. private _isPanClick;
  35592. private _twoFingerActivityCount;
  35593. private _isPinching;
  35594. /**
  35595. * Called on pointer POINTERMOVE event if only a single touch is active.
  35596. */
  35597. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35598. /**
  35599. * Called on pointer POINTERDOUBLETAP event.
  35600. */
  35601. protected onDoubleTap(type: string): void;
  35602. /**
  35603. * Called on pointer POINTERMOVE event if multiple touches are active.
  35604. */
  35605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35606. /**
  35607. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35608. * press.
  35609. */
  35610. protected onButtonDown(evt: PointerEvent): void;
  35611. /**
  35612. * Called each time a new POINTERUP event occurs. Ie, for each button
  35613. * release.
  35614. */
  35615. protected onButtonUp(evt: PointerEvent): void;
  35616. /**
  35617. * Called when window becomes inactive.
  35618. */
  35619. protected onLostFocus(): void;
  35620. }
  35621. }
  35622. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35623. import { Nullable } from "babylonjs/types";
  35624. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35625. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35626. /**
  35627. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35629. */
  35630. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35631. /**
  35632. * Defines the camera the input is attached to.
  35633. */
  35634. camera: ArcRotateCamera;
  35635. /**
  35636. * Defines the list of key codes associated with the up action (increase alpha)
  35637. */
  35638. keysUp: number[];
  35639. /**
  35640. * Defines the list of key codes associated with the down action (decrease alpha)
  35641. */
  35642. keysDown: number[];
  35643. /**
  35644. * Defines the list of key codes associated with the left action (increase beta)
  35645. */
  35646. keysLeft: number[];
  35647. /**
  35648. * Defines the list of key codes associated with the right action (decrease beta)
  35649. */
  35650. keysRight: number[];
  35651. /**
  35652. * Defines the list of key codes associated with the reset action.
  35653. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35654. */
  35655. keysReset: number[];
  35656. /**
  35657. * Defines the panning sensibility of the inputs.
  35658. * (How fast is the camera paning)
  35659. */
  35660. panningSensibility: number;
  35661. /**
  35662. * Defines the zooming sensibility of the inputs.
  35663. * (How fast is the camera zooming)
  35664. */
  35665. zoomingSensibility: number;
  35666. /**
  35667. * Defines wether maintaining the alt key down switch the movement mode from
  35668. * orientation to zoom.
  35669. */
  35670. useAltToZoom: boolean;
  35671. /**
  35672. * Rotation speed of the camera
  35673. */
  35674. angularSpeed: number;
  35675. private _keys;
  35676. private _ctrlPressed;
  35677. private _altPressed;
  35678. private _onCanvasBlurObserver;
  35679. private _onKeyboardObserver;
  35680. private _engine;
  35681. private _scene;
  35682. /**
  35683. * Attach the input controls to a specific dom element to get the input from.
  35684. * @param element Defines the element the controls should be listened from
  35685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35686. */
  35687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35688. /**
  35689. * Detach the current controls from the specified dom element.
  35690. * @param element Defines the element to stop listening the inputs from
  35691. */
  35692. detachControl(element: Nullable<HTMLElement>): void;
  35693. /**
  35694. * Update the current camera state depending on the inputs that have been used this frame.
  35695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35696. */
  35697. checkInputs(): void;
  35698. /**
  35699. * Gets the class name of the current intput.
  35700. * @returns the class name
  35701. */
  35702. getClassName(): string;
  35703. /**
  35704. * Get the friendly name associated with the input class.
  35705. * @returns the input friendly name
  35706. */
  35707. getSimpleName(): string;
  35708. }
  35709. }
  35710. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35711. import { Nullable } from "babylonjs/types";
  35712. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35713. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35714. /**
  35715. * Manage the mouse wheel inputs to control an arc rotate camera.
  35716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35717. */
  35718. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35719. /**
  35720. * Defines the camera the input is attached to.
  35721. */
  35722. camera: ArcRotateCamera;
  35723. /**
  35724. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35725. */
  35726. wheelPrecision: number;
  35727. /**
  35728. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35729. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35730. */
  35731. wheelDeltaPercentage: number;
  35732. private _wheel;
  35733. private _observer;
  35734. /**
  35735. * Attach the input controls to a specific dom element to get the input from.
  35736. * @param element Defines the element the controls should be listened from
  35737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35738. */
  35739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35740. /**
  35741. * Detach the current controls from the specified dom element.
  35742. * @param element Defines the element to stop listening the inputs from
  35743. */
  35744. detachControl(element: Nullable<HTMLElement>): void;
  35745. /**
  35746. * Gets the class name of the current intput.
  35747. * @returns the class name
  35748. */
  35749. getClassName(): string;
  35750. /**
  35751. * Get the friendly name associated with the input class.
  35752. * @returns the input friendly name
  35753. */
  35754. getSimpleName(): string;
  35755. }
  35756. }
  35757. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35759. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35760. /**
  35761. * Default Inputs manager for the ArcRotateCamera.
  35762. * It groups all the default supported inputs for ease of use.
  35763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35764. */
  35765. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35766. /**
  35767. * Instantiates a new ArcRotateCameraInputsManager.
  35768. * @param camera Defines the camera the inputs belong to
  35769. */
  35770. constructor(camera: ArcRotateCamera);
  35771. /**
  35772. * Add mouse wheel input support to the input manager.
  35773. * @returns the current input manager
  35774. */
  35775. addMouseWheel(): ArcRotateCameraInputsManager;
  35776. /**
  35777. * Add pointers input support to the input manager.
  35778. * @returns the current input manager
  35779. */
  35780. addPointers(): ArcRotateCameraInputsManager;
  35781. /**
  35782. * Add keyboard input support to the input manager.
  35783. * @returns the current input manager
  35784. */
  35785. addKeyboard(): ArcRotateCameraInputsManager;
  35786. }
  35787. }
  35788. declare module "babylonjs/Cameras/arcRotateCamera" {
  35789. import { Observable } from "babylonjs/Misc/observable";
  35790. import { Nullable } from "babylonjs/types";
  35791. import { Scene } from "babylonjs/scene";
  35792. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35794. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35795. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35796. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35797. import { Camera } from "babylonjs/Cameras/camera";
  35798. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35799. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35800. import { Collider } from "babylonjs/Collisions/collider";
  35801. /**
  35802. * This represents an orbital type of camera.
  35803. *
  35804. * 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.
  35805. * 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.
  35806. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35807. */
  35808. export class ArcRotateCamera extends TargetCamera {
  35809. /**
  35810. * Defines the rotation angle of the camera along the longitudinal axis.
  35811. */
  35812. alpha: number;
  35813. /**
  35814. * Defines the rotation angle of the camera along the latitudinal axis.
  35815. */
  35816. beta: number;
  35817. /**
  35818. * Defines the radius of the camera from it s target point.
  35819. */
  35820. radius: number;
  35821. protected _target: Vector3;
  35822. protected _targetHost: Nullable<AbstractMesh>;
  35823. /**
  35824. * Defines the target point of the camera.
  35825. * The camera looks towards it form the radius distance.
  35826. */
  35827. target: Vector3;
  35828. /**
  35829. * Define the current local position of the camera in the scene
  35830. */
  35831. position: Vector3;
  35832. /**
  35833. * Current inertia value on the longitudinal axis.
  35834. * The bigger this number the longer it will take for the camera to stop.
  35835. */
  35836. inertialAlphaOffset: number;
  35837. /**
  35838. * Current inertia value on the latitudinal axis.
  35839. * The bigger this number the longer it will take for the camera to stop.
  35840. */
  35841. inertialBetaOffset: number;
  35842. /**
  35843. * Current inertia value on the radius axis.
  35844. * The bigger this number the longer it will take for the camera to stop.
  35845. */
  35846. inertialRadiusOffset: number;
  35847. /**
  35848. * Minimum allowed angle on the longitudinal axis.
  35849. * This can help limiting how the Camera is able to move in the scene.
  35850. */
  35851. lowerAlphaLimit: Nullable<number>;
  35852. /**
  35853. * Maximum allowed angle on the longitudinal axis.
  35854. * This can help limiting how the Camera is able to move in the scene.
  35855. */
  35856. upperAlphaLimit: Nullable<number>;
  35857. /**
  35858. * Minimum allowed angle on the latitudinal axis.
  35859. * This can help limiting how the Camera is able to move in the scene.
  35860. */
  35861. lowerBetaLimit: number;
  35862. /**
  35863. * Maximum allowed angle on the latitudinal axis.
  35864. * This can help limiting how the Camera is able to move in the scene.
  35865. */
  35866. upperBetaLimit: number;
  35867. /**
  35868. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35869. * This can help limiting how the Camera is able to move in the scene.
  35870. */
  35871. lowerRadiusLimit: Nullable<number>;
  35872. /**
  35873. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35874. * This can help limiting how the Camera is able to move in the scene.
  35875. */
  35876. upperRadiusLimit: Nullable<number>;
  35877. /**
  35878. * Defines the current inertia value used during panning of the camera along the X axis.
  35879. */
  35880. inertialPanningX: number;
  35881. /**
  35882. * Defines the current inertia value used during panning of the camera along the Y axis.
  35883. */
  35884. inertialPanningY: number;
  35885. /**
  35886. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35887. * Basically if your fingers moves away from more than this distance you will be considered
  35888. * in pinch mode.
  35889. */
  35890. pinchToPanMaxDistance: number;
  35891. /**
  35892. * Defines the maximum distance the camera can pan.
  35893. * This could help keeping the cammera always in your scene.
  35894. */
  35895. panningDistanceLimit: Nullable<number>;
  35896. /**
  35897. * Defines the target of the camera before paning.
  35898. */
  35899. panningOriginTarget: Vector3;
  35900. /**
  35901. * Defines the value of the inertia used during panning.
  35902. * 0 would mean stop inertia and one would mean no decelleration at all.
  35903. */
  35904. panningInertia: number;
  35905. /**
  35906. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35907. */
  35908. angularSensibilityX: number;
  35909. /**
  35910. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35911. */
  35912. angularSensibilityY: number;
  35913. /**
  35914. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35915. */
  35916. pinchPrecision: number;
  35917. /**
  35918. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35919. * It will be used instead of pinchDeltaPrecision if different from 0.
  35920. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35921. */
  35922. pinchDeltaPercentage: number;
  35923. /**
  35924. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35925. */
  35926. panningSensibility: number;
  35927. /**
  35928. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35929. */
  35930. keysUp: number[];
  35931. /**
  35932. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35933. */
  35934. keysDown: number[];
  35935. /**
  35936. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35937. */
  35938. keysLeft: number[];
  35939. /**
  35940. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35941. */
  35942. keysRight: number[];
  35943. /**
  35944. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35945. */
  35946. wheelPrecision: number;
  35947. /**
  35948. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35949. * It will be used instead of pinchDeltaPrecision if different from 0.
  35950. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35951. */
  35952. wheelDeltaPercentage: number;
  35953. /**
  35954. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35955. */
  35956. zoomOnFactor: number;
  35957. /**
  35958. * Defines a screen offset for the camera position.
  35959. */
  35960. targetScreenOffset: Vector2;
  35961. /**
  35962. * Allows the camera to be completely reversed.
  35963. * If false the camera can not arrive upside down.
  35964. */
  35965. allowUpsideDown: boolean;
  35966. /**
  35967. * Define if double tap/click is used to restore the previously saved state of the camera.
  35968. */
  35969. useInputToRestoreState: boolean;
  35970. /** @hidden */
  35971. _viewMatrix: Matrix;
  35972. /** @hidden */
  35973. _useCtrlForPanning: boolean;
  35974. /** @hidden */
  35975. _panningMouseButton: number;
  35976. /**
  35977. * Defines the input associated to the camera.
  35978. */
  35979. inputs: ArcRotateCameraInputsManager;
  35980. /** @hidden */
  35981. _reset: () => void;
  35982. /**
  35983. * Defines the allowed panning axis.
  35984. */
  35985. panningAxis: Vector3;
  35986. protected _localDirection: Vector3;
  35987. protected _transformedDirection: Vector3;
  35988. private _bouncingBehavior;
  35989. /**
  35990. * Gets the bouncing behavior of the camera if it has been enabled.
  35991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35992. */
  35993. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35994. /**
  35995. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35996. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35997. */
  35998. useBouncingBehavior: boolean;
  35999. private _framingBehavior;
  36000. /**
  36001. * Gets the framing behavior of the camera if it has been enabled.
  36002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36003. */
  36004. readonly framingBehavior: Nullable<FramingBehavior>;
  36005. /**
  36006. * Defines if the framing behavior of the camera is enabled on the camera.
  36007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36008. */
  36009. useFramingBehavior: boolean;
  36010. private _autoRotationBehavior;
  36011. /**
  36012. * Gets the auto rotation behavior of the camera if it has been enabled.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36014. */
  36015. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36016. /**
  36017. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36019. */
  36020. useAutoRotationBehavior: boolean;
  36021. /**
  36022. * Observable triggered when the mesh target has been changed on the camera.
  36023. */
  36024. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36025. /**
  36026. * Event raised when the camera is colliding with a mesh.
  36027. */
  36028. onCollide: (collidedMesh: AbstractMesh) => void;
  36029. /**
  36030. * Defines whether the camera should check collision with the objects oh the scene.
  36031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36032. */
  36033. checkCollisions: boolean;
  36034. /**
  36035. * Defines the collision radius of the camera.
  36036. * This simulates a sphere around the camera.
  36037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36038. */
  36039. collisionRadius: Vector3;
  36040. protected _collider: Collider;
  36041. protected _previousPosition: Vector3;
  36042. protected _collisionVelocity: Vector3;
  36043. protected _newPosition: Vector3;
  36044. protected _previousAlpha: number;
  36045. protected _previousBeta: number;
  36046. protected _previousRadius: number;
  36047. protected _collisionTriggered: boolean;
  36048. protected _targetBoundingCenter: Nullable<Vector3>;
  36049. private _computationVector;
  36050. private _tempAxisVector;
  36051. private _tempAxisRotationMatrix;
  36052. /**
  36053. * Instantiates a new ArcRotateCamera in a given scene
  36054. * @param name Defines the name of the camera
  36055. * @param alpha Defines the camera rotation along the logitudinal axis
  36056. * @param beta Defines the camera rotation along the latitudinal axis
  36057. * @param radius Defines the camera distance from its target
  36058. * @param target Defines the camera target
  36059. * @param scene Defines the scene the camera belongs to
  36060. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36061. */
  36062. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36063. /** @hidden */
  36064. _initCache(): void;
  36065. /** @hidden */
  36066. _updateCache(ignoreParentClass?: boolean): void;
  36067. protected _getTargetPosition(): Vector3;
  36068. private _storedAlpha;
  36069. private _storedBeta;
  36070. private _storedRadius;
  36071. private _storedTarget;
  36072. /**
  36073. * Stores the current state of the camera (alpha, beta, radius and target)
  36074. * @returns the camera itself
  36075. */
  36076. storeState(): Camera;
  36077. /**
  36078. * @hidden
  36079. * Restored camera state. You must call storeState() first
  36080. */
  36081. _restoreStateValues(): boolean;
  36082. /** @hidden */
  36083. _isSynchronizedViewMatrix(): boolean;
  36084. /**
  36085. * Attached controls to the current camera.
  36086. * @param element Defines the element the controls should be listened from
  36087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36088. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36089. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36090. */
  36091. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36092. /**
  36093. * Detach the current controls from the camera.
  36094. * The camera will stop reacting to inputs.
  36095. * @param element Defines the element to stop listening the inputs from
  36096. */
  36097. detachControl(element: HTMLElement): void;
  36098. /** @hidden */
  36099. _checkInputs(): void;
  36100. protected _checkLimits(): void;
  36101. /**
  36102. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36103. */
  36104. rebuildAnglesAndRadius(): void;
  36105. /**
  36106. * Use a position to define the current camera related information like aplha, beta and radius
  36107. * @param position Defines the position to set the camera at
  36108. */
  36109. setPosition(position: Vector3): void;
  36110. /**
  36111. * Defines the target the camera should look at.
  36112. * This will automatically adapt alpha beta and radius to fit within the new target.
  36113. * @param target Defines the new target as a Vector or a mesh
  36114. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36115. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36116. */
  36117. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36118. /** @hidden */
  36119. _getViewMatrix(): Matrix;
  36120. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36121. /**
  36122. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36123. * @param meshes Defines the mesh to zoom on
  36124. * @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)
  36125. */
  36126. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36127. /**
  36128. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36129. * The target will be changed but the radius
  36130. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36131. * @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)
  36132. */
  36133. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36134. min: Vector3;
  36135. max: Vector3;
  36136. distance: number;
  36137. }, doNotUpdateMaxZ?: boolean): void;
  36138. /**
  36139. * @override
  36140. * Override Camera.createRigCamera
  36141. */
  36142. createRigCamera(name: string, cameraIndex: number): Camera;
  36143. /**
  36144. * @hidden
  36145. * @override
  36146. * Override Camera._updateRigCameras
  36147. */
  36148. _updateRigCameras(): void;
  36149. /**
  36150. * Destroy the camera and release the current resources hold by it.
  36151. */
  36152. dispose(): void;
  36153. /**
  36154. * Gets the current object class name.
  36155. * @return the class name
  36156. */
  36157. getClassName(): string;
  36158. }
  36159. }
  36160. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36161. import { Behavior } from "babylonjs/Behaviors/behavior";
  36162. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36163. /**
  36164. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36166. */
  36167. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36168. /**
  36169. * Gets the name of the behavior.
  36170. */
  36171. readonly name: string;
  36172. private _zoomStopsAnimation;
  36173. private _idleRotationSpeed;
  36174. private _idleRotationWaitTime;
  36175. private _idleRotationSpinupTime;
  36176. /**
  36177. * Sets the flag that indicates if user zooming should stop animation.
  36178. */
  36179. /**
  36180. * Gets the flag that indicates if user zooming should stop animation.
  36181. */
  36182. zoomStopsAnimation: boolean;
  36183. /**
  36184. * Sets the default speed at which the camera rotates around the model.
  36185. */
  36186. /**
  36187. * Gets the default speed at which the camera rotates around the model.
  36188. */
  36189. idleRotationSpeed: number;
  36190. /**
  36191. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36192. */
  36193. /**
  36194. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36195. */
  36196. idleRotationWaitTime: number;
  36197. /**
  36198. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36199. */
  36200. /**
  36201. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36202. */
  36203. idleRotationSpinupTime: number;
  36204. /**
  36205. * Gets a value indicating if the camera is currently rotating because of this behavior
  36206. */
  36207. readonly rotationInProgress: boolean;
  36208. private _onPrePointerObservableObserver;
  36209. private _onAfterCheckInputsObserver;
  36210. private _attachedCamera;
  36211. private _isPointerDown;
  36212. private _lastFrameTime;
  36213. private _lastInteractionTime;
  36214. private _cameraRotationSpeed;
  36215. /**
  36216. * Initializes the behavior.
  36217. */
  36218. init(): void;
  36219. /**
  36220. * Attaches the behavior to its arc rotate camera.
  36221. * @param camera Defines the camera to attach the behavior to
  36222. */
  36223. attach(camera: ArcRotateCamera): void;
  36224. /**
  36225. * Detaches the behavior from its current arc rotate camera.
  36226. */
  36227. detach(): void;
  36228. /**
  36229. * Returns true if user is scrolling.
  36230. * @return true if user is scrolling.
  36231. */
  36232. private _userIsZooming;
  36233. private _lastFrameRadius;
  36234. private _shouldAnimationStopForInteraction;
  36235. /**
  36236. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36237. */
  36238. private _applyUserInteraction;
  36239. private _userIsMoving;
  36240. }
  36241. }
  36242. declare module "babylonjs/Behaviors/Cameras/index" {
  36243. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36244. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36245. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36246. }
  36247. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36248. import { Mesh } from "babylonjs/Meshes/mesh";
  36249. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36250. import { Behavior } from "babylonjs/Behaviors/behavior";
  36251. /**
  36252. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36253. */
  36254. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36255. private ui;
  36256. /**
  36257. * The name of the behavior
  36258. */
  36259. name: string;
  36260. /**
  36261. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36262. */
  36263. distanceAwayFromFace: number;
  36264. /**
  36265. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36266. */
  36267. distanceAwayFromBottomOfFace: number;
  36268. private _faceVectors;
  36269. private _target;
  36270. private _scene;
  36271. private _onRenderObserver;
  36272. private _tmpMatrix;
  36273. private _tmpVector;
  36274. /**
  36275. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36276. * @param ui The transform node that should be attched to the mesh
  36277. */
  36278. constructor(ui: TransformNode);
  36279. /**
  36280. * Initializes the behavior
  36281. */
  36282. init(): void;
  36283. private _closestFace;
  36284. private _zeroVector;
  36285. private _lookAtTmpMatrix;
  36286. private _lookAtToRef;
  36287. /**
  36288. * Attaches the AttachToBoxBehavior to the passed in mesh
  36289. * @param target The mesh that the specified node will be attached to
  36290. */
  36291. attach(target: Mesh): void;
  36292. /**
  36293. * Detaches the behavior from the mesh
  36294. */
  36295. detach(): void;
  36296. }
  36297. }
  36298. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36299. import { Behavior } from "babylonjs/Behaviors/behavior";
  36300. import { Mesh } from "babylonjs/Meshes/mesh";
  36301. /**
  36302. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36303. */
  36304. export class FadeInOutBehavior implements Behavior<Mesh> {
  36305. /**
  36306. * Time in milliseconds to delay before fading in (Default: 0)
  36307. */
  36308. delay: number;
  36309. /**
  36310. * Time in milliseconds for the mesh to fade in (Default: 300)
  36311. */
  36312. fadeInTime: number;
  36313. private _millisecondsPerFrame;
  36314. private _hovered;
  36315. private _hoverValue;
  36316. private _ownerNode;
  36317. /**
  36318. * Instatiates the FadeInOutBehavior
  36319. */
  36320. constructor();
  36321. /**
  36322. * The name of the behavior
  36323. */
  36324. readonly name: string;
  36325. /**
  36326. * Initializes the behavior
  36327. */
  36328. init(): void;
  36329. /**
  36330. * Attaches the fade behavior on the passed in mesh
  36331. * @param ownerNode The mesh that will be faded in/out once attached
  36332. */
  36333. attach(ownerNode: Mesh): void;
  36334. /**
  36335. * Detaches the behavior from the mesh
  36336. */
  36337. detach(): void;
  36338. /**
  36339. * Triggers the mesh to begin fading in or out
  36340. * @param value if the object should fade in or out (true to fade in)
  36341. */
  36342. fadeIn(value: boolean): void;
  36343. private _update;
  36344. private _setAllVisibility;
  36345. }
  36346. }
  36347. declare module "babylonjs/Misc/pivotTools" {
  36348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36349. /**
  36350. * Class containing a set of static utilities functions for managing Pivots
  36351. * @hidden
  36352. */
  36353. export class PivotTools {
  36354. private static _PivotCached;
  36355. private static _OldPivotPoint;
  36356. private static _PivotTranslation;
  36357. private static _PivotTmpVector;
  36358. /** @hidden */
  36359. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36360. /** @hidden */
  36361. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36362. }
  36363. }
  36364. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36365. import { Scene } from "babylonjs/scene";
  36366. import { Vector4, Plane } from "babylonjs/Maths/math";
  36367. import { Mesh } from "babylonjs/Meshes/mesh";
  36368. /**
  36369. * Class containing static functions to help procedurally build meshes
  36370. */
  36371. export class PlaneBuilder {
  36372. /**
  36373. * Creates a plane mesh
  36374. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36375. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36376. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36380. * @param name defines the name of the mesh
  36381. * @param options defines the options used to create the mesh
  36382. * @param scene defines the hosting scene
  36383. * @returns the plane mesh
  36384. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36385. */
  36386. static CreatePlane(name: string, options: {
  36387. size?: number;
  36388. width?: number;
  36389. height?: number;
  36390. sideOrientation?: number;
  36391. frontUVs?: Vector4;
  36392. backUVs?: Vector4;
  36393. updatable?: boolean;
  36394. sourcePlane?: Plane;
  36395. }, scene: Scene): Mesh;
  36396. }
  36397. }
  36398. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36399. import { Behavior } from "babylonjs/Behaviors/behavior";
  36400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36401. import { Observable } from "babylonjs/Misc/observable";
  36402. import { Vector3 } from "babylonjs/Maths/math";
  36403. import { Ray } from "babylonjs/Culling/ray";
  36404. import "babylonjs/Meshes/Builders/planeBuilder";
  36405. /**
  36406. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36407. */
  36408. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36409. private static _AnyMouseID;
  36410. private _attachedNode;
  36411. private _dragPlane;
  36412. private _scene;
  36413. private _pointerObserver;
  36414. private _beforeRenderObserver;
  36415. private static _planeScene;
  36416. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36417. /**
  36418. * 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)
  36419. */
  36420. maxDragAngle: number;
  36421. /**
  36422. * @hidden
  36423. */
  36424. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36425. /**
  36426. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36427. */
  36428. currentDraggingPointerID: number;
  36429. /**
  36430. * The last position where the pointer hit the drag plane in world space
  36431. */
  36432. lastDragPosition: Vector3;
  36433. /**
  36434. * If the behavior is currently in a dragging state
  36435. */
  36436. dragging: boolean;
  36437. /**
  36438. * 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)
  36439. */
  36440. dragDeltaRatio: number;
  36441. /**
  36442. * If the drag plane orientation should be updated during the dragging (Default: true)
  36443. */
  36444. updateDragPlane: boolean;
  36445. private _debugMode;
  36446. private _moving;
  36447. /**
  36448. * Fires each time the attached mesh is dragged with the pointer
  36449. * * delta between last drag position and current drag position in world space
  36450. * * dragDistance along the drag axis
  36451. * * dragPlaneNormal normal of the current drag plane used during the drag
  36452. * * dragPlanePoint in world space where the drag intersects the drag plane
  36453. */
  36454. onDragObservable: Observable<{
  36455. delta: Vector3;
  36456. dragPlanePoint: Vector3;
  36457. dragPlaneNormal: Vector3;
  36458. dragDistance: number;
  36459. pointerId: number;
  36460. }>;
  36461. /**
  36462. * Fires each time a drag begins (eg. mouse down on mesh)
  36463. */
  36464. onDragStartObservable: Observable<{
  36465. dragPlanePoint: Vector3;
  36466. pointerId: number;
  36467. }>;
  36468. /**
  36469. * Fires each time a drag ends (eg. mouse release after drag)
  36470. */
  36471. onDragEndObservable: Observable<{
  36472. dragPlanePoint: Vector3;
  36473. pointerId: number;
  36474. }>;
  36475. /**
  36476. * If the attached mesh should be moved when dragged
  36477. */
  36478. moveAttached: boolean;
  36479. /**
  36480. * If the drag behavior will react to drag events (Default: true)
  36481. */
  36482. enabled: boolean;
  36483. /**
  36484. * If camera controls should be detached during the drag
  36485. */
  36486. detachCameraControls: boolean;
  36487. /**
  36488. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36489. */
  36490. useObjectOrienationForDragging: boolean;
  36491. private _options;
  36492. /**
  36493. * Creates a pointer drag behavior that can be attached to a mesh
  36494. * @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)
  36495. */
  36496. constructor(options?: {
  36497. dragAxis?: Vector3;
  36498. dragPlaneNormal?: Vector3;
  36499. });
  36500. /**
  36501. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36502. */
  36503. validateDrag: (targetPosition: Vector3) => boolean;
  36504. /**
  36505. * The name of the behavior
  36506. */
  36507. readonly name: string;
  36508. /**
  36509. * Initializes the behavior
  36510. */
  36511. init(): void;
  36512. private _tmpVector;
  36513. private _alternatePickedPoint;
  36514. private _worldDragAxis;
  36515. private _targetPosition;
  36516. private _attachedElement;
  36517. /**
  36518. * Attaches the drag behavior the passed in mesh
  36519. * @param ownerNode The mesh that will be dragged around once attached
  36520. */
  36521. attach(ownerNode: AbstractMesh): void;
  36522. /**
  36523. * Force relase the drag action by code.
  36524. */
  36525. releaseDrag(): void;
  36526. private _startDragRay;
  36527. private _lastPointerRay;
  36528. /**
  36529. * Simulates the start of a pointer drag event on the behavior
  36530. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36531. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36532. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36533. */
  36534. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36535. private _startDrag;
  36536. private _dragDelta;
  36537. private _moveDrag;
  36538. private _pickWithRayOnDragPlane;
  36539. private _pointA;
  36540. private _pointB;
  36541. private _pointC;
  36542. private _lineA;
  36543. private _lineB;
  36544. private _localAxis;
  36545. private _lookAt;
  36546. private _updateDragPlanePosition;
  36547. /**
  36548. * Detaches the behavior from the mesh
  36549. */
  36550. detach(): void;
  36551. }
  36552. }
  36553. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36554. import { Mesh } from "babylonjs/Meshes/mesh";
  36555. import { Behavior } from "babylonjs/Behaviors/behavior";
  36556. /**
  36557. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36558. */
  36559. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36560. private _dragBehaviorA;
  36561. private _dragBehaviorB;
  36562. private _startDistance;
  36563. private _initialScale;
  36564. private _targetScale;
  36565. private _ownerNode;
  36566. private _sceneRenderObserver;
  36567. /**
  36568. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36569. */
  36570. constructor();
  36571. /**
  36572. * The name of the behavior
  36573. */
  36574. readonly name: string;
  36575. /**
  36576. * Initializes the behavior
  36577. */
  36578. init(): void;
  36579. private _getCurrentDistance;
  36580. /**
  36581. * Attaches the scale behavior the passed in mesh
  36582. * @param ownerNode The mesh that will be scaled around once attached
  36583. */
  36584. attach(ownerNode: Mesh): void;
  36585. /**
  36586. * Detaches the behavior from the mesh
  36587. */
  36588. detach(): void;
  36589. }
  36590. }
  36591. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36592. import { Behavior } from "babylonjs/Behaviors/behavior";
  36593. import { Mesh } from "babylonjs/Meshes/mesh";
  36594. import { Observable } from "babylonjs/Misc/observable";
  36595. /**
  36596. * 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
  36597. */
  36598. export class SixDofDragBehavior implements Behavior<Mesh> {
  36599. private static _virtualScene;
  36600. private _ownerNode;
  36601. private _sceneRenderObserver;
  36602. private _scene;
  36603. private _targetPosition;
  36604. private _virtualOriginMesh;
  36605. private _virtualDragMesh;
  36606. private _pointerObserver;
  36607. private _moving;
  36608. private _startingOrientation;
  36609. /**
  36610. * 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)
  36611. */
  36612. private zDragFactor;
  36613. /**
  36614. * If the object should rotate to face the drag origin
  36615. */
  36616. rotateDraggedObject: boolean;
  36617. /**
  36618. * If the behavior is currently in a dragging state
  36619. */
  36620. dragging: boolean;
  36621. /**
  36622. * 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)
  36623. */
  36624. dragDeltaRatio: number;
  36625. /**
  36626. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36627. */
  36628. currentDraggingPointerID: number;
  36629. /**
  36630. * If camera controls should be detached during the drag
  36631. */
  36632. detachCameraControls: boolean;
  36633. /**
  36634. * Fires each time a drag starts
  36635. */
  36636. onDragStartObservable: Observable<{}>;
  36637. /**
  36638. * Fires each time a drag ends (eg. mouse release after drag)
  36639. */
  36640. onDragEndObservable: Observable<{}>;
  36641. /**
  36642. * 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
  36643. */
  36644. constructor();
  36645. /**
  36646. * The name of the behavior
  36647. */
  36648. readonly name: string;
  36649. /**
  36650. * Initializes the behavior
  36651. */
  36652. init(): void;
  36653. /**
  36654. * Attaches the scale behavior the passed in mesh
  36655. * @param ownerNode The mesh that will be scaled around once attached
  36656. */
  36657. attach(ownerNode: Mesh): void;
  36658. /**
  36659. * Detaches the behavior from the mesh
  36660. */
  36661. detach(): void;
  36662. }
  36663. }
  36664. declare module "babylonjs/Behaviors/Meshes/index" {
  36665. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36666. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36667. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36668. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36669. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36670. }
  36671. declare module "babylonjs/Behaviors/index" {
  36672. export * from "babylonjs/Behaviors/behavior";
  36673. export * from "babylonjs/Behaviors/Cameras/index";
  36674. export * from "babylonjs/Behaviors/Meshes/index";
  36675. }
  36676. declare module "babylonjs/Bones/boneIKController" {
  36677. import { Bone } from "babylonjs/Bones/bone";
  36678. import { Vector3 } from "babylonjs/Maths/math";
  36679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36680. import { Nullable } from "babylonjs/types";
  36681. /**
  36682. * Class used to apply inverse kinematics to bones
  36683. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36684. */
  36685. export class BoneIKController {
  36686. private static _tmpVecs;
  36687. private static _tmpQuat;
  36688. private static _tmpMats;
  36689. /**
  36690. * Gets or sets the target mesh
  36691. */
  36692. targetMesh: AbstractMesh;
  36693. /** Gets or sets the mesh used as pole */
  36694. poleTargetMesh: AbstractMesh;
  36695. /**
  36696. * Gets or sets the bone used as pole
  36697. */
  36698. poleTargetBone: Nullable<Bone>;
  36699. /**
  36700. * Gets or sets the target position
  36701. */
  36702. targetPosition: Vector3;
  36703. /**
  36704. * Gets or sets the pole target position
  36705. */
  36706. poleTargetPosition: Vector3;
  36707. /**
  36708. * Gets or sets the pole target local offset
  36709. */
  36710. poleTargetLocalOffset: Vector3;
  36711. /**
  36712. * Gets or sets the pole angle
  36713. */
  36714. poleAngle: number;
  36715. /**
  36716. * Gets or sets the mesh associated with the controller
  36717. */
  36718. mesh: AbstractMesh;
  36719. /**
  36720. * 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)
  36721. */
  36722. slerpAmount: number;
  36723. private _bone1Quat;
  36724. private _bone1Mat;
  36725. private _bone2Ang;
  36726. private _bone1;
  36727. private _bone2;
  36728. private _bone1Length;
  36729. private _bone2Length;
  36730. private _maxAngle;
  36731. private _maxReach;
  36732. private _rightHandedSystem;
  36733. private _bendAxis;
  36734. private _slerping;
  36735. private _adjustRoll;
  36736. /**
  36737. * Gets or sets maximum allowed angle
  36738. */
  36739. maxAngle: number;
  36740. /**
  36741. * Creates a new BoneIKController
  36742. * @param mesh defines the mesh to control
  36743. * @param bone defines the bone to control
  36744. * @param options defines options to set up the controller
  36745. */
  36746. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36747. targetMesh?: AbstractMesh;
  36748. poleTargetMesh?: AbstractMesh;
  36749. poleTargetBone?: Bone;
  36750. poleTargetLocalOffset?: Vector3;
  36751. poleAngle?: number;
  36752. bendAxis?: Vector3;
  36753. maxAngle?: number;
  36754. slerpAmount?: number;
  36755. });
  36756. private _setMaxAngle;
  36757. /**
  36758. * Force the controller to update the bones
  36759. */
  36760. update(): void;
  36761. }
  36762. }
  36763. declare module "babylonjs/Bones/boneLookController" {
  36764. import { Vector3, Space } from "babylonjs/Maths/math";
  36765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36766. import { Bone } from "babylonjs/Bones/bone";
  36767. /**
  36768. * Class used to make a bone look toward a point in space
  36769. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36770. */
  36771. export class BoneLookController {
  36772. private static _tmpVecs;
  36773. private static _tmpQuat;
  36774. private static _tmpMats;
  36775. /**
  36776. * The target Vector3 that the bone will look at
  36777. */
  36778. target: Vector3;
  36779. /**
  36780. * The mesh that the bone is attached to
  36781. */
  36782. mesh: AbstractMesh;
  36783. /**
  36784. * The bone that will be looking to the target
  36785. */
  36786. bone: Bone;
  36787. /**
  36788. * The up axis of the coordinate system that is used when the bone is rotated
  36789. */
  36790. upAxis: Vector3;
  36791. /**
  36792. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36793. */
  36794. upAxisSpace: Space;
  36795. /**
  36796. * Used to make an adjustment to the yaw of the bone
  36797. */
  36798. adjustYaw: number;
  36799. /**
  36800. * Used to make an adjustment to the pitch of the bone
  36801. */
  36802. adjustPitch: number;
  36803. /**
  36804. * Used to make an adjustment to the roll of the bone
  36805. */
  36806. adjustRoll: number;
  36807. /**
  36808. * 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)
  36809. */
  36810. slerpAmount: number;
  36811. private _minYaw;
  36812. private _maxYaw;
  36813. private _minPitch;
  36814. private _maxPitch;
  36815. private _minYawSin;
  36816. private _minYawCos;
  36817. private _maxYawSin;
  36818. private _maxYawCos;
  36819. private _midYawConstraint;
  36820. private _minPitchTan;
  36821. private _maxPitchTan;
  36822. private _boneQuat;
  36823. private _slerping;
  36824. private _transformYawPitch;
  36825. private _transformYawPitchInv;
  36826. private _firstFrameSkipped;
  36827. private _yawRange;
  36828. private _fowardAxis;
  36829. /**
  36830. * Gets or sets the minimum yaw angle that the bone can look to
  36831. */
  36832. minYaw: number;
  36833. /**
  36834. * Gets or sets the maximum yaw angle that the bone can look to
  36835. */
  36836. maxYaw: number;
  36837. /**
  36838. * Gets or sets the minimum pitch angle that the bone can look to
  36839. */
  36840. minPitch: number;
  36841. /**
  36842. * Gets or sets the maximum pitch angle that the bone can look to
  36843. */
  36844. maxPitch: number;
  36845. /**
  36846. * Create a BoneLookController
  36847. * @param mesh the mesh that the bone belongs to
  36848. * @param bone the bone that will be looking to the target
  36849. * @param target the target Vector3 to look at
  36850. * @param options optional settings:
  36851. * * maxYaw: the maximum angle the bone will yaw to
  36852. * * minYaw: the minimum angle the bone will yaw to
  36853. * * maxPitch: the maximum angle the bone will pitch to
  36854. * * minPitch: the minimum angle the bone will yaw to
  36855. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36856. * * upAxis: the up axis of the coordinate system
  36857. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36858. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36859. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36860. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36861. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36862. * * adjustRoll: used to make an adjustment to the roll of the bone
  36863. **/
  36864. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36865. maxYaw?: number;
  36866. minYaw?: number;
  36867. maxPitch?: number;
  36868. minPitch?: number;
  36869. slerpAmount?: number;
  36870. upAxis?: Vector3;
  36871. upAxisSpace?: Space;
  36872. yawAxis?: Vector3;
  36873. pitchAxis?: Vector3;
  36874. adjustYaw?: number;
  36875. adjustPitch?: number;
  36876. adjustRoll?: number;
  36877. });
  36878. /**
  36879. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36880. */
  36881. update(): void;
  36882. private _getAngleDiff;
  36883. private _getAngleBetween;
  36884. private _isAngleBetween;
  36885. }
  36886. }
  36887. declare module "babylonjs/Bones/index" {
  36888. export * from "babylonjs/Bones/bone";
  36889. export * from "babylonjs/Bones/boneIKController";
  36890. export * from "babylonjs/Bones/boneLookController";
  36891. export * from "babylonjs/Bones/skeleton";
  36892. }
  36893. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36894. import { Nullable } from "babylonjs/types";
  36895. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36896. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36897. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36898. /**
  36899. * Manage the gamepad inputs to control an arc rotate camera.
  36900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36901. */
  36902. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36903. /**
  36904. * Defines the camera the input is attached to.
  36905. */
  36906. camera: ArcRotateCamera;
  36907. /**
  36908. * Defines the gamepad the input is gathering event from.
  36909. */
  36910. gamepad: Nullable<Gamepad>;
  36911. /**
  36912. * Defines the gamepad rotation sensiblity.
  36913. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36914. */
  36915. gamepadRotationSensibility: number;
  36916. /**
  36917. * Defines the gamepad move sensiblity.
  36918. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36919. */
  36920. gamepadMoveSensibility: number;
  36921. private _onGamepadConnectedObserver;
  36922. private _onGamepadDisconnectedObserver;
  36923. /**
  36924. * Attach the input controls to a specific dom element to get the input from.
  36925. * @param element Defines the element the controls should be listened from
  36926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36927. */
  36928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36929. /**
  36930. * Detach the current controls from the specified dom element.
  36931. * @param element Defines the element to stop listening the inputs from
  36932. */
  36933. detachControl(element: Nullable<HTMLElement>): void;
  36934. /**
  36935. * Update the current camera state depending on the inputs that have been used this frame.
  36936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36937. */
  36938. checkInputs(): void;
  36939. /**
  36940. * Gets the class name of the current intput.
  36941. * @returns the class name
  36942. */
  36943. getClassName(): string;
  36944. /**
  36945. * Get the friendly name associated with the input class.
  36946. * @returns the input friendly name
  36947. */
  36948. getSimpleName(): string;
  36949. }
  36950. }
  36951. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36952. import { Nullable } from "babylonjs/types";
  36953. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36954. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36955. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36956. interface ArcRotateCameraInputsManager {
  36957. /**
  36958. * Add orientation input support to the input manager.
  36959. * @returns the current input manager
  36960. */
  36961. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36962. }
  36963. }
  36964. /**
  36965. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36967. */
  36968. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36969. /**
  36970. * Defines the camera the input is attached to.
  36971. */
  36972. camera: ArcRotateCamera;
  36973. /**
  36974. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36975. */
  36976. alphaCorrection: number;
  36977. /**
  36978. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36979. */
  36980. gammaCorrection: number;
  36981. private _alpha;
  36982. private _gamma;
  36983. private _dirty;
  36984. private _deviceOrientationHandler;
  36985. /**
  36986. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36987. */
  36988. constructor();
  36989. /**
  36990. * Attach the input controls to a specific dom element to get the input from.
  36991. * @param element Defines the element the controls should be listened from
  36992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36993. */
  36994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36995. /** @hidden */
  36996. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36997. /**
  36998. * Update the current camera state depending on the inputs that have been used this frame.
  36999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37000. */
  37001. checkInputs(): void;
  37002. /**
  37003. * Detach the current controls from the specified dom element.
  37004. * @param element Defines the element to stop listening the inputs from
  37005. */
  37006. detachControl(element: Nullable<HTMLElement>): void;
  37007. /**
  37008. * Gets the class name of the current intput.
  37009. * @returns the class name
  37010. */
  37011. getClassName(): string;
  37012. /**
  37013. * Get the friendly name associated with the input class.
  37014. * @returns the input friendly name
  37015. */
  37016. getSimpleName(): string;
  37017. }
  37018. }
  37019. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37020. import { Nullable } from "babylonjs/types";
  37021. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37022. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37023. /**
  37024. * Listen to mouse events to control the camera.
  37025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37026. */
  37027. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37028. /**
  37029. * Defines the camera the input is attached to.
  37030. */
  37031. camera: FlyCamera;
  37032. /**
  37033. * Defines if touch is enabled. (Default is true.)
  37034. */
  37035. touchEnabled: boolean;
  37036. /**
  37037. * Defines the buttons associated with the input to handle camera rotation.
  37038. */
  37039. buttons: number[];
  37040. /**
  37041. * Assign buttons for Yaw control.
  37042. */
  37043. buttonsYaw: number[];
  37044. /**
  37045. * Assign buttons for Pitch control.
  37046. */
  37047. buttonsPitch: number[];
  37048. /**
  37049. * Assign buttons for Roll control.
  37050. */
  37051. buttonsRoll: number[];
  37052. /**
  37053. * Detect if any button is being pressed while mouse is moved.
  37054. * -1 = Mouse locked.
  37055. * 0 = Left button.
  37056. * 1 = Middle Button.
  37057. * 2 = Right Button.
  37058. */
  37059. activeButton: number;
  37060. /**
  37061. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37062. * Higher values reduce its sensitivity.
  37063. */
  37064. angularSensibility: number;
  37065. private _mousemoveCallback;
  37066. private _observer;
  37067. private _rollObserver;
  37068. private previousPosition;
  37069. private noPreventDefault;
  37070. private element;
  37071. /**
  37072. * Listen to mouse events to control the camera.
  37073. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37075. */
  37076. constructor(touchEnabled?: boolean);
  37077. /**
  37078. * Attach the mouse control to the HTML DOM element.
  37079. * @param element Defines the element that listens to the input events.
  37080. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37081. */
  37082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37083. /**
  37084. * Detach the current controls from the specified dom element.
  37085. * @param element Defines the element to stop listening the inputs from
  37086. */
  37087. detachControl(element: Nullable<HTMLElement>): void;
  37088. /**
  37089. * Gets the class name of the current input.
  37090. * @returns the class name.
  37091. */
  37092. getClassName(): string;
  37093. /**
  37094. * Get the friendly name associated with the input class.
  37095. * @returns the input's friendly name.
  37096. */
  37097. getSimpleName(): string;
  37098. private _pointerInput;
  37099. private _onMouseMove;
  37100. /**
  37101. * Rotate camera by mouse offset.
  37102. */
  37103. private rotateCamera;
  37104. }
  37105. }
  37106. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37107. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37108. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37109. /**
  37110. * Default Inputs manager for the FlyCamera.
  37111. * It groups all the default supported inputs for ease of use.
  37112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37113. */
  37114. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37115. /**
  37116. * Instantiates a new FlyCameraInputsManager.
  37117. * @param camera Defines the camera the inputs belong to.
  37118. */
  37119. constructor(camera: FlyCamera);
  37120. /**
  37121. * Add keyboard input support to the input manager.
  37122. * @returns the new FlyCameraKeyboardMoveInput().
  37123. */
  37124. addKeyboard(): FlyCameraInputsManager;
  37125. /**
  37126. * Add mouse input support to the input manager.
  37127. * @param touchEnabled Enable touch screen support.
  37128. * @returns the new FlyCameraMouseInput().
  37129. */
  37130. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37131. }
  37132. }
  37133. declare module "babylonjs/Cameras/flyCamera" {
  37134. import { Scene } from "babylonjs/scene";
  37135. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37137. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37138. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37139. /**
  37140. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37141. * such as in a 3D Space Shooter or a Flight Simulator.
  37142. */
  37143. export class FlyCamera extends TargetCamera {
  37144. /**
  37145. * Define the collision ellipsoid of the camera.
  37146. * This is helpful for simulating a camera body, like a player's body.
  37147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37148. */
  37149. ellipsoid: Vector3;
  37150. /**
  37151. * Define an offset for the position of the ellipsoid around the camera.
  37152. * This can be helpful if the camera is attached away from the player's body center,
  37153. * such as at its head.
  37154. */
  37155. ellipsoidOffset: Vector3;
  37156. /**
  37157. * Enable or disable collisions of the camera with the rest of the scene objects.
  37158. */
  37159. checkCollisions: boolean;
  37160. /**
  37161. * Enable or disable gravity on the camera.
  37162. */
  37163. applyGravity: boolean;
  37164. /**
  37165. * Define the current direction the camera is moving to.
  37166. */
  37167. cameraDirection: Vector3;
  37168. /**
  37169. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37170. * This overrides and empties cameraRotation.
  37171. */
  37172. rotationQuaternion: Quaternion;
  37173. /**
  37174. * Track Roll to maintain the wanted Rolling when looking around.
  37175. */
  37176. _trackRoll: number;
  37177. /**
  37178. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37179. */
  37180. rollCorrect: number;
  37181. /**
  37182. * Mimic a banked turn, Rolling the camera when Yawing.
  37183. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37184. */
  37185. bankedTurn: boolean;
  37186. /**
  37187. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37188. */
  37189. bankedTurnLimit: number;
  37190. /**
  37191. * Value of 0 disables the banked Roll.
  37192. * Value of 1 is equal to the Yaw angle in radians.
  37193. */
  37194. bankedTurnMultiplier: number;
  37195. /**
  37196. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37197. */
  37198. inputs: FlyCameraInputsManager;
  37199. /**
  37200. * Gets the input sensibility for mouse input.
  37201. * Higher values reduce sensitivity.
  37202. */
  37203. /**
  37204. * Sets the input sensibility for a mouse input.
  37205. * Higher values reduce sensitivity.
  37206. */
  37207. angularSensibility: number;
  37208. /**
  37209. * Get the keys for camera movement forward.
  37210. */
  37211. /**
  37212. * Set the keys for camera movement forward.
  37213. */
  37214. keysForward: number[];
  37215. /**
  37216. * Get the keys for camera movement backward.
  37217. */
  37218. keysBackward: number[];
  37219. /**
  37220. * Get the keys for camera movement up.
  37221. */
  37222. /**
  37223. * Set the keys for camera movement up.
  37224. */
  37225. keysUp: number[];
  37226. /**
  37227. * Get the keys for camera movement down.
  37228. */
  37229. /**
  37230. * Set the keys for camera movement down.
  37231. */
  37232. keysDown: number[];
  37233. /**
  37234. * Get the keys for camera movement left.
  37235. */
  37236. /**
  37237. * Set the keys for camera movement left.
  37238. */
  37239. keysLeft: number[];
  37240. /**
  37241. * Set the keys for camera movement right.
  37242. */
  37243. /**
  37244. * Set the keys for camera movement right.
  37245. */
  37246. keysRight: number[];
  37247. /**
  37248. * Event raised when the camera collides with a mesh in the scene.
  37249. */
  37250. onCollide: (collidedMesh: AbstractMesh) => void;
  37251. private _collider;
  37252. private _needMoveForGravity;
  37253. private _oldPosition;
  37254. private _diffPosition;
  37255. private _newPosition;
  37256. /** @hidden */
  37257. _localDirection: Vector3;
  37258. /** @hidden */
  37259. _transformedDirection: Vector3;
  37260. /**
  37261. * Instantiates a FlyCamera.
  37262. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37263. * such as in a 3D Space Shooter or a Flight Simulator.
  37264. * @param name Define the name of the camera in the scene.
  37265. * @param position Define the starting position of the camera in the scene.
  37266. * @param scene Define the scene the camera belongs to.
  37267. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37268. */
  37269. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37270. /**
  37271. * Attach a control to the HTML DOM element.
  37272. * @param element Defines the element that listens to the input events.
  37273. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37274. */
  37275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37276. /**
  37277. * Detach a control from the HTML DOM element.
  37278. * The camera will stop reacting to that input.
  37279. * @param element Defines the element that listens to the input events.
  37280. */
  37281. detachControl(element: HTMLElement): void;
  37282. private _collisionMask;
  37283. /**
  37284. * Get the mask that the camera ignores in collision events.
  37285. */
  37286. /**
  37287. * Set the mask that the camera ignores in collision events.
  37288. */
  37289. collisionMask: number;
  37290. /** @hidden */
  37291. _collideWithWorld(displacement: Vector3): void;
  37292. /** @hidden */
  37293. private _onCollisionPositionChange;
  37294. /** @hidden */
  37295. _checkInputs(): void;
  37296. /** @hidden */
  37297. _decideIfNeedsToMove(): boolean;
  37298. /** @hidden */
  37299. _updatePosition(): void;
  37300. /**
  37301. * Restore the Roll to its target value at the rate specified.
  37302. * @param rate - Higher means slower restoring.
  37303. * @hidden
  37304. */
  37305. restoreRoll(rate: number): void;
  37306. /**
  37307. * Destroy the camera and release the current resources held by it.
  37308. */
  37309. dispose(): void;
  37310. /**
  37311. * Get the current object class name.
  37312. * @returns the class name.
  37313. */
  37314. getClassName(): string;
  37315. }
  37316. }
  37317. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37318. import { Nullable } from "babylonjs/types";
  37319. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37320. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37321. /**
  37322. * Listen to keyboard events to control the camera.
  37323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37324. */
  37325. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37326. /**
  37327. * Defines the camera the input is attached to.
  37328. */
  37329. camera: FlyCamera;
  37330. /**
  37331. * The list of keyboard keys used to control the forward move of the camera.
  37332. */
  37333. keysForward: number[];
  37334. /**
  37335. * The list of keyboard keys used to control the backward move of the camera.
  37336. */
  37337. keysBackward: number[];
  37338. /**
  37339. * The list of keyboard keys used to control the forward move of the camera.
  37340. */
  37341. keysUp: number[];
  37342. /**
  37343. * The list of keyboard keys used to control the backward move of the camera.
  37344. */
  37345. keysDown: number[];
  37346. /**
  37347. * The list of keyboard keys used to control the right strafe move of the camera.
  37348. */
  37349. keysRight: number[];
  37350. /**
  37351. * The list of keyboard keys used to control the left strafe move of the camera.
  37352. */
  37353. keysLeft: number[];
  37354. private _keys;
  37355. private _onCanvasBlurObserver;
  37356. private _onKeyboardObserver;
  37357. private _engine;
  37358. private _scene;
  37359. /**
  37360. * Attach the input controls to a specific dom element to get the input from.
  37361. * @param element Defines the element the controls should be listened from
  37362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37363. */
  37364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37365. /**
  37366. * Detach the current controls from the specified dom element.
  37367. * @param element Defines the element to stop listening the inputs from
  37368. */
  37369. detachControl(element: Nullable<HTMLElement>): void;
  37370. /**
  37371. * Gets the class name of the current intput.
  37372. * @returns the class name
  37373. */
  37374. getClassName(): string;
  37375. /** @hidden */
  37376. _onLostFocus(e: FocusEvent): void;
  37377. /**
  37378. * Get the friendly name associated with the input class.
  37379. * @returns the input friendly name
  37380. */
  37381. getSimpleName(): string;
  37382. /**
  37383. * Update the current camera state depending on the inputs that have been used this frame.
  37384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37385. */
  37386. checkInputs(): void;
  37387. }
  37388. }
  37389. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37390. import { Nullable } from "babylonjs/types";
  37391. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37392. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37393. /**
  37394. * Manage the mouse wheel inputs to control a follow camera.
  37395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37396. */
  37397. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37398. /**
  37399. * Defines the camera the input is attached to.
  37400. */
  37401. camera: FollowCamera;
  37402. /**
  37403. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37404. */
  37405. axisControlRadius: boolean;
  37406. /**
  37407. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37408. */
  37409. axisControlHeight: boolean;
  37410. /**
  37411. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37412. */
  37413. axisControlRotation: boolean;
  37414. /**
  37415. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37416. * relation to mouseWheel events.
  37417. */
  37418. wheelPrecision: number;
  37419. /**
  37420. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37421. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37422. */
  37423. wheelDeltaPercentage: number;
  37424. private _wheel;
  37425. private _observer;
  37426. /**
  37427. * Attach the input controls to a specific dom element to get the input from.
  37428. * @param element Defines the element the controls should be listened from
  37429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37430. */
  37431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37432. /**
  37433. * Detach the current controls from the specified dom element.
  37434. * @param element Defines the element to stop listening the inputs from
  37435. */
  37436. detachControl(element: Nullable<HTMLElement>): void;
  37437. /**
  37438. * Gets the class name of the current intput.
  37439. * @returns the class name
  37440. */
  37441. getClassName(): string;
  37442. /**
  37443. * Get the friendly name associated with the input class.
  37444. * @returns the input friendly name
  37445. */
  37446. getSimpleName(): string;
  37447. }
  37448. }
  37449. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37450. import { Nullable } from "babylonjs/types";
  37451. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37452. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37453. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37454. /**
  37455. * Manage the pointers inputs to control an follow camera.
  37456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37457. */
  37458. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37459. /**
  37460. * Defines the camera the input is attached to.
  37461. */
  37462. camera: FollowCamera;
  37463. /**
  37464. * Gets the class name of the current input.
  37465. * @returns the class name
  37466. */
  37467. getClassName(): string;
  37468. /**
  37469. * Defines the pointer angular sensibility along the X axis or how fast is
  37470. * the camera rotating.
  37471. * A negative number will reverse the axis direction.
  37472. */
  37473. angularSensibilityX: number;
  37474. /**
  37475. * Defines the pointer angular sensibility along the Y axis or how fast is
  37476. * the camera rotating.
  37477. * A negative number will reverse the axis direction.
  37478. */
  37479. angularSensibilityY: number;
  37480. /**
  37481. * Defines the pointer pinch precision or how fast is the camera zooming.
  37482. * A negative number will reverse the axis direction.
  37483. */
  37484. pinchPrecision: number;
  37485. /**
  37486. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37487. * from 0.
  37488. * It defines the percentage of current camera.radius to use as delta when
  37489. * pinch zoom is used.
  37490. */
  37491. pinchDeltaPercentage: number;
  37492. /**
  37493. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37494. */
  37495. axisXControlRadius: boolean;
  37496. /**
  37497. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37498. */
  37499. axisXControlHeight: boolean;
  37500. /**
  37501. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37502. */
  37503. axisXControlRotation: boolean;
  37504. /**
  37505. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37506. */
  37507. axisYControlRadius: boolean;
  37508. /**
  37509. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37510. */
  37511. axisYControlHeight: boolean;
  37512. /**
  37513. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37514. */
  37515. axisYControlRotation: boolean;
  37516. /**
  37517. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37518. */
  37519. axisPinchControlRadius: boolean;
  37520. /**
  37521. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37522. */
  37523. axisPinchControlHeight: boolean;
  37524. /**
  37525. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37526. */
  37527. axisPinchControlRotation: boolean;
  37528. /**
  37529. * Log error messages if basic misconfiguration has occurred.
  37530. */
  37531. warningEnable: boolean;
  37532. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37533. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37534. private _warningCounter;
  37535. private _warning;
  37536. }
  37537. }
  37538. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37539. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37540. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37541. /**
  37542. * Default Inputs manager for the FollowCamera.
  37543. * It groups all the default supported inputs for ease of use.
  37544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37545. */
  37546. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37547. /**
  37548. * Instantiates a new FollowCameraInputsManager.
  37549. * @param camera Defines the camera the inputs belong to
  37550. */
  37551. constructor(camera: FollowCamera);
  37552. /**
  37553. * Add keyboard input support to the input manager.
  37554. * @returns the current input manager
  37555. */
  37556. addKeyboard(): FollowCameraInputsManager;
  37557. /**
  37558. * Add mouse wheel input support to the input manager.
  37559. * @returns the current input manager
  37560. */
  37561. addMouseWheel(): FollowCameraInputsManager;
  37562. /**
  37563. * Add pointers input support to the input manager.
  37564. * @returns the current input manager
  37565. */
  37566. addPointers(): FollowCameraInputsManager;
  37567. /**
  37568. * Add orientation input support to the input manager.
  37569. * @returns the current input manager
  37570. */
  37571. addVRDeviceOrientation(): FollowCameraInputsManager;
  37572. }
  37573. }
  37574. declare module "babylonjs/Cameras/followCamera" {
  37575. import { Nullable } from "babylonjs/types";
  37576. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37577. import { Scene } from "babylonjs/scene";
  37578. import { Vector3 } from "babylonjs/Maths/math";
  37579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37580. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37581. /**
  37582. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37583. * an arc rotate version arcFollowCamera are available.
  37584. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37585. */
  37586. export class FollowCamera extends TargetCamera {
  37587. /**
  37588. * Distance the follow camera should follow an object at
  37589. */
  37590. radius: number;
  37591. /**
  37592. * Minimum allowed distance of the camera to the axis of rotation
  37593. * (The camera can not get closer).
  37594. * This can help limiting how the Camera is able to move in the scene.
  37595. */
  37596. lowerRadiusLimit: Nullable<number>;
  37597. /**
  37598. * Maximum allowed distance of the camera to the axis of rotation
  37599. * (The camera can not get further).
  37600. * This can help limiting how the Camera is able to move in the scene.
  37601. */
  37602. upperRadiusLimit: Nullable<number>;
  37603. /**
  37604. * Define a rotation offset between the camera and the object it follows
  37605. */
  37606. rotationOffset: number;
  37607. /**
  37608. * Minimum allowed angle to camera position relative to target object.
  37609. * This can help limiting how the Camera is able to move in the scene.
  37610. */
  37611. lowerRotationOffsetLimit: Nullable<number>;
  37612. /**
  37613. * Maximum allowed angle to camera position relative to target object.
  37614. * This can help limiting how the Camera is able to move in the scene.
  37615. */
  37616. upperRotationOffsetLimit: Nullable<number>;
  37617. /**
  37618. * Define a height offset between the camera and the object it follows.
  37619. * It can help following an object from the top (like a car chaing a plane)
  37620. */
  37621. heightOffset: number;
  37622. /**
  37623. * Minimum allowed height of camera position relative to target object.
  37624. * This can help limiting how the Camera is able to move in the scene.
  37625. */
  37626. lowerHeightOffsetLimit: Nullable<number>;
  37627. /**
  37628. * Maximum allowed height of camera position relative to target object.
  37629. * This can help limiting how the Camera is able to move in the scene.
  37630. */
  37631. upperHeightOffsetLimit: Nullable<number>;
  37632. /**
  37633. * Define how fast the camera can accelerate to follow it s target.
  37634. */
  37635. cameraAcceleration: number;
  37636. /**
  37637. * Define the speed limit of the camera following an object.
  37638. */
  37639. maxCameraSpeed: number;
  37640. /**
  37641. * Define the target of the camera.
  37642. */
  37643. lockedTarget: Nullable<AbstractMesh>;
  37644. /**
  37645. * Defines the input associated with the camera.
  37646. */
  37647. inputs: FollowCameraInputsManager;
  37648. /**
  37649. * Instantiates the follow camera.
  37650. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37651. * @param name Define the name of the camera in the scene
  37652. * @param position Define the position of the camera
  37653. * @param scene Define the scene the camera belong to
  37654. * @param lockedTarget Define the target of the camera
  37655. */
  37656. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37657. private _follow;
  37658. /**
  37659. * Attached controls to the current camera.
  37660. * @param element Defines the element the controls should be listened from
  37661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37662. */
  37663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37664. /**
  37665. * Detach the current controls from the camera.
  37666. * The camera will stop reacting to inputs.
  37667. * @param element Defines the element to stop listening the inputs from
  37668. */
  37669. detachControl(element: HTMLElement): void;
  37670. /** @hidden */
  37671. _checkInputs(): void;
  37672. private _checkLimits;
  37673. /**
  37674. * Gets the camera class name.
  37675. * @returns the class name
  37676. */
  37677. getClassName(): string;
  37678. }
  37679. /**
  37680. * Arc Rotate version of the follow camera.
  37681. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37683. */
  37684. export class ArcFollowCamera extends TargetCamera {
  37685. /** The longitudinal angle of the camera */
  37686. alpha: number;
  37687. /** The latitudinal angle of the camera */
  37688. beta: number;
  37689. /** The radius of the camera from its target */
  37690. radius: number;
  37691. /** Define the camera target (the messh it should follow) */
  37692. target: Nullable<AbstractMesh>;
  37693. private _cartesianCoordinates;
  37694. /**
  37695. * Instantiates a new ArcFollowCamera
  37696. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37697. * @param name Define the name of the camera
  37698. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37699. * @param beta Define the rotation angle of the camera around the elevation axis
  37700. * @param radius Define the radius of the camera from its target point
  37701. * @param target Define the target of the camera
  37702. * @param scene Define the scene the camera belongs to
  37703. */
  37704. constructor(name: string,
  37705. /** The longitudinal angle of the camera */
  37706. alpha: number,
  37707. /** The latitudinal angle of the camera */
  37708. beta: number,
  37709. /** The radius of the camera from its target */
  37710. radius: number,
  37711. /** Define the camera target (the messh it should follow) */
  37712. target: Nullable<AbstractMesh>, scene: Scene);
  37713. private _follow;
  37714. /** @hidden */
  37715. _checkInputs(): void;
  37716. /**
  37717. * Returns the class name of the object.
  37718. * It is mostly used internally for serialization purposes.
  37719. */
  37720. getClassName(): string;
  37721. }
  37722. }
  37723. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37724. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37725. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37726. import { Nullable } from "babylonjs/types";
  37727. /**
  37728. * Manage the keyboard inputs to control the movement of a follow camera.
  37729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37730. */
  37731. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37732. /**
  37733. * Defines the camera the input is attached to.
  37734. */
  37735. camera: FollowCamera;
  37736. /**
  37737. * Defines the list of key codes associated with the up action (increase heightOffset)
  37738. */
  37739. keysHeightOffsetIncr: number[];
  37740. /**
  37741. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37742. */
  37743. keysHeightOffsetDecr: number[];
  37744. /**
  37745. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37746. */
  37747. keysHeightOffsetModifierAlt: boolean;
  37748. /**
  37749. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37750. */
  37751. keysHeightOffsetModifierCtrl: boolean;
  37752. /**
  37753. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37754. */
  37755. keysHeightOffsetModifierShift: boolean;
  37756. /**
  37757. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37758. */
  37759. keysRotationOffsetIncr: number[];
  37760. /**
  37761. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37762. */
  37763. keysRotationOffsetDecr: number[];
  37764. /**
  37765. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37766. */
  37767. keysRotationOffsetModifierAlt: boolean;
  37768. /**
  37769. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37770. */
  37771. keysRotationOffsetModifierCtrl: boolean;
  37772. /**
  37773. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37774. */
  37775. keysRotationOffsetModifierShift: boolean;
  37776. /**
  37777. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37778. */
  37779. keysRadiusIncr: number[];
  37780. /**
  37781. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37782. */
  37783. keysRadiusDecr: number[];
  37784. /**
  37785. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37786. */
  37787. keysRadiusModifierAlt: boolean;
  37788. /**
  37789. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37790. */
  37791. keysRadiusModifierCtrl: boolean;
  37792. /**
  37793. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37794. */
  37795. keysRadiusModifierShift: boolean;
  37796. /**
  37797. * Defines the rate of change of heightOffset.
  37798. */
  37799. heightSensibility: number;
  37800. /**
  37801. * Defines the rate of change of rotationOffset.
  37802. */
  37803. rotationSensibility: number;
  37804. /**
  37805. * Defines the rate of change of radius.
  37806. */
  37807. radiusSensibility: number;
  37808. private _keys;
  37809. private _ctrlPressed;
  37810. private _altPressed;
  37811. private _shiftPressed;
  37812. private _onCanvasBlurObserver;
  37813. private _onKeyboardObserver;
  37814. private _engine;
  37815. private _scene;
  37816. /**
  37817. * Attach the input controls to a specific dom element to get the input from.
  37818. * @param element Defines the element the controls should be listened from
  37819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37820. */
  37821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37822. /**
  37823. * Detach the current controls from the specified dom element.
  37824. * @param element Defines the element to stop listening the inputs from
  37825. */
  37826. detachControl(element: Nullable<HTMLElement>): void;
  37827. /**
  37828. * Update the current camera state depending on the inputs that have been used this frame.
  37829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37830. */
  37831. checkInputs(): void;
  37832. /**
  37833. * Gets the class name of the current input.
  37834. * @returns the class name
  37835. */
  37836. getClassName(): string;
  37837. /**
  37838. * Get the friendly name associated with the input class.
  37839. * @returns the input friendly name
  37840. */
  37841. getSimpleName(): string;
  37842. /**
  37843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37844. * allow modification of the heightOffset value.
  37845. */
  37846. private _modifierHeightOffset;
  37847. /**
  37848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37849. * allow modification of the rotationOffset value.
  37850. */
  37851. private _modifierRotationOffset;
  37852. /**
  37853. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37854. * allow modification of the radius value.
  37855. */
  37856. private _modifierRadius;
  37857. }
  37858. }
  37859. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37860. import { Nullable } from "babylonjs/types";
  37861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37862. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37863. import { Observable } from "babylonjs/Misc/observable";
  37864. module "babylonjs/Cameras/freeCameraInputsManager" {
  37865. interface FreeCameraInputsManager {
  37866. /**
  37867. * @hidden
  37868. */
  37869. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37870. /**
  37871. * Add orientation input support to the input manager.
  37872. * @returns the current input manager
  37873. */
  37874. addDeviceOrientation(): FreeCameraInputsManager;
  37875. }
  37876. }
  37877. /**
  37878. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37879. * Screen rotation is taken into account.
  37880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37881. */
  37882. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37883. private _camera;
  37884. private _screenOrientationAngle;
  37885. private _constantTranform;
  37886. private _screenQuaternion;
  37887. private _alpha;
  37888. private _beta;
  37889. private _gamma;
  37890. /**
  37891. * @hidden
  37892. */
  37893. _onDeviceOrientationChangedObservable: Observable<void>;
  37894. /**
  37895. * Instantiates a new input
  37896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37897. */
  37898. constructor();
  37899. /**
  37900. * Define the camera controlled by the input.
  37901. */
  37902. camera: FreeCamera;
  37903. /**
  37904. * Attach the input controls to a specific dom element to get the input from.
  37905. * @param element Defines the element the controls should be listened from
  37906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37907. */
  37908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37909. private _orientationChanged;
  37910. private _deviceOrientation;
  37911. /**
  37912. * Detach the current controls from the specified dom element.
  37913. * @param element Defines the element to stop listening the inputs from
  37914. */
  37915. detachControl(element: Nullable<HTMLElement>): void;
  37916. /**
  37917. * Update the current camera state depending on the inputs that have been used this frame.
  37918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37919. */
  37920. checkInputs(): void;
  37921. /**
  37922. * Gets the class name of the current intput.
  37923. * @returns the class name
  37924. */
  37925. getClassName(): string;
  37926. /**
  37927. * Get the friendly name associated with the input class.
  37928. * @returns the input friendly name
  37929. */
  37930. getSimpleName(): string;
  37931. }
  37932. }
  37933. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37934. import { Nullable } from "babylonjs/types";
  37935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37937. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37938. /**
  37939. * Manage the gamepad inputs to control a free camera.
  37940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37941. */
  37942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37943. /**
  37944. * Define the camera the input is attached to.
  37945. */
  37946. camera: FreeCamera;
  37947. /**
  37948. * Define the Gamepad controlling the input
  37949. */
  37950. gamepad: Nullable<Gamepad>;
  37951. /**
  37952. * Defines the gamepad rotation sensiblity.
  37953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37954. */
  37955. gamepadAngularSensibility: number;
  37956. /**
  37957. * Defines the gamepad move sensiblity.
  37958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37959. */
  37960. gamepadMoveSensibility: number;
  37961. private _onGamepadConnectedObserver;
  37962. private _onGamepadDisconnectedObserver;
  37963. private _cameraTransform;
  37964. private _deltaTransform;
  37965. private _vector3;
  37966. private _vector2;
  37967. /**
  37968. * Attach the input controls to a specific dom element to get the input from.
  37969. * @param element Defines the element the controls should be listened from
  37970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37971. */
  37972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37973. /**
  37974. * Detach the current controls from the specified dom element.
  37975. * @param element Defines the element to stop listening the inputs from
  37976. */
  37977. detachControl(element: Nullable<HTMLElement>): void;
  37978. /**
  37979. * Update the current camera state depending on the inputs that have been used this frame.
  37980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37981. */
  37982. checkInputs(): void;
  37983. /**
  37984. * Gets the class name of the current intput.
  37985. * @returns the class name
  37986. */
  37987. getClassName(): string;
  37988. /**
  37989. * Get the friendly name associated with the input class.
  37990. * @returns the input friendly name
  37991. */
  37992. getSimpleName(): string;
  37993. }
  37994. }
  37995. declare module "babylonjs/Misc/virtualJoystick" {
  37996. import { Nullable } from "babylonjs/types";
  37997. import { Vector3 } from "babylonjs/Maths/math";
  37998. /**
  37999. * Defines the potential axis of a Joystick
  38000. */
  38001. export enum JoystickAxis {
  38002. /** X axis */
  38003. X = 0,
  38004. /** Y axis */
  38005. Y = 1,
  38006. /** Z axis */
  38007. Z = 2
  38008. }
  38009. /**
  38010. * Class used to define virtual joystick (used in touch mode)
  38011. */
  38012. export class VirtualJoystick {
  38013. /**
  38014. * Gets or sets a boolean indicating that left and right values must be inverted
  38015. */
  38016. reverseLeftRight: boolean;
  38017. /**
  38018. * Gets or sets a boolean indicating that up and down values must be inverted
  38019. */
  38020. reverseUpDown: boolean;
  38021. /**
  38022. * Gets the offset value for the position (ie. the change of the position value)
  38023. */
  38024. deltaPosition: Vector3;
  38025. /**
  38026. * Gets a boolean indicating if the virtual joystick was pressed
  38027. */
  38028. pressed: boolean;
  38029. /**
  38030. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38031. */
  38032. static Canvas: Nullable<HTMLCanvasElement>;
  38033. private static _globalJoystickIndex;
  38034. private static vjCanvasContext;
  38035. private static vjCanvasWidth;
  38036. private static vjCanvasHeight;
  38037. private static halfWidth;
  38038. private _action;
  38039. private _axisTargetedByLeftAndRight;
  38040. private _axisTargetedByUpAndDown;
  38041. private _joystickSensibility;
  38042. private _inversedSensibility;
  38043. private _joystickPointerID;
  38044. private _joystickColor;
  38045. private _joystickPointerPos;
  38046. private _joystickPreviousPointerPos;
  38047. private _joystickPointerStartPos;
  38048. private _deltaJoystickVector;
  38049. private _leftJoystick;
  38050. private _touches;
  38051. private _onPointerDownHandlerRef;
  38052. private _onPointerMoveHandlerRef;
  38053. private _onPointerUpHandlerRef;
  38054. private _onResize;
  38055. /**
  38056. * Creates a new virtual joystick
  38057. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38058. */
  38059. constructor(leftJoystick?: boolean);
  38060. /**
  38061. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38062. * @param newJoystickSensibility defines the new sensibility
  38063. */
  38064. setJoystickSensibility(newJoystickSensibility: number): void;
  38065. private _onPointerDown;
  38066. private _onPointerMove;
  38067. private _onPointerUp;
  38068. /**
  38069. * Change the color of the virtual joystick
  38070. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38071. */
  38072. setJoystickColor(newColor: string): void;
  38073. /**
  38074. * Defines a callback to call when the joystick is touched
  38075. * @param action defines the callback
  38076. */
  38077. setActionOnTouch(action: () => any): void;
  38078. /**
  38079. * Defines which axis you'd like to control for left & right
  38080. * @param axis defines the axis to use
  38081. */
  38082. setAxisForLeftRight(axis: JoystickAxis): void;
  38083. /**
  38084. * Defines which axis you'd like to control for up & down
  38085. * @param axis defines the axis to use
  38086. */
  38087. setAxisForUpDown(axis: JoystickAxis): void;
  38088. private _drawVirtualJoystick;
  38089. /**
  38090. * Release internal HTML canvas
  38091. */
  38092. releaseCanvas(): void;
  38093. }
  38094. }
  38095. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38096. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38097. import { Nullable } from "babylonjs/types";
  38098. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38099. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38100. module "babylonjs/Cameras/freeCameraInputsManager" {
  38101. interface FreeCameraInputsManager {
  38102. /**
  38103. * Add virtual joystick input support to the input manager.
  38104. * @returns the current input manager
  38105. */
  38106. addVirtualJoystick(): FreeCameraInputsManager;
  38107. }
  38108. }
  38109. /**
  38110. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38112. */
  38113. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38114. /**
  38115. * Defines the camera the input is attached to.
  38116. */
  38117. camera: FreeCamera;
  38118. private _leftjoystick;
  38119. private _rightjoystick;
  38120. /**
  38121. * Gets the left stick of the virtual joystick.
  38122. * @returns The virtual Joystick
  38123. */
  38124. getLeftJoystick(): VirtualJoystick;
  38125. /**
  38126. * Gets the right stick of the virtual joystick.
  38127. * @returns The virtual Joystick
  38128. */
  38129. getRightJoystick(): VirtualJoystick;
  38130. /**
  38131. * Update the current camera state depending on the inputs that have been used this frame.
  38132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38133. */
  38134. checkInputs(): void;
  38135. /**
  38136. * Attach the input controls to a specific dom element to get the input from.
  38137. * @param element Defines the element the controls should be listened from
  38138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38139. */
  38140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38141. /**
  38142. * Detach the current controls from the specified dom element.
  38143. * @param element Defines the element to stop listening the inputs from
  38144. */
  38145. detachControl(element: Nullable<HTMLElement>): void;
  38146. /**
  38147. * Gets the class name of the current intput.
  38148. * @returns the class name
  38149. */
  38150. getClassName(): string;
  38151. /**
  38152. * Get the friendly name associated with the input class.
  38153. * @returns the input friendly name
  38154. */
  38155. getSimpleName(): string;
  38156. }
  38157. }
  38158. declare module "babylonjs/Cameras/Inputs/index" {
  38159. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38160. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38161. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38162. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38163. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38164. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38165. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38166. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38167. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38168. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38169. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38170. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38171. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38172. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38173. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38174. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38175. }
  38176. declare module "babylonjs/Cameras/touchCamera" {
  38177. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38178. import { Scene } from "babylonjs/scene";
  38179. import { Vector3 } from "babylonjs/Maths/math";
  38180. /**
  38181. * This represents a FPS type of camera controlled by touch.
  38182. * This is like a universal camera minus the Gamepad controls.
  38183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38184. */
  38185. export class TouchCamera extends FreeCamera {
  38186. /**
  38187. * Defines the touch sensibility for rotation.
  38188. * The higher the faster.
  38189. */
  38190. touchAngularSensibility: number;
  38191. /**
  38192. * Defines the touch sensibility for move.
  38193. * The higher the faster.
  38194. */
  38195. touchMoveSensibility: number;
  38196. /**
  38197. * Instantiates a new touch camera.
  38198. * This represents a FPS type of camera controlled by touch.
  38199. * This is like a universal camera minus the Gamepad controls.
  38200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38201. * @param name Define the name of the camera in the scene
  38202. * @param position Define the start position of the camera in the scene
  38203. * @param scene Define the scene the camera belongs to
  38204. */
  38205. constructor(name: string, position: Vector3, scene: Scene);
  38206. /**
  38207. * Gets the current object class name.
  38208. * @return the class name
  38209. */
  38210. getClassName(): string;
  38211. /** @hidden */
  38212. _setupInputs(): void;
  38213. }
  38214. }
  38215. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38216. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38217. import { Scene } from "babylonjs/scene";
  38218. import { Vector3, Axis } from "babylonjs/Maths/math";
  38219. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38220. /**
  38221. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38222. * being tilted forward or back and left or right.
  38223. */
  38224. export class DeviceOrientationCamera extends FreeCamera {
  38225. private _initialQuaternion;
  38226. private _quaternionCache;
  38227. private _tmpDragQuaternion;
  38228. /**
  38229. * Creates a new device orientation camera
  38230. * @param name The name of the camera
  38231. * @param position The start position camera
  38232. * @param scene The scene the camera belongs to
  38233. */
  38234. constructor(name: string, position: Vector3, scene: Scene);
  38235. /**
  38236. * Disabled pointer input on first orientation sensor update (Default: true)
  38237. */
  38238. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38239. private _dragFactor;
  38240. /**
  38241. * Enabled turning on the y axis when the orientation sensor is active
  38242. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38243. */
  38244. enableHorizontalDragging(dragFactor?: number): void;
  38245. /**
  38246. * Gets the current instance class name ("DeviceOrientationCamera").
  38247. * This helps avoiding instanceof at run time.
  38248. * @returns the class name
  38249. */
  38250. getClassName(): string;
  38251. /**
  38252. * @hidden
  38253. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38254. */
  38255. _checkInputs(): void;
  38256. /**
  38257. * Reset the camera to its default orientation on the specified axis only.
  38258. * @param axis The axis to reset
  38259. */
  38260. resetToCurrentRotation(axis?: Axis): void;
  38261. }
  38262. }
  38263. declare module "babylonjs/Cameras/universalCamera" {
  38264. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38265. import { Scene } from "babylonjs/scene";
  38266. import { Vector3 } from "babylonjs/Maths/math";
  38267. /**
  38268. * 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,
  38269. * which still works and will still be found in many Playgrounds.
  38270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38271. */
  38272. export class UniversalCamera extends TouchCamera {
  38273. /**
  38274. * Defines the gamepad rotation sensiblity.
  38275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38276. */
  38277. gamepadAngularSensibility: number;
  38278. /**
  38279. * Defines the gamepad move sensiblity.
  38280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38281. */
  38282. gamepadMoveSensibility: number;
  38283. /**
  38284. * 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,
  38285. * which still works and will still be found in many Playgrounds.
  38286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38287. * @param name Define the name of the camera in the scene
  38288. * @param position Define the start position of the camera in the scene
  38289. * @param scene Define the scene the camera belongs to
  38290. */
  38291. constructor(name: string, position: Vector3, scene: Scene);
  38292. /**
  38293. * Gets the current object class name.
  38294. * @return the class name
  38295. */
  38296. getClassName(): string;
  38297. }
  38298. }
  38299. declare module "babylonjs/Cameras/gamepadCamera" {
  38300. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38301. import { Scene } from "babylonjs/scene";
  38302. import { Vector3 } from "babylonjs/Maths/math";
  38303. /**
  38304. * This represents a FPS type of camera. This is only here for back compat purpose.
  38305. * Please use the UniversalCamera instead as both are identical.
  38306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38307. */
  38308. export class GamepadCamera extends UniversalCamera {
  38309. /**
  38310. * Instantiates a new Gamepad Camera
  38311. * This represents a FPS type of camera. This is only here for back compat purpose.
  38312. * Please use the UniversalCamera instead as both are identical.
  38313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38314. * @param name Define the name of the camera in the scene
  38315. * @param position Define the start position of the camera in the scene
  38316. * @param scene Define the scene the camera belongs to
  38317. */
  38318. constructor(name: string, position: Vector3, scene: Scene);
  38319. /**
  38320. * Gets the current object class name.
  38321. * @return the class name
  38322. */
  38323. getClassName(): string;
  38324. }
  38325. }
  38326. declare module "babylonjs/Shaders/pass.fragment" {
  38327. /** @hidden */
  38328. export var passPixelShader: {
  38329. name: string;
  38330. shader: string;
  38331. };
  38332. }
  38333. declare module "babylonjs/Shaders/passCube.fragment" {
  38334. /** @hidden */
  38335. export var passCubePixelShader: {
  38336. name: string;
  38337. shader: string;
  38338. };
  38339. }
  38340. declare module "babylonjs/PostProcesses/passPostProcess" {
  38341. import { Nullable } from "babylonjs/types";
  38342. import { Camera } from "babylonjs/Cameras/camera";
  38343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38344. import { Engine } from "babylonjs/Engines/engine";
  38345. import "babylonjs/Shaders/pass.fragment";
  38346. import "babylonjs/Shaders/passCube.fragment";
  38347. /**
  38348. * PassPostProcess which produces an output the same as it's input
  38349. */
  38350. export class PassPostProcess extends PostProcess {
  38351. /**
  38352. * Creates the PassPostProcess
  38353. * @param name The name of the effect.
  38354. * @param options The required width/height ratio to downsize to before computing the render pass.
  38355. * @param camera The camera to apply the render pass to.
  38356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38357. * @param engine The engine which the post process will be applied. (default: current engine)
  38358. * @param reusable If the post process can be reused on the same frame. (default: false)
  38359. * @param textureType The type of texture to be used when performing the post processing.
  38360. * @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)
  38361. */
  38362. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38363. }
  38364. /**
  38365. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38366. */
  38367. export class PassCubePostProcess extends PostProcess {
  38368. private _face;
  38369. /**
  38370. * Gets or sets the cube face to display.
  38371. * * 0 is +X
  38372. * * 1 is -X
  38373. * * 2 is +Y
  38374. * * 3 is -Y
  38375. * * 4 is +Z
  38376. * * 5 is -Z
  38377. */
  38378. face: number;
  38379. /**
  38380. * Creates the PassCubePostProcess
  38381. * @param name The name of the effect.
  38382. * @param options The required width/height ratio to downsize to before computing the render pass.
  38383. * @param camera The camera to apply the render pass to.
  38384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38385. * @param engine The engine which the post process will be applied. (default: current engine)
  38386. * @param reusable If the post process can be reused on the same frame. (default: false)
  38387. * @param textureType The type of texture to be used when performing the post processing.
  38388. * @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)
  38389. */
  38390. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38391. }
  38392. }
  38393. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38394. /** @hidden */
  38395. export var anaglyphPixelShader: {
  38396. name: string;
  38397. shader: string;
  38398. };
  38399. }
  38400. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38401. import { Engine } from "babylonjs/Engines/engine";
  38402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38403. import { Camera } from "babylonjs/Cameras/camera";
  38404. import "babylonjs/Shaders/anaglyph.fragment";
  38405. /**
  38406. * Postprocess used to generate anaglyphic rendering
  38407. */
  38408. export class AnaglyphPostProcess extends PostProcess {
  38409. private _passedProcess;
  38410. /**
  38411. * Creates a new AnaglyphPostProcess
  38412. * @param name defines postprocess name
  38413. * @param options defines creation options or target ratio scale
  38414. * @param rigCameras defines cameras using this postprocess
  38415. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38416. * @param engine defines hosting engine
  38417. * @param reusable defines if the postprocess will be reused multiple times per frame
  38418. */
  38419. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38420. }
  38421. }
  38422. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38423. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38424. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38425. import { Scene } from "babylonjs/scene";
  38426. import { Vector3 } from "babylonjs/Maths/math";
  38427. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38428. /**
  38429. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38430. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38431. */
  38432. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38433. /**
  38434. * Creates a new AnaglyphArcRotateCamera
  38435. * @param name defines camera name
  38436. * @param alpha defines alpha angle (in radians)
  38437. * @param beta defines beta angle (in radians)
  38438. * @param radius defines radius
  38439. * @param target defines camera target
  38440. * @param interaxialDistance defines distance between each color axis
  38441. * @param scene defines the hosting scene
  38442. */
  38443. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38444. /**
  38445. * Gets camera class name
  38446. * @returns AnaglyphArcRotateCamera
  38447. */
  38448. getClassName(): string;
  38449. }
  38450. }
  38451. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38452. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38453. import { Scene } from "babylonjs/scene";
  38454. import { Vector3 } from "babylonjs/Maths/math";
  38455. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38456. /**
  38457. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38458. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38459. */
  38460. export class AnaglyphFreeCamera extends FreeCamera {
  38461. /**
  38462. * Creates a new AnaglyphFreeCamera
  38463. * @param name defines camera name
  38464. * @param position defines initial position
  38465. * @param interaxialDistance defines distance between each color axis
  38466. * @param scene defines the hosting scene
  38467. */
  38468. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38469. /**
  38470. * Gets camera class name
  38471. * @returns AnaglyphFreeCamera
  38472. */
  38473. getClassName(): string;
  38474. }
  38475. }
  38476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38477. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38478. import { Scene } from "babylonjs/scene";
  38479. import { Vector3 } from "babylonjs/Maths/math";
  38480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38481. /**
  38482. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38484. */
  38485. export class AnaglyphGamepadCamera extends GamepadCamera {
  38486. /**
  38487. * Creates a new AnaglyphGamepadCamera
  38488. * @param name defines camera name
  38489. * @param position defines initial position
  38490. * @param interaxialDistance defines distance between each color axis
  38491. * @param scene defines the hosting scene
  38492. */
  38493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38494. /**
  38495. * Gets camera class name
  38496. * @returns AnaglyphGamepadCamera
  38497. */
  38498. getClassName(): string;
  38499. }
  38500. }
  38501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38502. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38503. import { Scene } from "babylonjs/scene";
  38504. import { Vector3 } from "babylonjs/Maths/math";
  38505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38506. /**
  38507. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38509. */
  38510. export class AnaglyphUniversalCamera extends UniversalCamera {
  38511. /**
  38512. * Creates a new AnaglyphUniversalCamera
  38513. * @param name defines camera name
  38514. * @param position defines initial position
  38515. * @param interaxialDistance defines distance between each color axis
  38516. * @param scene defines the hosting scene
  38517. */
  38518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38519. /**
  38520. * Gets camera class name
  38521. * @returns AnaglyphUniversalCamera
  38522. */
  38523. getClassName(): string;
  38524. }
  38525. }
  38526. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38527. /** @hidden */
  38528. export var stereoscopicInterlacePixelShader: {
  38529. name: string;
  38530. shader: string;
  38531. };
  38532. }
  38533. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38534. import { Camera } from "babylonjs/Cameras/camera";
  38535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38536. import { Engine } from "babylonjs/Engines/engine";
  38537. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38538. /**
  38539. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38540. */
  38541. export class StereoscopicInterlacePostProcess extends PostProcess {
  38542. private _stepSize;
  38543. private _passedProcess;
  38544. /**
  38545. * Initializes a StereoscopicInterlacePostProcess
  38546. * @param name The name of the effect.
  38547. * @param rigCameras The rig cameras to be appled to the post process
  38548. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38550. * @param engine The engine which the post process will be applied. (default: current engine)
  38551. * @param reusable If the post process can be reused on the same frame. (default: false)
  38552. */
  38553. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38554. }
  38555. }
  38556. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38557. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38558. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38559. import { Scene } from "babylonjs/scene";
  38560. import { Vector3 } from "babylonjs/Maths/math";
  38561. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38562. /**
  38563. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38564. * @see http://doc.babylonjs.com/features/cameras
  38565. */
  38566. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38567. /**
  38568. * Creates a new StereoscopicArcRotateCamera
  38569. * @param name defines camera name
  38570. * @param alpha defines alpha angle (in radians)
  38571. * @param beta defines beta angle (in radians)
  38572. * @param radius defines radius
  38573. * @param target defines camera target
  38574. * @param interaxialDistance defines distance between each color axis
  38575. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38576. * @param scene defines the hosting scene
  38577. */
  38578. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38579. /**
  38580. * Gets camera class name
  38581. * @returns StereoscopicArcRotateCamera
  38582. */
  38583. getClassName(): string;
  38584. }
  38585. }
  38586. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38588. import { Scene } from "babylonjs/scene";
  38589. import { Vector3 } from "babylonjs/Maths/math";
  38590. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38591. /**
  38592. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38593. * @see http://doc.babylonjs.com/features/cameras
  38594. */
  38595. export class StereoscopicFreeCamera extends FreeCamera {
  38596. /**
  38597. * Creates a new StereoscopicFreeCamera
  38598. * @param name defines camera name
  38599. * @param position defines initial position
  38600. * @param interaxialDistance defines distance between each color axis
  38601. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38602. * @param scene defines the hosting scene
  38603. */
  38604. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38605. /**
  38606. * Gets camera class name
  38607. * @returns StereoscopicFreeCamera
  38608. */
  38609. getClassName(): string;
  38610. }
  38611. }
  38612. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38613. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38614. import { Scene } from "babylonjs/scene";
  38615. import { Vector3 } from "babylonjs/Maths/math";
  38616. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38617. /**
  38618. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38619. * @see http://doc.babylonjs.com/features/cameras
  38620. */
  38621. export class StereoscopicGamepadCamera extends GamepadCamera {
  38622. /**
  38623. * Creates a new StereoscopicGamepadCamera
  38624. * @param name defines camera name
  38625. * @param position defines initial position
  38626. * @param interaxialDistance defines distance between each color axis
  38627. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38628. * @param scene defines the hosting scene
  38629. */
  38630. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38631. /**
  38632. * Gets camera class name
  38633. * @returns StereoscopicGamepadCamera
  38634. */
  38635. getClassName(): string;
  38636. }
  38637. }
  38638. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38639. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38640. import { Scene } from "babylonjs/scene";
  38641. import { Vector3 } from "babylonjs/Maths/math";
  38642. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38643. /**
  38644. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38645. * @see http://doc.babylonjs.com/features/cameras
  38646. */
  38647. export class StereoscopicUniversalCamera extends UniversalCamera {
  38648. /**
  38649. * Creates a new StereoscopicUniversalCamera
  38650. * @param name defines camera name
  38651. * @param position defines initial position
  38652. * @param interaxialDistance defines distance between each color axis
  38653. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38654. * @param scene defines the hosting scene
  38655. */
  38656. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38657. /**
  38658. * Gets camera class name
  38659. * @returns StereoscopicUniversalCamera
  38660. */
  38661. getClassName(): string;
  38662. }
  38663. }
  38664. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38665. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38666. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38667. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38668. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38669. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38670. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38671. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38672. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38673. }
  38674. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38675. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38676. import { Scene } from "babylonjs/scene";
  38677. import { Vector3 } from "babylonjs/Maths/math";
  38678. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38679. /**
  38680. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38681. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38682. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38683. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38684. */
  38685. export class VirtualJoysticksCamera extends FreeCamera {
  38686. /**
  38687. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38688. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38689. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38690. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38691. * @param name Define the name of the camera in the scene
  38692. * @param position Define the start position of the camera in the scene
  38693. * @param scene Define the scene the camera belongs to
  38694. */
  38695. constructor(name: string, position: Vector3, scene: Scene);
  38696. /**
  38697. * Gets the current object class name.
  38698. * @return the class name
  38699. */
  38700. getClassName(): string;
  38701. }
  38702. }
  38703. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38704. import { Matrix } from "babylonjs/Maths/math";
  38705. /**
  38706. * This represents all the required metrics to create a VR camera.
  38707. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38708. */
  38709. export class VRCameraMetrics {
  38710. /**
  38711. * Define the horizontal resolution off the screen.
  38712. */
  38713. hResolution: number;
  38714. /**
  38715. * Define the vertical resolution off the screen.
  38716. */
  38717. vResolution: number;
  38718. /**
  38719. * Define the horizontal screen size.
  38720. */
  38721. hScreenSize: number;
  38722. /**
  38723. * Define the vertical screen size.
  38724. */
  38725. vScreenSize: number;
  38726. /**
  38727. * Define the vertical screen center position.
  38728. */
  38729. vScreenCenter: number;
  38730. /**
  38731. * Define the distance of the eyes to the screen.
  38732. */
  38733. eyeToScreenDistance: number;
  38734. /**
  38735. * Define the distance between both lenses
  38736. */
  38737. lensSeparationDistance: number;
  38738. /**
  38739. * Define the distance between both viewer's eyes.
  38740. */
  38741. interpupillaryDistance: number;
  38742. /**
  38743. * Define the distortion factor of the VR postprocess.
  38744. * Please, touch with care.
  38745. */
  38746. distortionK: number[];
  38747. /**
  38748. * Define the chromatic aberration correction factors for the VR post process.
  38749. */
  38750. chromaAbCorrection: number[];
  38751. /**
  38752. * Define the scale factor of the post process.
  38753. * The smaller the better but the slower.
  38754. */
  38755. postProcessScaleFactor: number;
  38756. /**
  38757. * Define an offset for the lens center.
  38758. */
  38759. lensCenterOffset: number;
  38760. /**
  38761. * Define if the current vr camera should compensate the distortion of the lense or not.
  38762. */
  38763. compensateDistortion: boolean;
  38764. /**
  38765. * Defines if multiview should be enabled when rendering (Default: false)
  38766. */
  38767. multiviewEnabled: boolean;
  38768. /**
  38769. * Gets the rendering aspect ratio based on the provided resolutions.
  38770. */
  38771. readonly aspectRatio: number;
  38772. /**
  38773. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38774. */
  38775. readonly aspectRatioFov: number;
  38776. /**
  38777. * @hidden
  38778. */
  38779. readonly leftHMatrix: Matrix;
  38780. /**
  38781. * @hidden
  38782. */
  38783. readonly rightHMatrix: Matrix;
  38784. /**
  38785. * @hidden
  38786. */
  38787. readonly leftPreViewMatrix: Matrix;
  38788. /**
  38789. * @hidden
  38790. */
  38791. readonly rightPreViewMatrix: Matrix;
  38792. /**
  38793. * Get the default VRMetrics based on the most generic setup.
  38794. * @returns the default vr metrics
  38795. */
  38796. static GetDefault(): VRCameraMetrics;
  38797. }
  38798. }
  38799. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38800. /** @hidden */
  38801. export var vrDistortionCorrectionPixelShader: {
  38802. name: string;
  38803. shader: string;
  38804. };
  38805. }
  38806. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38807. import { Camera } from "babylonjs/Cameras/camera";
  38808. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38809. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38810. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38811. /**
  38812. * VRDistortionCorrectionPostProcess used for mobile VR
  38813. */
  38814. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38815. private _isRightEye;
  38816. private _distortionFactors;
  38817. private _postProcessScaleFactor;
  38818. private _lensCenterOffset;
  38819. private _scaleIn;
  38820. private _scaleFactor;
  38821. private _lensCenter;
  38822. /**
  38823. * Initializes the VRDistortionCorrectionPostProcess
  38824. * @param name The name of the effect.
  38825. * @param camera The camera to apply the render pass to.
  38826. * @param isRightEye If this is for the right eye distortion
  38827. * @param vrMetrics All the required metrics for the VR camera
  38828. */
  38829. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38830. }
  38831. }
  38832. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38833. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38835. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38836. import { Scene } from "babylonjs/scene";
  38837. import { Vector3 } from "babylonjs/Maths/math";
  38838. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38839. import "babylonjs/Cameras/RigModes/vrRigMode";
  38840. /**
  38841. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38842. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38843. */
  38844. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38845. /**
  38846. * Creates a new VRDeviceOrientationArcRotateCamera
  38847. * @param name defines camera name
  38848. * @param alpha defines the camera rotation along the logitudinal axis
  38849. * @param beta defines the camera rotation along the latitudinal axis
  38850. * @param radius defines the camera distance from its target
  38851. * @param target defines the camera target
  38852. * @param scene defines the scene the camera belongs to
  38853. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38854. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38855. */
  38856. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38857. /**
  38858. * Gets camera class name
  38859. * @returns VRDeviceOrientationArcRotateCamera
  38860. */
  38861. getClassName(): string;
  38862. }
  38863. }
  38864. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38865. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38866. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38867. import { Scene } from "babylonjs/scene";
  38868. import { Vector3 } from "babylonjs/Maths/math";
  38869. import "babylonjs/Cameras/RigModes/vrRigMode";
  38870. /**
  38871. * Camera used to simulate VR rendering (based on FreeCamera)
  38872. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38873. */
  38874. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38875. /**
  38876. * Creates a new VRDeviceOrientationFreeCamera
  38877. * @param name defines camera name
  38878. * @param position defines the start position of the camera
  38879. * @param scene defines the scene the camera belongs to
  38880. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38881. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38882. */
  38883. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38884. /**
  38885. * Gets camera class name
  38886. * @returns VRDeviceOrientationFreeCamera
  38887. */
  38888. getClassName(): string;
  38889. }
  38890. }
  38891. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38892. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38893. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38894. import { Scene } from "babylonjs/scene";
  38895. import { Vector3 } from "babylonjs/Maths/math";
  38896. /**
  38897. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38898. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38899. */
  38900. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38901. /**
  38902. * Creates a new VRDeviceOrientationGamepadCamera
  38903. * @param name defines camera name
  38904. * @param position defines the start position of the camera
  38905. * @param scene defines the scene the camera belongs to
  38906. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38907. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38908. */
  38909. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38910. /**
  38911. * Gets camera class name
  38912. * @returns VRDeviceOrientationGamepadCamera
  38913. */
  38914. getClassName(): string;
  38915. }
  38916. }
  38917. declare module "babylonjs/Gamepads/xboxGamepad" {
  38918. import { Observable } from "babylonjs/Misc/observable";
  38919. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38920. /**
  38921. * Defines supported buttons for XBox360 compatible gamepads
  38922. */
  38923. export enum Xbox360Button {
  38924. /** A */
  38925. A = 0,
  38926. /** B */
  38927. B = 1,
  38928. /** X */
  38929. X = 2,
  38930. /** Y */
  38931. Y = 3,
  38932. /** Start */
  38933. Start = 4,
  38934. /** Back */
  38935. Back = 5,
  38936. /** Left button */
  38937. LB = 6,
  38938. /** Right button */
  38939. RB = 7,
  38940. /** Left stick */
  38941. LeftStick = 8,
  38942. /** Right stick */
  38943. RightStick = 9
  38944. }
  38945. /** Defines values for XBox360 DPad */
  38946. export enum Xbox360Dpad {
  38947. /** Up */
  38948. Up = 0,
  38949. /** Down */
  38950. Down = 1,
  38951. /** Left */
  38952. Left = 2,
  38953. /** Right */
  38954. Right = 3
  38955. }
  38956. /**
  38957. * Defines a XBox360 gamepad
  38958. */
  38959. export class Xbox360Pad extends Gamepad {
  38960. private _leftTrigger;
  38961. private _rightTrigger;
  38962. private _onlefttriggerchanged;
  38963. private _onrighttriggerchanged;
  38964. private _onbuttondown;
  38965. private _onbuttonup;
  38966. private _ondpaddown;
  38967. private _ondpadup;
  38968. /** Observable raised when a button is pressed */
  38969. onButtonDownObservable: Observable<Xbox360Button>;
  38970. /** Observable raised when a button is released */
  38971. onButtonUpObservable: Observable<Xbox360Button>;
  38972. /** Observable raised when a pad is pressed */
  38973. onPadDownObservable: Observable<Xbox360Dpad>;
  38974. /** Observable raised when a pad is released */
  38975. onPadUpObservable: Observable<Xbox360Dpad>;
  38976. private _buttonA;
  38977. private _buttonB;
  38978. private _buttonX;
  38979. private _buttonY;
  38980. private _buttonBack;
  38981. private _buttonStart;
  38982. private _buttonLB;
  38983. private _buttonRB;
  38984. private _buttonLeftStick;
  38985. private _buttonRightStick;
  38986. private _dPadUp;
  38987. private _dPadDown;
  38988. private _dPadLeft;
  38989. private _dPadRight;
  38990. private _isXboxOnePad;
  38991. /**
  38992. * Creates a new XBox360 gamepad object
  38993. * @param id defines the id of this gamepad
  38994. * @param index defines its index
  38995. * @param gamepad defines the internal HTML gamepad object
  38996. * @param xboxOne defines if it is a XBox One gamepad
  38997. */
  38998. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38999. /**
  39000. * Defines the callback to call when left trigger is pressed
  39001. * @param callback defines the callback to use
  39002. */
  39003. onlefttriggerchanged(callback: (value: number) => void): void;
  39004. /**
  39005. * Defines the callback to call when right trigger is pressed
  39006. * @param callback defines the callback to use
  39007. */
  39008. onrighttriggerchanged(callback: (value: number) => void): void;
  39009. /**
  39010. * Gets the left trigger value
  39011. */
  39012. /**
  39013. * Sets the left trigger value
  39014. */
  39015. leftTrigger: number;
  39016. /**
  39017. * Gets the right trigger value
  39018. */
  39019. /**
  39020. * Sets the right trigger value
  39021. */
  39022. rightTrigger: number;
  39023. /**
  39024. * Defines the callback to call when a button is pressed
  39025. * @param callback defines the callback to use
  39026. */
  39027. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39028. /**
  39029. * Defines the callback to call when a button is released
  39030. * @param callback defines the callback to use
  39031. */
  39032. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39033. /**
  39034. * Defines the callback to call when a pad is pressed
  39035. * @param callback defines the callback to use
  39036. */
  39037. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39038. /**
  39039. * Defines the callback to call when a pad is released
  39040. * @param callback defines the callback to use
  39041. */
  39042. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39043. private _setButtonValue;
  39044. private _setDPadValue;
  39045. /**
  39046. * Gets the value of the `A` button
  39047. */
  39048. /**
  39049. * Sets the value of the `A` button
  39050. */
  39051. buttonA: number;
  39052. /**
  39053. * Gets the value of the `B` button
  39054. */
  39055. /**
  39056. * Sets the value of the `B` button
  39057. */
  39058. buttonB: number;
  39059. /**
  39060. * Gets the value of the `X` button
  39061. */
  39062. /**
  39063. * Sets the value of the `X` button
  39064. */
  39065. buttonX: number;
  39066. /**
  39067. * Gets the value of the `Y` button
  39068. */
  39069. /**
  39070. * Sets the value of the `Y` button
  39071. */
  39072. buttonY: number;
  39073. /**
  39074. * Gets the value of the `Start` button
  39075. */
  39076. /**
  39077. * Sets the value of the `Start` button
  39078. */
  39079. buttonStart: number;
  39080. /**
  39081. * Gets the value of the `Back` button
  39082. */
  39083. /**
  39084. * Sets the value of the `Back` button
  39085. */
  39086. buttonBack: number;
  39087. /**
  39088. * Gets the value of the `Left` button
  39089. */
  39090. /**
  39091. * Sets the value of the `Left` button
  39092. */
  39093. buttonLB: number;
  39094. /**
  39095. * Gets the value of the `Right` button
  39096. */
  39097. /**
  39098. * Sets the value of the `Right` button
  39099. */
  39100. buttonRB: number;
  39101. /**
  39102. * Gets the value of the Left joystick
  39103. */
  39104. /**
  39105. * Sets the value of the Left joystick
  39106. */
  39107. buttonLeftStick: number;
  39108. /**
  39109. * Gets the value of the Right joystick
  39110. */
  39111. /**
  39112. * Sets the value of the Right joystick
  39113. */
  39114. buttonRightStick: number;
  39115. /**
  39116. * Gets the value of D-pad up
  39117. */
  39118. /**
  39119. * Sets the value of D-pad up
  39120. */
  39121. dPadUp: number;
  39122. /**
  39123. * Gets the value of D-pad down
  39124. */
  39125. /**
  39126. * Sets the value of D-pad down
  39127. */
  39128. dPadDown: number;
  39129. /**
  39130. * Gets the value of D-pad left
  39131. */
  39132. /**
  39133. * Sets the value of D-pad left
  39134. */
  39135. dPadLeft: number;
  39136. /**
  39137. * Gets the value of D-pad right
  39138. */
  39139. /**
  39140. * Sets the value of D-pad right
  39141. */
  39142. dPadRight: number;
  39143. /**
  39144. * Force the gamepad to synchronize with device values
  39145. */
  39146. update(): void;
  39147. /**
  39148. * Disposes the gamepad
  39149. */
  39150. dispose(): void;
  39151. }
  39152. }
  39153. declare module "babylonjs/Materials/pushMaterial" {
  39154. import { Nullable } from "babylonjs/types";
  39155. import { Scene } from "babylonjs/scene";
  39156. import { Matrix } from "babylonjs/Maths/math";
  39157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39158. import { Mesh } from "babylonjs/Meshes/mesh";
  39159. import { Material } from "babylonjs/Materials/material";
  39160. import { Effect } from "babylonjs/Materials/effect";
  39161. /**
  39162. * Base class of materials working in push mode in babylon JS
  39163. * @hidden
  39164. */
  39165. export class PushMaterial extends Material {
  39166. protected _activeEffect: Effect;
  39167. protected _normalMatrix: Matrix;
  39168. /**
  39169. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39170. * This means that the material can keep using a previous shader while a new one is being compiled.
  39171. * This is mostly used when shader parallel compilation is supported (true by default)
  39172. */
  39173. allowShaderHotSwapping: boolean;
  39174. constructor(name: string, scene: Scene);
  39175. getEffect(): Effect;
  39176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39177. /**
  39178. * Binds the given world matrix to the active effect
  39179. *
  39180. * @param world the matrix to bind
  39181. */
  39182. bindOnlyWorldMatrix(world: Matrix): void;
  39183. /**
  39184. * Binds the given normal matrix to the active effect
  39185. *
  39186. * @param normalMatrix the matrix to bind
  39187. */
  39188. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39189. bind(world: Matrix, mesh?: Mesh): void;
  39190. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39191. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39192. }
  39193. }
  39194. declare module "babylonjs/Materials/materialFlags" {
  39195. /**
  39196. * This groups all the flags used to control the materials channel.
  39197. */
  39198. export class MaterialFlags {
  39199. private static _DiffuseTextureEnabled;
  39200. /**
  39201. * Are diffuse textures enabled in the application.
  39202. */
  39203. static DiffuseTextureEnabled: boolean;
  39204. private static _AmbientTextureEnabled;
  39205. /**
  39206. * Are ambient textures enabled in the application.
  39207. */
  39208. static AmbientTextureEnabled: boolean;
  39209. private static _OpacityTextureEnabled;
  39210. /**
  39211. * Are opacity textures enabled in the application.
  39212. */
  39213. static OpacityTextureEnabled: boolean;
  39214. private static _ReflectionTextureEnabled;
  39215. /**
  39216. * Are reflection textures enabled in the application.
  39217. */
  39218. static ReflectionTextureEnabled: boolean;
  39219. private static _EmissiveTextureEnabled;
  39220. /**
  39221. * Are emissive textures enabled in the application.
  39222. */
  39223. static EmissiveTextureEnabled: boolean;
  39224. private static _SpecularTextureEnabled;
  39225. /**
  39226. * Are specular textures enabled in the application.
  39227. */
  39228. static SpecularTextureEnabled: boolean;
  39229. private static _BumpTextureEnabled;
  39230. /**
  39231. * Are bump textures enabled in the application.
  39232. */
  39233. static BumpTextureEnabled: boolean;
  39234. private static _LightmapTextureEnabled;
  39235. /**
  39236. * Are lightmap textures enabled in the application.
  39237. */
  39238. static LightmapTextureEnabled: boolean;
  39239. private static _RefractionTextureEnabled;
  39240. /**
  39241. * Are refraction textures enabled in the application.
  39242. */
  39243. static RefractionTextureEnabled: boolean;
  39244. private static _ColorGradingTextureEnabled;
  39245. /**
  39246. * Are color grading textures enabled in the application.
  39247. */
  39248. static ColorGradingTextureEnabled: boolean;
  39249. private static _FresnelEnabled;
  39250. /**
  39251. * Are fresnels enabled in the application.
  39252. */
  39253. static FresnelEnabled: boolean;
  39254. private static _ClearCoatTextureEnabled;
  39255. /**
  39256. * Are clear coat textures enabled in the application.
  39257. */
  39258. static ClearCoatTextureEnabled: boolean;
  39259. private static _ClearCoatBumpTextureEnabled;
  39260. /**
  39261. * Are clear coat bump textures enabled in the application.
  39262. */
  39263. static ClearCoatBumpTextureEnabled: boolean;
  39264. private static _ClearCoatTintTextureEnabled;
  39265. /**
  39266. * Are clear coat tint textures enabled in the application.
  39267. */
  39268. static ClearCoatTintTextureEnabled: boolean;
  39269. private static _SheenTextureEnabled;
  39270. /**
  39271. * Are sheen textures enabled in the application.
  39272. */
  39273. static SheenTextureEnabled: boolean;
  39274. private static _AnisotropicTextureEnabled;
  39275. /**
  39276. * Are anisotropic textures enabled in the application.
  39277. */
  39278. static AnisotropicTextureEnabled: boolean;
  39279. }
  39280. }
  39281. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39282. /** @hidden */
  39283. export var defaultFragmentDeclaration: {
  39284. name: string;
  39285. shader: string;
  39286. };
  39287. }
  39288. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39289. /** @hidden */
  39290. export var defaultUboDeclaration: {
  39291. name: string;
  39292. shader: string;
  39293. };
  39294. }
  39295. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39296. /** @hidden */
  39297. export var lightFragmentDeclaration: {
  39298. name: string;
  39299. shader: string;
  39300. };
  39301. }
  39302. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39303. /** @hidden */
  39304. export var lightUboDeclaration: {
  39305. name: string;
  39306. shader: string;
  39307. };
  39308. }
  39309. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39310. /** @hidden */
  39311. export var lightsFragmentFunctions: {
  39312. name: string;
  39313. shader: string;
  39314. };
  39315. }
  39316. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39317. /** @hidden */
  39318. export var shadowsFragmentFunctions: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39324. /** @hidden */
  39325. export var fresnelFunction: {
  39326. name: string;
  39327. shader: string;
  39328. };
  39329. }
  39330. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39331. /** @hidden */
  39332. export var reflectionFunction: {
  39333. name: string;
  39334. shader: string;
  39335. };
  39336. }
  39337. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39338. /** @hidden */
  39339. export var bumpFragmentFunctions: {
  39340. name: string;
  39341. shader: string;
  39342. };
  39343. }
  39344. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39345. /** @hidden */
  39346. export var logDepthDeclaration: {
  39347. name: string;
  39348. shader: string;
  39349. };
  39350. }
  39351. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39352. /** @hidden */
  39353. export var bumpFragment: {
  39354. name: string;
  39355. shader: string;
  39356. };
  39357. }
  39358. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39359. /** @hidden */
  39360. export var depthPrePass: {
  39361. name: string;
  39362. shader: string;
  39363. };
  39364. }
  39365. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39366. /** @hidden */
  39367. export var lightFragment: {
  39368. name: string;
  39369. shader: string;
  39370. };
  39371. }
  39372. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39373. /** @hidden */
  39374. export var logDepthFragment: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module "babylonjs/Shaders/default.fragment" {
  39380. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39381. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39383. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39384. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39385. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39386. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39387. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39388. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39389. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39390. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39391. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39392. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39393. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39394. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39395. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39396. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39397. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39398. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39399. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39400. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39401. /** @hidden */
  39402. export var defaultPixelShader: {
  39403. name: string;
  39404. shader: string;
  39405. };
  39406. }
  39407. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39408. /** @hidden */
  39409. export var defaultVertexDeclaration: {
  39410. name: string;
  39411. shader: string;
  39412. };
  39413. }
  39414. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39415. /** @hidden */
  39416. export var bumpVertexDeclaration: {
  39417. name: string;
  39418. shader: string;
  39419. };
  39420. }
  39421. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39422. /** @hidden */
  39423. export var bumpVertex: {
  39424. name: string;
  39425. shader: string;
  39426. };
  39427. }
  39428. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39429. /** @hidden */
  39430. export var fogVertex: {
  39431. name: string;
  39432. shader: string;
  39433. };
  39434. }
  39435. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39436. /** @hidden */
  39437. export var shadowsVertex: {
  39438. name: string;
  39439. shader: string;
  39440. };
  39441. }
  39442. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39443. /** @hidden */
  39444. export var pointCloudVertex: {
  39445. name: string;
  39446. shader: string;
  39447. };
  39448. }
  39449. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39450. /** @hidden */
  39451. export var logDepthVertex: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/Shaders/default.vertex" {
  39457. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39459. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39460. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39464. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39465. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39466. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39468. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39469. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39470. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39471. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39472. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39473. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39474. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39475. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39476. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39477. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39478. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39479. /** @hidden */
  39480. export var defaultVertexShader: {
  39481. name: string;
  39482. shader: string;
  39483. };
  39484. }
  39485. declare module "babylonjs/Materials/standardMaterial" {
  39486. import { SmartArray } from "babylonjs/Misc/smartArray";
  39487. import { IAnimatable } from "babylonjs/Misc/tools";
  39488. import { Nullable } from "babylonjs/types";
  39489. import { Scene } from "babylonjs/scene";
  39490. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39491. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39493. import { Mesh } from "babylonjs/Meshes/mesh";
  39494. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39495. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39496. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39497. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39498. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39500. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39501. import "babylonjs/Shaders/default.fragment";
  39502. import "babylonjs/Shaders/default.vertex";
  39503. /** @hidden */
  39504. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39505. MAINUV1: boolean;
  39506. MAINUV2: boolean;
  39507. DIFFUSE: boolean;
  39508. DIFFUSEDIRECTUV: number;
  39509. AMBIENT: boolean;
  39510. AMBIENTDIRECTUV: number;
  39511. OPACITY: boolean;
  39512. OPACITYDIRECTUV: number;
  39513. OPACITYRGB: boolean;
  39514. REFLECTION: boolean;
  39515. EMISSIVE: boolean;
  39516. EMISSIVEDIRECTUV: number;
  39517. SPECULAR: boolean;
  39518. SPECULARDIRECTUV: number;
  39519. BUMP: boolean;
  39520. BUMPDIRECTUV: number;
  39521. PARALLAX: boolean;
  39522. PARALLAXOCCLUSION: boolean;
  39523. SPECULAROVERALPHA: boolean;
  39524. CLIPPLANE: boolean;
  39525. CLIPPLANE2: boolean;
  39526. CLIPPLANE3: boolean;
  39527. CLIPPLANE4: boolean;
  39528. ALPHATEST: boolean;
  39529. DEPTHPREPASS: boolean;
  39530. ALPHAFROMDIFFUSE: boolean;
  39531. POINTSIZE: boolean;
  39532. FOG: boolean;
  39533. SPECULARTERM: boolean;
  39534. DIFFUSEFRESNEL: boolean;
  39535. OPACITYFRESNEL: boolean;
  39536. REFLECTIONFRESNEL: boolean;
  39537. REFRACTIONFRESNEL: boolean;
  39538. EMISSIVEFRESNEL: boolean;
  39539. FRESNEL: boolean;
  39540. NORMAL: boolean;
  39541. UV1: boolean;
  39542. UV2: boolean;
  39543. VERTEXCOLOR: boolean;
  39544. VERTEXALPHA: boolean;
  39545. NUM_BONE_INFLUENCERS: number;
  39546. BonesPerMesh: number;
  39547. BONETEXTURE: boolean;
  39548. INSTANCES: boolean;
  39549. GLOSSINESS: boolean;
  39550. ROUGHNESS: boolean;
  39551. EMISSIVEASILLUMINATION: boolean;
  39552. LINKEMISSIVEWITHDIFFUSE: boolean;
  39553. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39554. LIGHTMAP: boolean;
  39555. LIGHTMAPDIRECTUV: number;
  39556. OBJECTSPACE_NORMALMAP: boolean;
  39557. USELIGHTMAPASSHADOWMAP: boolean;
  39558. REFLECTIONMAP_3D: boolean;
  39559. REFLECTIONMAP_SPHERICAL: boolean;
  39560. REFLECTIONMAP_PLANAR: boolean;
  39561. REFLECTIONMAP_CUBIC: boolean;
  39562. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39563. REFLECTIONMAP_PROJECTION: boolean;
  39564. REFLECTIONMAP_SKYBOX: boolean;
  39565. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39566. REFLECTIONMAP_EXPLICIT: boolean;
  39567. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39568. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39569. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39570. INVERTCUBICMAP: boolean;
  39571. LOGARITHMICDEPTH: boolean;
  39572. REFRACTION: boolean;
  39573. REFRACTIONMAP_3D: boolean;
  39574. REFLECTIONOVERALPHA: boolean;
  39575. TWOSIDEDLIGHTING: boolean;
  39576. SHADOWFLOAT: boolean;
  39577. MORPHTARGETS: boolean;
  39578. MORPHTARGETS_NORMAL: boolean;
  39579. MORPHTARGETS_TANGENT: boolean;
  39580. NUM_MORPH_INFLUENCERS: number;
  39581. NONUNIFORMSCALING: boolean;
  39582. PREMULTIPLYALPHA: boolean;
  39583. IMAGEPROCESSING: boolean;
  39584. VIGNETTE: boolean;
  39585. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39586. VIGNETTEBLENDMODEOPAQUE: boolean;
  39587. TONEMAPPING: boolean;
  39588. TONEMAPPING_ACES: boolean;
  39589. CONTRAST: boolean;
  39590. COLORCURVES: boolean;
  39591. COLORGRADING: boolean;
  39592. COLORGRADING3D: boolean;
  39593. SAMPLER3DGREENDEPTH: boolean;
  39594. SAMPLER3DBGRMAP: boolean;
  39595. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39596. MULTIVIEW: boolean;
  39597. /**
  39598. * If the reflection texture on this material is in linear color space
  39599. * @hidden
  39600. */
  39601. IS_REFLECTION_LINEAR: boolean;
  39602. /**
  39603. * If the refraction texture on this material is in linear color space
  39604. * @hidden
  39605. */
  39606. IS_REFRACTION_LINEAR: boolean;
  39607. EXPOSURE: boolean;
  39608. constructor();
  39609. setReflectionMode(modeToEnable: string): void;
  39610. }
  39611. /**
  39612. * This is the default material used in Babylon. It is the best trade off between quality
  39613. * and performances.
  39614. * @see http://doc.babylonjs.com/babylon101/materials
  39615. */
  39616. export class StandardMaterial extends PushMaterial {
  39617. private _diffuseTexture;
  39618. /**
  39619. * The basic texture of the material as viewed under a light.
  39620. */
  39621. diffuseTexture: Nullable<BaseTexture>;
  39622. private _ambientTexture;
  39623. /**
  39624. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39625. */
  39626. ambientTexture: Nullable<BaseTexture>;
  39627. private _opacityTexture;
  39628. /**
  39629. * Define the transparency of the material from a texture.
  39630. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39631. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39632. */
  39633. opacityTexture: Nullable<BaseTexture>;
  39634. private _reflectionTexture;
  39635. /**
  39636. * Define the texture used to display the reflection.
  39637. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39638. */
  39639. reflectionTexture: Nullable<BaseTexture>;
  39640. private _emissiveTexture;
  39641. /**
  39642. * Define texture of the material as if self lit.
  39643. * This will be mixed in the final result even in the absence of light.
  39644. */
  39645. emissiveTexture: Nullable<BaseTexture>;
  39646. private _specularTexture;
  39647. /**
  39648. * Define how the color and intensity of the highlight given by the light in the material.
  39649. */
  39650. specularTexture: Nullable<BaseTexture>;
  39651. private _bumpTexture;
  39652. /**
  39653. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39654. * 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.
  39655. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39656. */
  39657. bumpTexture: Nullable<BaseTexture>;
  39658. private _lightmapTexture;
  39659. /**
  39660. * Complex lighting can be computationally expensive to compute at runtime.
  39661. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39662. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39663. */
  39664. lightmapTexture: Nullable<BaseTexture>;
  39665. private _refractionTexture;
  39666. /**
  39667. * Define the texture used to display the refraction.
  39668. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39669. */
  39670. refractionTexture: Nullable<BaseTexture>;
  39671. /**
  39672. * The color of the material lit by the environmental background lighting.
  39673. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39674. */
  39675. ambientColor: Color3;
  39676. /**
  39677. * The basic color of the material as viewed under a light.
  39678. */
  39679. diffuseColor: Color3;
  39680. /**
  39681. * Define how the color and intensity of the highlight given by the light in the material.
  39682. */
  39683. specularColor: Color3;
  39684. /**
  39685. * Define the color of the material as if self lit.
  39686. * This will be mixed in the final result even in the absence of light.
  39687. */
  39688. emissiveColor: Color3;
  39689. /**
  39690. * Defines how sharp are the highlights in the material.
  39691. * The bigger the value the sharper giving a more glossy feeling to the result.
  39692. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39693. */
  39694. specularPower: number;
  39695. private _useAlphaFromDiffuseTexture;
  39696. /**
  39697. * Does the transparency come from the diffuse texture alpha channel.
  39698. */
  39699. useAlphaFromDiffuseTexture: boolean;
  39700. private _useEmissiveAsIllumination;
  39701. /**
  39702. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39703. */
  39704. useEmissiveAsIllumination: boolean;
  39705. private _linkEmissiveWithDiffuse;
  39706. /**
  39707. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39708. * the emissive level when the final color is close to one.
  39709. */
  39710. linkEmissiveWithDiffuse: boolean;
  39711. private _useSpecularOverAlpha;
  39712. /**
  39713. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39714. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39715. */
  39716. useSpecularOverAlpha: boolean;
  39717. private _useReflectionOverAlpha;
  39718. /**
  39719. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39720. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39721. */
  39722. useReflectionOverAlpha: boolean;
  39723. private _disableLighting;
  39724. /**
  39725. * Does lights from the scene impacts this material.
  39726. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39727. */
  39728. disableLighting: boolean;
  39729. private _useObjectSpaceNormalMap;
  39730. /**
  39731. * Allows using an object space normal map (instead of tangent space).
  39732. */
  39733. useObjectSpaceNormalMap: boolean;
  39734. private _useParallax;
  39735. /**
  39736. * Is parallax enabled or not.
  39737. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39738. */
  39739. useParallax: boolean;
  39740. private _useParallaxOcclusion;
  39741. /**
  39742. * Is parallax occlusion enabled or not.
  39743. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39744. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39745. */
  39746. useParallaxOcclusion: boolean;
  39747. /**
  39748. * 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.
  39749. */
  39750. parallaxScaleBias: number;
  39751. private _roughness;
  39752. /**
  39753. * Helps to define how blurry the reflections should appears in the material.
  39754. */
  39755. roughness: number;
  39756. /**
  39757. * In case of refraction, define the value of the indice of refraction.
  39758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39759. */
  39760. indexOfRefraction: number;
  39761. /**
  39762. * Invert the refraction texture alongside the y axis.
  39763. * It can be useful with procedural textures or probe for instance.
  39764. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39765. */
  39766. invertRefractionY: boolean;
  39767. /**
  39768. * Defines the alpha limits in alpha test mode.
  39769. */
  39770. alphaCutOff: number;
  39771. private _useLightmapAsShadowmap;
  39772. /**
  39773. * In case of light mapping, define whether the map contains light or shadow informations.
  39774. */
  39775. useLightmapAsShadowmap: boolean;
  39776. private _diffuseFresnelParameters;
  39777. /**
  39778. * Define the diffuse fresnel parameters of the material.
  39779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39780. */
  39781. diffuseFresnelParameters: FresnelParameters;
  39782. private _opacityFresnelParameters;
  39783. /**
  39784. * Define the opacity fresnel parameters of the material.
  39785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39786. */
  39787. opacityFresnelParameters: FresnelParameters;
  39788. private _reflectionFresnelParameters;
  39789. /**
  39790. * Define the reflection fresnel parameters of the material.
  39791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39792. */
  39793. reflectionFresnelParameters: FresnelParameters;
  39794. private _refractionFresnelParameters;
  39795. /**
  39796. * Define the refraction fresnel parameters of the material.
  39797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39798. */
  39799. refractionFresnelParameters: FresnelParameters;
  39800. private _emissiveFresnelParameters;
  39801. /**
  39802. * Define the emissive fresnel parameters of the material.
  39803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39804. */
  39805. emissiveFresnelParameters: FresnelParameters;
  39806. private _useReflectionFresnelFromSpecular;
  39807. /**
  39808. * If true automatically deducts the fresnels values from the material specularity.
  39809. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39810. */
  39811. useReflectionFresnelFromSpecular: boolean;
  39812. private _useGlossinessFromSpecularMapAlpha;
  39813. /**
  39814. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39815. */
  39816. useGlossinessFromSpecularMapAlpha: boolean;
  39817. private _maxSimultaneousLights;
  39818. /**
  39819. * Defines the maximum number of lights that can be used in the material
  39820. */
  39821. maxSimultaneousLights: number;
  39822. private _invertNormalMapX;
  39823. /**
  39824. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39825. */
  39826. invertNormalMapX: boolean;
  39827. private _invertNormalMapY;
  39828. /**
  39829. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39830. */
  39831. invertNormalMapY: boolean;
  39832. private _twoSidedLighting;
  39833. /**
  39834. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39835. */
  39836. twoSidedLighting: boolean;
  39837. /**
  39838. * Default configuration related to image processing available in the standard Material.
  39839. */
  39840. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39841. /**
  39842. * Gets the image processing configuration used either in this material.
  39843. */
  39844. /**
  39845. * Sets the Default image processing configuration used either in the this material.
  39846. *
  39847. * If sets to null, the scene one is in use.
  39848. */
  39849. imageProcessingConfiguration: ImageProcessingConfiguration;
  39850. /**
  39851. * Keep track of the image processing observer to allow dispose and replace.
  39852. */
  39853. private _imageProcessingObserver;
  39854. /**
  39855. * Attaches a new image processing configuration to the Standard Material.
  39856. * @param configuration
  39857. */
  39858. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39859. /**
  39860. * Gets wether the color curves effect is enabled.
  39861. */
  39862. /**
  39863. * Sets wether the color curves effect is enabled.
  39864. */
  39865. cameraColorCurvesEnabled: boolean;
  39866. /**
  39867. * Gets wether the color grading effect is enabled.
  39868. */
  39869. /**
  39870. * Gets wether the color grading effect is enabled.
  39871. */
  39872. cameraColorGradingEnabled: boolean;
  39873. /**
  39874. * Gets wether tonemapping is enabled or not.
  39875. */
  39876. /**
  39877. * Sets wether tonemapping is enabled or not
  39878. */
  39879. cameraToneMappingEnabled: boolean;
  39880. /**
  39881. * The camera exposure used on this material.
  39882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39883. * This corresponds to a photographic exposure.
  39884. */
  39885. /**
  39886. * The camera exposure used on this material.
  39887. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39888. * This corresponds to a photographic exposure.
  39889. */
  39890. cameraExposure: number;
  39891. /**
  39892. * Gets The camera contrast used on this material.
  39893. */
  39894. /**
  39895. * Sets The camera contrast used on this material.
  39896. */
  39897. cameraContrast: number;
  39898. /**
  39899. * Gets the Color Grading 2D Lookup Texture.
  39900. */
  39901. /**
  39902. * Sets the Color Grading 2D Lookup Texture.
  39903. */
  39904. cameraColorGradingTexture: Nullable<BaseTexture>;
  39905. /**
  39906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39908. * 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;
  39909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39910. */
  39911. /**
  39912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39914. * 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;
  39915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39916. */
  39917. cameraColorCurves: Nullable<ColorCurves>;
  39918. /**
  39919. * Custom callback helping to override the default shader used in the material.
  39920. */
  39921. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39922. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39923. protected _worldViewProjectionMatrix: Matrix;
  39924. protected _globalAmbientColor: Color3;
  39925. protected _useLogarithmicDepth: boolean;
  39926. /**
  39927. * Instantiates a new standard material.
  39928. * This is the default material used in Babylon. It is the best trade off between quality
  39929. * and performances.
  39930. * @see http://doc.babylonjs.com/babylon101/materials
  39931. * @param name Define the name of the material in the scene
  39932. * @param scene Define the scene the material belong to
  39933. */
  39934. constructor(name: string, scene: Scene);
  39935. /**
  39936. * Gets a boolean indicating that current material needs to register RTT
  39937. */
  39938. readonly hasRenderTargetTextures: boolean;
  39939. /**
  39940. * Gets the current class name of the material e.g. "StandardMaterial"
  39941. * Mainly use in serialization.
  39942. * @returns the class name
  39943. */
  39944. getClassName(): string;
  39945. /**
  39946. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39947. * You can try switching to logarithmic depth.
  39948. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39949. */
  39950. useLogarithmicDepth: boolean;
  39951. /**
  39952. * Specifies if the material will require alpha blending
  39953. * @returns a boolean specifying if alpha blending is needed
  39954. */
  39955. needAlphaBlending(): boolean;
  39956. /**
  39957. * Specifies if this material should be rendered in alpha test mode
  39958. * @returns a boolean specifying if an alpha test is needed.
  39959. */
  39960. needAlphaTesting(): boolean;
  39961. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39962. /**
  39963. * Get the texture used for alpha test purpose.
  39964. * @returns the diffuse texture in case of the standard material.
  39965. */
  39966. getAlphaTestTexture(): Nullable<BaseTexture>;
  39967. /**
  39968. * Get if the submesh is ready to be used and all its information available.
  39969. * Child classes can use it to update shaders
  39970. * @param mesh defines the mesh to check
  39971. * @param subMesh defines which submesh to check
  39972. * @param useInstances specifies that instances should be used
  39973. * @returns a boolean indicating that the submesh is ready or not
  39974. */
  39975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39976. /**
  39977. * Builds the material UBO layouts.
  39978. * Used internally during the effect preparation.
  39979. */
  39980. buildUniformLayout(): void;
  39981. /**
  39982. * Unbinds the material from the mesh
  39983. */
  39984. unbind(): void;
  39985. /**
  39986. * Binds the submesh to this material by preparing the effect and shader to draw
  39987. * @param world defines the world transformation matrix
  39988. * @param mesh defines the mesh containing the submesh
  39989. * @param subMesh defines the submesh to bind the material to
  39990. */
  39991. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39992. /**
  39993. * Get the list of animatables in the material.
  39994. * @returns the list of animatables object used in the material
  39995. */
  39996. getAnimatables(): IAnimatable[];
  39997. /**
  39998. * Gets the active textures from the material
  39999. * @returns an array of textures
  40000. */
  40001. getActiveTextures(): BaseTexture[];
  40002. /**
  40003. * Specifies if the material uses a texture
  40004. * @param texture defines the texture to check against the material
  40005. * @returns a boolean specifying if the material uses the texture
  40006. */
  40007. hasTexture(texture: BaseTexture): boolean;
  40008. /**
  40009. * Disposes the material
  40010. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40011. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40012. */
  40013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40014. /**
  40015. * Makes a duplicate of the material, and gives it a new name
  40016. * @param name defines the new name for the duplicated material
  40017. * @returns the cloned material
  40018. */
  40019. clone(name: string): StandardMaterial;
  40020. /**
  40021. * Serializes this material in a JSON representation
  40022. * @returns the serialized material object
  40023. */
  40024. serialize(): any;
  40025. /**
  40026. * Creates a standard material from parsed material data
  40027. * @param source defines the JSON representation of the material
  40028. * @param scene defines the hosting scene
  40029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40030. * @returns a new standard material
  40031. */
  40032. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40033. /**
  40034. * Are diffuse textures enabled in the application.
  40035. */
  40036. static DiffuseTextureEnabled: boolean;
  40037. /**
  40038. * Are ambient textures enabled in the application.
  40039. */
  40040. static AmbientTextureEnabled: boolean;
  40041. /**
  40042. * Are opacity textures enabled in the application.
  40043. */
  40044. static OpacityTextureEnabled: boolean;
  40045. /**
  40046. * Are reflection textures enabled in the application.
  40047. */
  40048. static ReflectionTextureEnabled: boolean;
  40049. /**
  40050. * Are emissive textures enabled in the application.
  40051. */
  40052. static EmissiveTextureEnabled: boolean;
  40053. /**
  40054. * Are specular textures enabled in the application.
  40055. */
  40056. static SpecularTextureEnabled: boolean;
  40057. /**
  40058. * Are bump textures enabled in the application.
  40059. */
  40060. static BumpTextureEnabled: boolean;
  40061. /**
  40062. * Are lightmap textures enabled in the application.
  40063. */
  40064. static LightmapTextureEnabled: boolean;
  40065. /**
  40066. * Are refraction textures enabled in the application.
  40067. */
  40068. static RefractionTextureEnabled: boolean;
  40069. /**
  40070. * Are color grading textures enabled in the application.
  40071. */
  40072. static ColorGradingTextureEnabled: boolean;
  40073. /**
  40074. * Are fresnels enabled in the application.
  40075. */
  40076. static FresnelEnabled: boolean;
  40077. }
  40078. }
  40079. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40080. import { Scene } from "babylonjs/scene";
  40081. import { Texture } from "babylonjs/Materials/Textures/texture";
  40082. /**
  40083. * A class extending Texture allowing drawing on a texture
  40084. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40085. */
  40086. export class DynamicTexture extends Texture {
  40087. private _generateMipMaps;
  40088. private _canvas;
  40089. private _context;
  40090. private _engine;
  40091. /**
  40092. * Creates a DynamicTexture
  40093. * @param name defines the name of the texture
  40094. * @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
  40095. * @param scene defines the scene where you want the texture
  40096. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40097. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40098. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40099. */
  40100. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40101. /**
  40102. * Get the current class name of the texture useful for serialization or dynamic coding.
  40103. * @returns "DynamicTexture"
  40104. */
  40105. getClassName(): string;
  40106. /**
  40107. * Gets the current state of canRescale
  40108. */
  40109. readonly canRescale: boolean;
  40110. private _recreate;
  40111. /**
  40112. * Scales the texture
  40113. * @param ratio the scale factor to apply to both width and height
  40114. */
  40115. scale(ratio: number): void;
  40116. /**
  40117. * Resizes the texture
  40118. * @param width the new width
  40119. * @param height the new height
  40120. */
  40121. scaleTo(width: number, height: number): void;
  40122. /**
  40123. * Gets the context of the canvas used by the texture
  40124. * @returns the canvas context of the dynamic texture
  40125. */
  40126. getContext(): CanvasRenderingContext2D;
  40127. /**
  40128. * Clears the texture
  40129. */
  40130. clear(): void;
  40131. /**
  40132. * Updates the texture
  40133. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40134. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40135. */
  40136. update(invertY?: boolean, premulAlpha?: boolean): void;
  40137. /**
  40138. * Draws text onto the texture
  40139. * @param text defines the text to be drawn
  40140. * @param x defines the placement of the text from the left
  40141. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40142. * @param font defines the font to be used with font-style, font-size, font-name
  40143. * @param color defines the color used for the text
  40144. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40145. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40146. * @param update defines whether texture is immediately update (default is true)
  40147. */
  40148. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40149. /**
  40150. * Clones the texture
  40151. * @returns the clone of the texture.
  40152. */
  40153. clone(): DynamicTexture;
  40154. /**
  40155. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40156. * @returns a serialized dynamic texture object
  40157. */
  40158. serialize(): any;
  40159. /** @hidden */
  40160. _rebuild(): void;
  40161. }
  40162. }
  40163. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40164. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40165. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40166. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40167. /** @hidden */
  40168. export var imageProcessingPixelShader: {
  40169. name: string;
  40170. shader: string;
  40171. };
  40172. }
  40173. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40174. import { Nullable } from "babylonjs/types";
  40175. import { Color4 } from "babylonjs/Maths/math";
  40176. import { Camera } from "babylonjs/Cameras/camera";
  40177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40178. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40179. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40180. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40181. import { Engine } from "babylonjs/Engines/engine";
  40182. import "babylonjs/Shaders/imageProcessing.fragment";
  40183. import "babylonjs/Shaders/postprocess.vertex";
  40184. /**
  40185. * ImageProcessingPostProcess
  40186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40187. */
  40188. export class ImageProcessingPostProcess extends PostProcess {
  40189. /**
  40190. * Default configuration related to image processing available in the PBR Material.
  40191. */
  40192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40193. /**
  40194. * Gets the image processing configuration used either in this material.
  40195. */
  40196. /**
  40197. * Sets the Default image processing configuration used either in the this material.
  40198. *
  40199. * If sets to null, the scene one is in use.
  40200. */
  40201. imageProcessingConfiguration: ImageProcessingConfiguration;
  40202. /**
  40203. * Keep track of the image processing observer to allow dispose and replace.
  40204. */
  40205. private _imageProcessingObserver;
  40206. /**
  40207. * Attaches a new image processing configuration to the PBR Material.
  40208. * @param configuration
  40209. */
  40210. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40211. /**
  40212. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40213. */
  40214. /**
  40215. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40216. */
  40217. colorCurves: Nullable<ColorCurves>;
  40218. /**
  40219. * Gets wether the color curves effect is enabled.
  40220. */
  40221. /**
  40222. * Sets wether the color curves effect is enabled.
  40223. */
  40224. colorCurvesEnabled: boolean;
  40225. /**
  40226. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40227. */
  40228. /**
  40229. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40230. */
  40231. colorGradingTexture: Nullable<BaseTexture>;
  40232. /**
  40233. * Gets wether the color grading effect is enabled.
  40234. */
  40235. /**
  40236. * Gets wether the color grading effect is enabled.
  40237. */
  40238. colorGradingEnabled: boolean;
  40239. /**
  40240. * Gets exposure used in the effect.
  40241. */
  40242. /**
  40243. * Sets exposure used in the effect.
  40244. */
  40245. exposure: number;
  40246. /**
  40247. * Gets wether tonemapping is enabled or not.
  40248. */
  40249. /**
  40250. * Sets wether tonemapping is enabled or not
  40251. */
  40252. toneMappingEnabled: boolean;
  40253. /**
  40254. * Gets the type of tone mapping effect.
  40255. */
  40256. /**
  40257. * Sets the type of tone mapping effect.
  40258. */
  40259. toneMappingType: number;
  40260. /**
  40261. * Gets contrast used in the effect.
  40262. */
  40263. /**
  40264. * Sets contrast used in the effect.
  40265. */
  40266. contrast: number;
  40267. /**
  40268. * Gets Vignette stretch size.
  40269. */
  40270. /**
  40271. * Sets Vignette stretch size.
  40272. */
  40273. vignetteStretch: number;
  40274. /**
  40275. * Gets Vignette centre X Offset.
  40276. */
  40277. /**
  40278. * Sets Vignette centre X Offset.
  40279. */
  40280. vignetteCentreX: number;
  40281. /**
  40282. * Gets Vignette centre Y Offset.
  40283. */
  40284. /**
  40285. * Sets Vignette centre Y Offset.
  40286. */
  40287. vignetteCentreY: number;
  40288. /**
  40289. * Gets Vignette weight or intensity of the vignette effect.
  40290. */
  40291. /**
  40292. * Sets Vignette weight or intensity of the vignette effect.
  40293. */
  40294. vignetteWeight: number;
  40295. /**
  40296. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40297. * if vignetteEnabled is set to true.
  40298. */
  40299. /**
  40300. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40301. * if vignetteEnabled is set to true.
  40302. */
  40303. vignetteColor: Color4;
  40304. /**
  40305. * Gets Camera field of view used by the Vignette effect.
  40306. */
  40307. /**
  40308. * Sets Camera field of view used by the Vignette effect.
  40309. */
  40310. vignetteCameraFov: number;
  40311. /**
  40312. * Gets the vignette blend mode allowing different kind of effect.
  40313. */
  40314. /**
  40315. * Sets the vignette blend mode allowing different kind of effect.
  40316. */
  40317. vignetteBlendMode: number;
  40318. /**
  40319. * Gets wether the vignette effect is enabled.
  40320. */
  40321. /**
  40322. * Sets wether the vignette effect is enabled.
  40323. */
  40324. vignetteEnabled: boolean;
  40325. private _fromLinearSpace;
  40326. /**
  40327. * Gets wether the input of the processing is in Gamma or Linear Space.
  40328. */
  40329. /**
  40330. * Sets wether the input of the processing is in Gamma or Linear Space.
  40331. */
  40332. fromLinearSpace: boolean;
  40333. /**
  40334. * Defines cache preventing GC.
  40335. */
  40336. private _defines;
  40337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40338. /**
  40339. * "ImageProcessingPostProcess"
  40340. * @returns "ImageProcessingPostProcess"
  40341. */
  40342. getClassName(): string;
  40343. protected _updateParameters(): void;
  40344. dispose(camera?: Camera): void;
  40345. }
  40346. }
  40347. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40348. import { Scene } from "babylonjs/scene";
  40349. import { Color3 } from "babylonjs/Maths/math";
  40350. import { Mesh } from "babylonjs/Meshes/mesh";
  40351. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40352. /**
  40353. * Class containing static functions to help procedurally build meshes
  40354. */
  40355. export class GroundBuilder {
  40356. /**
  40357. * Creates a ground mesh
  40358. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40359. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40361. * @param name defines the name of the mesh
  40362. * @param options defines the options used to create the mesh
  40363. * @param scene defines the hosting scene
  40364. * @returns the ground mesh
  40365. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40366. */
  40367. static CreateGround(name: string, options: {
  40368. width?: number;
  40369. height?: number;
  40370. subdivisions?: number;
  40371. subdivisionsX?: number;
  40372. subdivisionsY?: number;
  40373. updatable?: boolean;
  40374. }, scene: any): Mesh;
  40375. /**
  40376. * Creates a tiled ground mesh
  40377. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40378. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40379. * * 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
  40380. * * 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
  40381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40382. * @param name defines the name of the mesh
  40383. * @param options defines the options used to create the mesh
  40384. * @param scene defines the hosting scene
  40385. * @returns the tiled ground mesh
  40386. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40387. */
  40388. static CreateTiledGround(name: string, options: {
  40389. xmin: number;
  40390. zmin: number;
  40391. xmax: number;
  40392. zmax: number;
  40393. subdivisions?: {
  40394. w: number;
  40395. h: number;
  40396. };
  40397. precision?: {
  40398. w: number;
  40399. h: number;
  40400. };
  40401. updatable?: boolean;
  40402. }, scene: Scene): Mesh;
  40403. /**
  40404. * Creates a ground mesh from a height map
  40405. * * The parameter `url` sets the URL of the height map image resource.
  40406. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40407. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40408. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40409. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40410. * * 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.
  40411. * * 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).
  40412. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40414. * @param name defines the name of the mesh
  40415. * @param url defines the url to the height map
  40416. * @param options defines the options used to create the mesh
  40417. * @param scene defines the hosting scene
  40418. * @returns the ground mesh
  40419. * @see https://doc.babylonjs.com/babylon101/height_map
  40420. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40421. */
  40422. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40423. width?: number;
  40424. height?: number;
  40425. subdivisions?: number;
  40426. minHeight?: number;
  40427. maxHeight?: number;
  40428. colorFilter?: Color3;
  40429. alphaFilter?: number;
  40430. updatable?: boolean;
  40431. onReady?: (mesh: GroundMesh) => void;
  40432. }, scene: Scene): GroundMesh;
  40433. }
  40434. }
  40435. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40436. import { Vector4 } from "babylonjs/Maths/math";
  40437. import { Mesh } from "babylonjs/Meshes/mesh";
  40438. /**
  40439. * Class containing static functions to help procedurally build meshes
  40440. */
  40441. export class TorusBuilder {
  40442. /**
  40443. * Creates a torus mesh
  40444. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40445. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40446. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40450. * @param name defines the name of the mesh
  40451. * @param options defines the options used to create the mesh
  40452. * @param scene defines the hosting scene
  40453. * @returns the torus mesh
  40454. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40455. */
  40456. static CreateTorus(name: string, options: {
  40457. diameter?: number;
  40458. thickness?: number;
  40459. tessellation?: number;
  40460. updatable?: boolean;
  40461. sideOrientation?: number;
  40462. frontUVs?: Vector4;
  40463. backUVs?: Vector4;
  40464. }, scene: any): Mesh;
  40465. }
  40466. }
  40467. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40468. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40469. import { Mesh } from "babylonjs/Meshes/mesh";
  40470. /**
  40471. * Class containing static functions to help procedurally build meshes
  40472. */
  40473. export class CylinderBuilder {
  40474. /**
  40475. * Creates a cylinder or a cone mesh
  40476. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40477. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40478. * * 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.
  40479. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40480. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40481. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40482. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40483. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40484. * * 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).
  40485. * * 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
  40486. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40487. * * 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
  40488. * * 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.
  40489. * * If `enclose` is false, a ring surface is one element.
  40490. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40491. * * 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
  40492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40495. * @param name defines the name of the mesh
  40496. * @param options defines the options used to create the mesh
  40497. * @param scene defines the hosting scene
  40498. * @returns the cylinder mesh
  40499. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40500. */
  40501. static CreateCylinder(name: string, options: {
  40502. height?: number;
  40503. diameterTop?: number;
  40504. diameterBottom?: number;
  40505. diameter?: number;
  40506. tessellation?: number;
  40507. subdivisions?: number;
  40508. arc?: number;
  40509. faceColors?: Color4[];
  40510. faceUV?: Vector4[];
  40511. updatable?: boolean;
  40512. hasRings?: boolean;
  40513. enclose?: boolean;
  40514. sideOrientation?: number;
  40515. frontUVs?: Vector4;
  40516. backUVs?: Vector4;
  40517. }, scene: any): Mesh;
  40518. }
  40519. }
  40520. declare module "babylonjs/Gamepads/gamepadManager" {
  40521. import { Observable } from "babylonjs/Misc/observable";
  40522. import { Nullable } from "babylonjs/types";
  40523. import { Scene } from "babylonjs/scene";
  40524. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40525. /**
  40526. * Manager for handling gamepads
  40527. */
  40528. export class GamepadManager {
  40529. private _scene?;
  40530. private _babylonGamepads;
  40531. private _oneGamepadConnected;
  40532. /** @hidden */
  40533. _isMonitoring: boolean;
  40534. private _gamepadEventSupported;
  40535. private _gamepadSupport;
  40536. /**
  40537. * observable to be triggered when the gamepad controller has been connected
  40538. */
  40539. onGamepadConnectedObservable: Observable<Gamepad>;
  40540. /**
  40541. * observable to be triggered when the gamepad controller has been disconnected
  40542. */
  40543. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40544. private _onGamepadConnectedEvent;
  40545. private _onGamepadDisconnectedEvent;
  40546. /**
  40547. * Initializes the gamepad manager
  40548. * @param _scene BabylonJS scene
  40549. */
  40550. constructor(_scene?: Scene | undefined);
  40551. /**
  40552. * The gamepads in the game pad manager
  40553. */
  40554. readonly gamepads: Gamepad[];
  40555. /**
  40556. * Get the gamepad controllers based on type
  40557. * @param type The type of gamepad controller
  40558. * @returns Nullable gamepad
  40559. */
  40560. getGamepadByType(type?: number): Nullable<Gamepad>;
  40561. /**
  40562. * Disposes the gamepad manager
  40563. */
  40564. dispose(): void;
  40565. private _addNewGamepad;
  40566. private _startMonitoringGamepads;
  40567. private _stopMonitoringGamepads;
  40568. /** @hidden */
  40569. _checkGamepadsStatus(): void;
  40570. private _updateGamepadObjects;
  40571. }
  40572. }
  40573. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40574. import { Nullable } from "babylonjs/types";
  40575. import { Scene } from "babylonjs/scene";
  40576. import { ISceneComponent } from "babylonjs/sceneComponent";
  40577. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40578. module "babylonjs/scene" {
  40579. interface Scene {
  40580. /** @hidden */
  40581. _gamepadManager: Nullable<GamepadManager>;
  40582. /**
  40583. * Gets the gamepad manager associated with the scene
  40584. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40585. */
  40586. gamepadManager: GamepadManager;
  40587. }
  40588. }
  40589. module "babylonjs/Cameras/freeCameraInputsManager" {
  40590. /**
  40591. * Interface representing a free camera inputs manager
  40592. */
  40593. interface FreeCameraInputsManager {
  40594. /**
  40595. * Adds gamepad input support to the FreeCameraInputsManager.
  40596. * @returns the FreeCameraInputsManager
  40597. */
  40598. addGamepad(): FreeCameraInputsManager;
  40599. }
  40600. }
  40601. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40602. /**
  40603. * Interface representing an arc rotate camera inputs manager
  40604. */
  40605. interface ArcRotateCameraInputsManager {
  40606. /**
  40607. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40608. * @returns the camera inputs manager
  40609. */
  40610. addGamepad(): ArcRotateCameraInputsManager;
  40611. }
  40612. }
  40613. /**
  40614. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40615. */
  40616. export class GamepadSystemSceneComponent implements ISceneComponent {
  40617. /**
  40618. * The component name helpfull to identify the component in the list of scene components.
  40619. */
  40620. readonly name: string;
  40621. /**
  40622. * The scene the component belongs to.
  40623. */
  40624. scene: Scene;
  40625. /**
  40626. * Creates a new instance of the component for the given scene
  40627. * @param scene Defines the scene to register the component in
  40628. */
  40629. constructor(scene: Scene);
  40630. /**
  40631. * Registers the component in a given scene
  40632. */
  40633. register(): void;
  40634. /**
  40635. * Rebuilds the elements related to this component in case of
  40636. * context lost for instance.
  40637. */
  40638. rebuild(): void;
  40639. /**
  40640. * Disposes the component and the associated ressources
  40641. */
  40642. dispose(): void;
  40643. private _beforeCameraUpdate;
  40644. }
  40645. }
  40646. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40647. import { Observable } from "babylonjs/Misc/observable";
  40648. import { Nullable } from "babylonjs/types";
  40649. import { Camera } from "babylonjs/Cameras/camera";
  40650. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40651. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40652. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40653. import { Scene } from "babylonjs/scene";
  40654. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40657. import { Mesh } from "babylonjs/Meshes/mesh";
  40658. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40659. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40660. import "babylonjs/Meshes/Builders/groundBuilder";
  40661. import "babylonjs/Meshes/Builders/torusBuilder";
  40662. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40663. import "babylonjs/Gamepads/gamepadSceneComponent";
  40664. import "babylonjs/Animations/animatable";
  40665. /**
  40666. * Options to modify the vr teleportation behavior.
  40667. */
  40668. export interface VRTeleportationOptions {
  40669. /**
  40670. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40671. */
  40672. floorMeshName?: string;
  40673. /**
  40674. * A list of meshes to be used as the teleportation floor. (default: empty)
  40675. */
  40676. floorMeshes?: Mesh[];
  40677. }
  40678. /**
  40679. * Options to modify the vr experience helper's behavior.
  40680. */
  40681. export interface VRExperienceHelperOptions extends WebVROptions {
  40682. /**
  40683. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40684. */
  40685. createDeviceOrientationCamera?: boolean;
  40686. /**
  40687. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40688. */
  40689. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40690. /**
  40691. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40692. */
  40693. laserToggle?: boolean;
  40694. /**
  40695. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40696. */
  40697. floorMeshes?: Mesh[];
  40698. /**
  40699. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40700. */
  40701. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40702. }
  40703. /**
  40704. * Event containing information after VR has been entered
  40705. */
  40706. export class OnAfterEnteringVRObservableEvent {
  40707. /**
  40708. * If entering vr was successful
  40709. */
  40710. success: boolean;
  40711. }
  40712. /**
  40713. * Helps to quickly add VR support to an existing scene.
  40714. * See http://doc.babylonjs.com/how_to/webvr_helper
  40715. */
  40716. export class VRExperienceHelper {
  40717. /** Options to modify the vr experience helper's behavior. */
  40718. webVROptions: VRExperienceHelperOptions;
  40719. private _scene;
  40720. private _position;
  40721. private _btnVR;
  40722. private _btnVRDisplayed;
  40723. private _webVRsupported;
  40724. private _webVRready;
  40725. private _webVRrequesting;
  40726. private _webVRpresenting;
  40727. private _hasEnteredVR;
  40728. private _fullscreenVRpresenting;
  40729. private _canvas;
  40730. private _webVRCamera;
  40731. private _vrDeviceOrientationCamera;
  40732. private _deviceOrientationCamera;
  40733. private _existingCamera;
  40734. private _onKeyDown;
  40735. private _onVrDisplayPresentChange;
  40736. private _onVRDisplayChanged;
  40737. private _onVRRequestPresentStart;
  40738. private _onVRRequestPresentComplete;
  40739. /**
  40740. * Observable raised right before entering VR.
  40741. */
  40742. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40743. /**
  40744. * Observable raised when entering VR has completed.
  40745. */
  40746. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40747. /**
  40748. * Observable raised when exiting VR.
  40749. */
  40750. onExitingVRObservable: Observable<VRExperienceHelper>;
  40751. /**
  40752. * Observable raised when controller mesh is loaded.
  40753. */
  40754. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40755. /** Return this.onEnteringVRObservable
  40756. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40757. */
  40758. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40759. /** Return this.onExitingVRObservable
  40760. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40761. */
  40762. readonly onExitingVR: Observable<VRExperienceHelper>;
  40763. /** Return this.onControllerMeshLoadedObservable
  40764. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40765. */
  40766. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40767. private _rayLength;
  40768. private _useCustomVRButton;
  40769. private _teleportationRequested;
  40770. private _teleportActive;
  40771. private _floorMeshName;
  40772. private _floorMeshesCollection;
  40773. private _rotationAllowed;
  40774. private _teleportBackwardsVector;
  40775. private _teleportationTarget;
  40776. private _isDefaultTeleportationTarget;
  40777. private _postProcessMove;
  40778. private _teleportationFillColor;
  40779. private _teleportationBorderColor;
  40780. private _rotationAngle;
  40781. private _haloCenter;
  40782. private _cameraGazer;
  40783. private _padSensibilityUp;
  40784. private _padSensibilityDown;
  40785. private _leftController;
  40786. private _rightController;
  40787. /**
  40788. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40789. */
  40790. onNewMeshSelected: Observable<AbstractMesh>;
  40791. /**
  40792. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40793. */
  40794. onNewMeshPicked: Observable<PickingInfo>;
  40795. private _circleEase;
  40796. /**
  40797. * Observable raised before camera teleportation
  40798. */
  40799. onBeforeCameraTeleport: Observable<Vector3>;
  40800. /**
  40801. * Observable raised after camera teleportation
  40802. */
  40803. onAfterCameraTeleport: Observable<Vector3>;
  40804. /**
  40805. * Observable raised when current selected mesh gets unselected
  40806. */
  40807. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40808. private _raySelectionPredicate;
  40809. /**
  40810. * To be optionaly changed by user to define custom ray selection
  40811. */
  40812. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40813. /**
  40814. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40815. */
  40816. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40817. /**
  40818. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40819. */
  40820. teleportationEnabled: boolean;
  40821. private _defaultHeight;
  40822. private _teleportationInitialized;
  40823. private _interactionsEnabled;
  40824. private _interactionsRequested;
  40825. private _displayGaze;
  40826. private _displayLaserPointer;
  40827. /**
  40828. * The mesh used to display where the user is going to teleport.
  40829. */
  40830. /**
  40831. * Sets the mesh to be used to display where the user is going to teleport.
  40832. */
  40833. teleportationTarget: Mesh;
  40834. /**
  40835. * 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
  40836. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40837. * See http://doc.babylonjs.com/resources/baking_transformations
  40838. */
  40839. gazeTrackerMesh: Mesh;
  40840. /**
  40841. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40842. */
  40843. updateGazeTrackerScale: boolean;
  40844. /**
  40845. * If the gaze trackers color should be updated when selecting meshes
  40846. */
  40847. updateGazeTrackerColor: boolean;
  40848. /**
  40849. * The gaze tracking mesh corresponding to the left controller
  40850. */
  40851. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40852. /**
  40853. * The gaze tracking mesh corresponding to the right controller
  40854. */
  40855. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40856. /**
  40857. * If the ray of the gaze should be displayed.
  40858. */
  40859. /**
  40860. * Sets if the ray of the gaze should be displayed.
  40861. */
  40862. displayGaze: boolean;
  40863. /**
  40864. * If the ray of the LaserPointer should be displayed.
  40865. */
  40866. /**
  40867. * Sets if the ray of the LaserPointer should be displayed.
  40868. */
  40869. displayLaserPointer: boolean;
  40870. /**
  40871. * The deviceOrientationCamera used as the camera when not in VR.
  40872. */
  40873. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40874. /**
  40875. * Based on the current WebVR support, returns the current VR camera used.
  40876. */
  40877. readonly currentVRCamera: Nullable<Camera>;
  40878. /**
  40879. * The webVRCamera which is used when in VR.
  40880. */
  40881. readonly webVRCamera: WebVRFreeCamera;
  40882. /**
  40883. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40884. */
  40885. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40886. private readonly _teleportationRequestInitiated;
  40887. /**
  40888. * Defines wether or not Pointer lock should be requested when switching to
  40889. * full screen.
  40890. */
  40891. requestPointerLockOnFullScreen: boolean;
  40892. /**
  40893. * Instantiates a VRExperienceHelper.
  40894. * Helps to quickly add VR support to an existing scene.
  40895. * @param scene The scene the VRExperienceHelper belongs to.
  40896. * @param webVROptions Options to modify the vr experience helper's behavior.
  40897. */
  40898. constructor(scene: Scene,
  40899. /** Options to modify the vr experience helper's behavior. */
  40900. webVROptions?: VRExperienceHelperOptions);
  40901. private _onDefaultMeshLoaded;
  40902. private _onResize;
  40903. private _onFullscreenChange;
  40904. /**
  40905. * Gets a value indicating if we are currently in VR mode.
  40906. */
  40907. readonly isInVRMode: boolean;
  40908. private onVrDisplayPresentChange;
  40909. private onVRDisplayChanged;
  40910. private moveButtonToBottomRight;
  40911. private displayVRButton;
  40912. private updateButtonVisibility;
  40913. private _cachedAngularSensibility;
  40914. /**
  40915. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40916. * Otherwise, will use the fullscreen API.
  40917. */
  40918. enterVR(): void;
  40919. /**
  40920. * Attempt to exit VR, or fullscreen.
  40921. */
  40922. exitVR(): void;
  40923. /**
  40924. * The position of the vr experience helper.
  40925. */
  40926. /**
  40927. * Sets the position of the vr experience helper.
  40928. */
  40929. position: Vector3;
  40930. /**
  40931. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40932. */
  40933. enableInteractions(): void;
  40934. private readonly _noControllerIsActive;
  40935. private beforeRender;
  40936. private _isTeleportationFloor;
  40937. /**
  40938. * Adds a floor mesh to be used for teleportation.
  40939. * @param floorMesh the mesh to be used for teleportation.
  40940. */
  40941. addFloorMesh(floorMesh: Mesh): void;
  40942. /**
  40943. * Removes a floor mesh from being used for teleportation.
  40944. * @param floorMesh the mesh to be removed.
  40945. */
  40946. removeFloorMesh(floorMesh: Mesh): void;
  40947. /**
  40948. * Enables interactions and teleportation using the VR controllers and gaze.
  40949. * @param vrTeleportationOptions options to modify teleportation behavior.
  40950. */
  40951. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40952. private _onNewGamepadConnected;
  40953. private _tryEnableInteractionOnController;
  40954. private _onNewGamepadDisconnected;
  40955. private _enableInteractionOnController;
  40956. private _checkTeleportWithRay;
  40957. private _checkRotate;
  40958. private _checkTeleportBackwards;
  40959. private _enableTeleportationOnController;
  40960. private _createTeleportationCircles;
  40961. private _displayTeleportationTarget;
  40962. private _hideTeleportationTarget;
  40963. private _rotateCamera;
  40964. private _moveTeleportationSelectorTo;
  40965. private _workingVector;
  40966. private _workingQuaternion;
  40967. private _workingMatrix;
  40968. /**
  40969. * Teleports the users feet to the desired location
  40970. * @param location The location where the user's feet should be placed
  40971. */
  40972. teleportCamera(location: Vector3): void;
  40973. private _convertNormalToDirectionOfRay;
  40974. private _castRayAndSelectObject;
  40975. private _notifySelectedMeshUnselected;
  40976. /**
  40977. * Sets the color of the laser ray from the vr controllers.
  40978. * @param color new color for the ray.
  40979. */
  40980. changeLaserColor(color: Color3): void;
  40981. /**
  40982. * Sets the color of the ray from the vr headsets gaze.
  40983. * @param color new color for the ray.
  40984. */
  40985. changeGazeColor(color: Color3): void;
  40986. /**
  40987. * Exits VR and disposes of the vr experience helper
  40988. */
  40989. dispose(): void;
  40990. /**
  40991. * Gets the name of the VRExperienceHelper class
  40992. * @returns "VRExperienceHelper"
  40993. */
  40994. getClassName(): string;
  40995. }
  40996. }
  40997. declare module "babylonjs/Cameras/VR/index" {
  40998. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40999. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41000. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41001. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41002. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41003. export * from "babylonjs/Cameras/VR/webVRCamera";
  41004. }
  41005. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41006. import { Observable } from "babylonjs/Misc/observable";
  41007. import { Nullable } from "babylonjs/types";
  41008. import { IDisposable, Scene } from "babylonjs/scene";
  41009. import { Vector3 } from "babylonjs/Maths/math";
  41010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41011. import { Ray } from "babylonjs/Culling/ray";
  41012. /**
  41013. * Manages an XRSession
  41014. * @see https://doc.babylonjs.com/how_to/webxr
  41015. */
  41016. export class WebXRSessionManager implements IDisposable {
  41017. private scene;
  41018. /**
  41019. * Fires every time a new xrFrame arrives which can be used to update the camera
  41020. */
  41021. onXRFrameObservable: Observable<any>;
  41022. /**
  41023. * Fires when the xr session is ended either by the device or manually done
  41024. */
  41025. onXRSessionEnded: Observable<any>;
  41026. /** @hidden */
  41027. _xrSession: XRSession;
  41028. /** @hidden */
  41029. _frameOfReference: XRFrameOfReference;
  41030. /** @hidden */
  41031. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41032. /** @hidden */
  41033. _currentXRFrame: Nullable<XRFrame>;
  41034. private _xrNavigator;
  41035. private _xrDevice;
  41036. private _tmpMatrix;
  41037. /**
  41038. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41039. * @param scene The scene which the session should be created for
  41040. */
  41041. constructor(scene: Scene);
  41042. /**
  41043. * Initializes the manager
  41044. * After initialization enterXR can be called to start an XR session
  41045. * @returns Promise which resolves after it is initialized
  41046. */
  41047. initializeAsync(): Promise<void>;
  41048. /**
  41049. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41050. * @param sessionCreationOptions xr options to create the session with
  41051. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41052. * @returns Promise which resolves after it enters XR
  41053. */
  41054. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41055. /**
  41056. * Stops the xrSession and restores the renderloop
  41057. * @returns Promise which resolves after it exits XR
  41058. */
  41059. exitXRAsync(): Promise<void>;
  41060. /**
  41061. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41062. * @param ray ray to cast into the environment
  41063. * @returns Promise which resolves with a collision point in the environment if it exists
  41064. */
  41065. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41066. /**
  41067. * Checks if a session would be supported for the creation options specified
  41068. * @param options creation options to check if they are supported
  41069. * @returns true if supported
  41070. */
  41071. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41072. /**
  41073. * @hidden
  41074. * Converts the render layer of xrSession to a render target
  41075. * @param session session to create render target for
  41076. * @param scene scene the new render target should be created for
  41077. */
  41078. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41079. /**
  41080. * Disposes of the session manager
  41081. */
  41082. dispose(): void;
  41083. }
  41084. }
  41085. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41086. import { Scene } from "babylonjs/scene";
  41087. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41088. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41089. /**
  41090. * WebXR Camera which holds the views for the xrSession
  41091. * @see https://doc.babylonjs.com/how_to/webxr
  41092. */
  41093. export class WebXRCamera extends FreeCamera {
  41094. private static _TmpMatrix;
  41095. /**
  41096. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41097. * @param name the name of the camera
  41098. * @param scene the scene to add the camera to
  41099. */
  41100. constructor(name: string, scene: Scene);
  41101. private _updateNumberOfRigCameras;
  41102. /** @hidden */
  41103. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41104. /**
  41105. * Updates the cameras position from the current pose information of the XR session
  41106. * @param xrSessionManager the session containing pose information
  41107. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41108. */
  41109. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41110. }
  41111. }
  41112. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41113. import { Nullable } from "babylonjs/types";
  41114. import { Observable } from "babylonjs/Misc/observable";
  41115. import { IDisposable, Scene } from "babylonjs/scene";
  41116. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41118. import { Ray } from "babylonjs/Culling/ray";
  41119. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41120. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41121. /**
  41122. * States of the webXR experience
  41123. */
  41124. export enum WebXRState {
  41125. /**
  41126. * Transitioning to being in XR mode
  41127. */
  41128. ENTERING_XR = 0,
  41129. /**
  41130. * Transitioning to non XR mode
  41131. */
  41132. EXITING_XR = 1,
  41133. /**
  41134. * In XR mode and presenting
  41135. */
  41136. IN_XR = 2,
  41137. /**
  41138. * Not entered XR mode
  41139. */
  41140. NOT_IN_XR = 3
  41141. }
  41142. /**
  41143. * Helper class used to enable XR
  41144. * @see https://doc.babylonjs.com/how_to/webxr
  41145. */
  41146. export class WebXRExperienceHelper implements IDisposable {
  41147. private scene;
  41148. /**
  41149. * 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
  41150. */
  41151. container: AbstractMesh;
  41152. /**
  41153. * Camera used to render xr content
  41154. */
  41155. camera: WebXRCamera;
  41156. /**
  41157. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41158. */
  41159. state: WebXRState;
  41160. private _setState;
  41161. private static _TmpVector;
  41162. /**
  41163. * Fires when the state of the experience helper has changed
  41164. */
  41165. onStateChangedObservable: Observable<WebXRState>;
  41166. /** @hidden */
  41167. _sessionManager: WebXRSessionManager;
  41168. private _nonVRCamera;
  41169. private _originalSceneAutoClear;
  41170. private _supported;
  41171. /**
  41172. * Creates the experience helper
  41173. * @param scene the scene to attach the experience helper to
  41174. * @returns a promise for the experience helper
  41175. */
  41176. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41177. /**
  41178. * Creates a WebXRExperienceHelper
  41179. * @param scene The scene the helper should be created in
  41180. */
  41181. private constructor();
  41182. /**
  41183. * Exits XR mode and returns the scene to its original state
  41184. * @returns promise that resolves after xr mode has exited
  41185. */
  41186. exitXRAsync(): Promise<void>;
  41187. /**
  41188. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41189. * @param sessionCreationOptions options for the XR session
  41190. * @param frameOfReference frame of reference of the XR session
  41191. * @returns promise that resolves after xr mode has entered
  41192. */
  41193. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41194. /**
  41195. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41196. * @param ray ray to cast into the environment
  41197. * @returns Promise which resolves with a collision point in the environment if it exists
  41198. */
  41199. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41200. /**
  41201. * Updates the global position of the camera by moving the camera's container
  41202. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41203. * @param position The desired global position of the camera
  41204. */
  41205. setPositionOfCameraUsingContainer(position: Vector3): void;
  41206. /**
  41207. * Rotates the xr camera by rotating the camera's container around the camera's position
  41208. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41209. * @param rotation the desired quaternion rotation to apply to the camera
  41210. */
  41211. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41212. /**
  41213. * Checks if the creation options are supported by the xr session
  41214. * @param options creation options
  41215. * @returns true if supported
  41216. */
  41217. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41218. /**
  41219. * Disposes of the experience helper
  41220. */
  41221. dispose(): void;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41225. import { Nullable } from "babylonjs/types";
  41226. import { Observable } from "babylonjs/Misc/observable";
  41227. import { IDisposable, Scene } from "babylonjs/scene";
  41228. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41229. /**
  41230. * Button which can be used to enter a different mode of XR
  41231. */
  41232. export class WebXREnterExitUIButton {
  41233. /** button element */
  41234. element: HTMLElement;
  41235. /** XR initialization options for the button */
  41236. initializationOptions: XRSessionCreationOptions;
  41237. /**
  41238. * Creates a WebXREnterExitUIButton
  41239. * @param element button element
  41240. * @param initializationOptions XR initialization options for the button
  41241. */
  41242. constructor(
  41243. /** button element */
  41244. element: HTMLElement,
  41245. /** XR initialization options for the button */
  41246. initializationOptions: XRSessionCreationOptions);
  41247. /**
  41248. * Overwritable function which can be used to update the button's visuals when the state changes
  41249. * @param activeButton the current active button in the UI
  41250. */
  41251. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41252. }
  41253. /**
  41254. * Options to create the webXR UI
  41255. */
  41256. export class WebXREnterExitUIOptions {
  41257. /**
  41258. * Context to enter xr with
  41259. */
  41260. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41261. /**
  41262. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41263. */
  41264. customButtons?: Array<WebXREnterExitUIButton>;
  41265. }
  41266. /**
  41267. * UI to allow the user to enter/exit XR mode
  41268. */
  41269. export class WebXREnterExitUI implements IDisposable {
  41270. private scene;
  41271. private _overlay;
  41272. private _buttons;
  41273. private _activeButton;
  41274. /**
  41275. * Fired every time the active button is changed.
  41276. *
  41277. * When xr is entered via a button that launches xr that button will be the callback parameter
  41278. *
  41279. * When exiting xr the callback parameter will be null)
  41280. */
  41281. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41282. /**
  41283. * Creates UI to allow the user to enter/exit XR mode
  41284. * @param scene the scene to add the ui to
  41285. * @param helper the xr experience helper to enter/exit xr with
  41286. * @param options options to configure the UI
  41287. * @returns the created ui
  41288. */
  41289. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41290. private constructor();
  41291. private _updateButtons;
  41292. /**
  41293. * Disposes of the object
  41294. */
  41295. dispose(): void;
  41296. }
  41297. }
  41298. declare module "babylonjs/Cameras/XR/webXRInput" {
  41299. import { IDisposable, Scene } from "babylonjs/scene";
  41300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41301. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41302. /**
  41303. * Represents an XR input
  41304. */
  41305. export class WebXRController {
  41306. /**
  41307. * 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
  41308. */
  41309. grip?: AbstractMesh;
  41310. /**
  41311. * Pointer which can be used to select objects or attach a visible laser to
  41312. */
  41313. pointer: AbstractMesh;
  41314. /**
  41315. * Creates the controller
  41316. * @see https://doc.babylonjs.com/how_to/webxr
  41317. * @param scene the scene which the controller should be associated to
  41318. */
  41319. constructor(scene: Scene);
  41320. /**
  41321. * Disposes of the object
  41322. */
  41323. dispose(): void;
  41324. }
  41325. /**
  41326. * XR input used to track XR inputs such as controllers/rays
  41327. */
  41328. export class WebXRInput implements IDisposable {
  41329. private helper;
  41330. /**
  41331. * XR controllers being tracked
  41332. */
  41333. controllers: Array<WebXRController>;
  41334. private _tmpMatrix;
  41335. private _frameObserver;
  41336. /**
  41337. * Initializes the WebXRInput
  41338. * @param helper experience helper which the input should be created for
  41339. */
  41340. constructor(helper: WebXRExperienceHelper);
  41341. /**
  41342. * Disposes of the object
  41343. */
  41344. dispose(): void;
  41345. }
  41346. }
  41347. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41348. import { Nullable } from "babylonjs/types";
  41349. import { IDisposable } from "babylonjs/scene";
  41350. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41351. /**
  41352. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41353. */
  41354. export class WebXRManagedOutputCanvas implements IDisposable {
  41355. private _canvas;
  41356. /**
  41357. * xrpresent context of the canvas which can be used to display/mirror xr content
  41358. */
  41359. canvasContext: Nullable<WebGLRenderingContext>;
  41360. /**
  41361. * Initializes the canvas to be added/removed upon entering/exiting xr
  41362. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41363. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41364. */
  41365. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41366. /**
  41367. * Disposes of the object
  41368. */
  41369. dispose(): void;
  41370. private _setManagedOutputCanvas;
  41371. private _addCanvas;
  41372. private _removeCanvas;
  41373. }
  41374. }
  41375. declare module "babylonjs/Cameras/XR/index" {
  41376. export * from "babylonjs/Cameras/XR/webXRCamera";
  41377. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41378. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41379. export * from "babylonjs/Cameras/XR/webXRInput";
  41380. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41381. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41382. }
  41383. declare module "babylonjs/Cameras/RigModes/index" {
  41384. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41385. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41386. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41387. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41388. }
  41389. declare module "babylonjs/Cameras/index" {
  41390. export * from "babylonjs/Cameras/Inputs/index";
  41391. export * from "babylonjs/Cameras/cameraInputsManager";
  41392. export * from "babylonjs/Cameras/camera";
  41393. export * from "babylonjs/Cameras/targetCamera";
  41394. export * from "babylonjs/Cameras/freeCamera";
  41395. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41396. export * from "babylonjs/Cameras/touchCamera";
  41397. export * from "babylonjs/Cameras/arcRotateCamera";
  41398. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41399. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41400. export * from "babylonjs/Cameras/flyCamera";
  41401. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41402. export * from "babylonjs/Cameras/followCamera";
  41403. export * from "babylonjs/Cameras/gamepadCamera";
  41404. export * from "babylonjs/Cameras/Stereoscopic/index";
  41405. export * from "babylonjs/Cameras/universalCamera";
  41406. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41407. export * from "babylonjs/Cameras/VR/index";
  41408. export * from "babylonjs/Cameras/XR/index";
  41409. export * from "babylonjs/Cameras/RigModes/index";
  41410. }
  41411. declare module "babylonjs/Collisions/index" {
  41412. export * from "babylonjs/Collisions/collider";
  41413. export * from "babylonjs/Collisions/collisionCoordinator";
  41414. export * from "babylonjs/Collisions/pickingInfo";
  41415. export * from "babylonjs/Collisions/intersectionInfo";
  41416. }
  41417. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41418. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41419. import { Vector3, Plane } from "babylonjs/Maths/math";
  41420. import { Ray } from "babylonjs/Culling/ray";
  41421. /**
  41422. * Contains an array of blocks representing the octree
  41423. */
  41424. export interface IOctreeContainer<T> {
  41425. /**
  41426. * Blocks within the octree
  41427. */
  41428. blocks: Array<OctreeBlock<T>>;
  41429. }
  41430. /**
  41431. * Class used to store a cell in an octree
  41432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41433. */
  41434. export class OctreeBlock<T> {
  41435. /**
  41436. * Gets the content of the current block
  41437. */
  41438. entries: T[];
  41439. /**
  41440. * Gets the list of block children
  41441. */
  41442. blocks: Array<OctreeBlock<T>>;
  41443. private _depth;
  41444. private _maxDepth;
  41445. private _capacity;
  41446. private _minPoint;
  41447. private _maxPoint;
  41448. private _boundingVectors;
  41449. private _creationFunc;
  41450. /**
  41451. * Creates a new block
  41452. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41453. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41454. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41455. * @param depth defines the current depth of this block in the octree
  41456. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41457. * @param creationFunc defines a callback to call when an element is added to the block
  41458. */
  41459. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41460. /**
  41461. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41462. */
  41463. readonly capacity: number;
  41464. /**
  41465. * Gets the minimum vector (in world space) of the block's bounding box
  41466. */
  41467. readonly minPoint: Vector3;
  41468. /**
  41469. * Gets the maximum vector (in world space) of the block's bounding box
  41470. */
  41471. readonly maxPoint: Vector3;
  41472. /**
  41473. * Add a new element to this block
  41474. * @param entry defines the element to add
  41475. */
  41476. addEntry(entry: T): void;
  41477. /**
  41478. * Remove an element from this block
  41479. * @param entry defines the element to remove
  41480. */
  41481. removeEntry(entry: T): void;
  41482. /**
  41483. * Add an array of elements to this block
  41484. * @param entries defines the array of elements to add
  41485. */
  41486. addEntries(entries: T[]): void;
  41487. /**
  41488. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41489. * @param frustumPlanes defines the frustum planes to test
  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. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41494. /**
  41495. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41496. * @param sphereCenter defines the bounding sphere center
  41497. * @param sphereRadius defines the bounding sphere radius
  41498. * @param selection defines the array to store current content if selection is positive
  41499. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41500. */
  41501. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41502. /**
  41503. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41504. * @param ray defines the ray to test with
  41505. * @param selection defines the array to store current content if selection is positive
  41506. */
  41507. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41508. /**
  41509. * Subdivide the content into child blocks (this block will then be empty)
  41510. */
  41511. createInnerBlocks(): void;
  41512. /**
  41513. * @hidden
  41514. */
  41515. 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;
  41516. }
  41517. }
  41518. declare module "babylonjs/Culling/Octrees/octree" {
  41519. import { SmartArray } from "babylonjs/Misc/smartArray";
  41520. import { Vector3, Plane } from "babylonjs/Maths/math";
  41521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41523. import { Ray } from "babylonjs/Culling/ray";
  41524. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41525. /**
  41526. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41527. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41528. */
  41529. export class Octree<T> {
  41530. /** 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.) */
  41531. maxDepth: number;
  41532. /**
  41533. * Blocks within the octree containing objects
  41534. */
  41535. blocks: Array<OctreeBlock<T>>;
  41536. /**
  41537. * Content stored in the octree
  41538. */
  41539. dynamicContent: T[];
  41540. private _maxBlockCapacity;
  41541. private _selectionContent;
  41542. private _creationFunc;
  41543. /**
  41544. * Creates a octree
  41545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41546. * @param creationFunc function to be used to instatiate the octree
  41547. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41548. * @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.)
  41549. */
  41550. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41551. /** 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.) */
  41552. maxDepth?: number);
  41553. /**
  41554. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41555. * @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);
  41556. * @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);
  41557. * @param entries meshes to be added to the octree blocks
  41558. */
  41559. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41560. /**
  41561. * Adds a mesh to the octree
  41562. * @param entry Mesh to add to the octree
  41563. */
  41564. addMesh(entry: T): void;
  41565. /**
  41566. * Remove an element from the octree
  41567. * @param entry defines the element to remove
  41568. */
  41569. removeMesh(entry: T): void;
  41570. /**
  41571. * Selects an array of meshes within the frustum
  41572. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41573. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41574. * @returns array of meshes within the frustum
  41575. */
  41576. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41577. /**
  41578. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41579. * @param sphereCenter defines the bounding sphere center
  41580. * @param sphereRadius defines the bounding sphere radius
  41581. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41582. * @returns an array of objects that intersect the sphere
  41583. */
  41584. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41585. /**
  41586. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41587. * @param ray defines the ray to test with
  41588. * @returns array of intersected objects
  41589. */
  41590. intersectsRay(ray: Ray): SmartArray<T>;
  41591. /**
  41592. * Adds a mesh into the octree block if it intersects the block
  41593. */
  41594. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41595. /**
  41596. * Adds a submesh into the octree block if it intersects the block
  41597. */
  41598. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41599. }
  41600. }
  41601. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41602. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41603. import { Scene } from "babylonjs/scene";
  41604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41606. import { Ray } from "babylonjs/Culling/ray";
  41607. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41608. import { Collider } from "babylonjs/Collisions/collider";
  41609. module "babylonjs/scene" {
  41610. interface Scene {
  41611. /**
  41612. * @hidden
  41613. * Backing Filed
  41614. */
  41615. _selectionOctree: Octree<AbstractMesh>;
  41616. /**
  41617. * Gets the octree used to boost mesh selection (picking)
  41618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41619. */
  41620. selectionOctree: Octree<AbstractMesh>;
  41621. /**
  41622. * Creates or updates the octree used to boost selection (picking)
  41623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41624. * @param maxCapacity defines the maximum capacity per leaf
  41625. * @param maxDepth defines the maximum depth of the octree
  41626. * @returns an octree of AbstractMesh
  41627. */
  41628. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41629. }
  41630. }
  41631. module "babylonjs/Meshes/abstractMesh" {
  41632. interface AbstractMesh {
  41633. /**
  41634. * @hidden
  41635. * Backing Field
  41636. */
  41637. _submeshesOctree: Octree<SubMesh>;
  41638. /**
  41639. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41640. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41641. * @param maxCapacity defines the maximum size of each block (64 by default)
  41642. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41643. * @returns the new octree
  41644. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41646. */
  41647. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41648. }
  41649. }
  41650. /**
  41651. * Defines the octree scene component responsible to manage any octrees
  41652. * in a given scene.
  41653. */
  41654. export class OctreeSceneComponent {
  41655. /**
  41656. * The component name helpfull to identify the component in the list of scene components.
  41657. */
  41658. readonly name: string;
  41659. /**
  41660. * The scene the component belongs to.
  41661. */
  41662. scene: Scene;
  41663. /**
  41664. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41665. */
  41666. readonly checksIsEnabled: boolean;
  41667. /**
  41668. * Creates a new instance of the component for the given scene
  41669. * @param scene Defines the scene to register the component in
  41670. */
  41671. constructor(scene: Scene);
  41672. /**
  41673. * Registers the component in a given scene
  41674. */
  41675. register(): void;
  41676. /**
  41677. * Return the list of active meshes
  41678. * @returns the list of active meshes
  41679. */
  41680. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41681. /**
  41682. * Return the list of active sub meshes
  41683. * @param mesh The mesh to get the candidates sub meshes from
  41684. * @returns the list of active sub meshes
  41685. */
  41686. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41687. private _tempRay;
  41688. /**
  41689. * Return the list of sub meshes intersecting with a given local ray
  41690. * @param mesh defines the mesh to find the submesh for
  41691. * @param localRay defines the ray in local space
  41692. * @returns the list of intersecting sub meshes
  41693. */
  41694. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41695. /**
  41696. * Return the list of sub meshes colliding with a collider
  41697. * @param mesh defines the mesh to find the submesh for
  41698. * @param collider defines the collider to evaluate the collision against
  41699. * @returns the list of colliding sub meshes
  41700. */
  41701. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41702. /**
  41703. * Rebuilds the elements related to this component in case of
  41704. * context lost for instance.
  41705. */
  41706. rebuild(): void;
  41707. /**
  41708. * Disposes the component and the associated ressources.
  41709. */
  41710. dispose(): void;
  41711. }
  41712. }
  41713. declare module "babylonjs/Culling/Octrees/index" {
  41714. export * from "babylonjs/Culling/Octrees/octree";
  41715. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41716. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41717. }
  41718. declare module "babylonjs/Culling/index" {
  41719. export * from "babylonjs/Culling/boundingBox";
  41720. export * from "babylonjs/Culling/boundingInfo";
  41721. export * from "babylonjs/Culling/boundingSphere";
  41722. export * from "babylonjs/Culling/Octrees/index";
  41723. export * from "babylonjs/Culling/ray";
  41724. }
  41725. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41726. import { IDisposable, Scene } from "babylonjs/scene";
  41727. import { Nullable } from "babylonjs/types";
  41728. import { Observable } from "babylonjs/Misc/observable";
  41729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41730. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41731. /**
  41732. * Renders a layer on top of an existing scene
  41733. */
  41734. export class UtilityLayerRenderer implements IDisposable {
  41735. /** the original scene that will be rendered on top of */
  41736. originalScene: Scene;
  41737. private _pointerCaptures;
  41738. private _lastPointerEvents;
  41739. private static _DefaultUtilityLayer;
  41740. private static _DefaultKeepDepthUtilityLayer;
  41741. private _sharedGizmoLight;
  41742. /**
  41743. * @hidden
  41744. * Light which used by gizmos to get light shading
  41745. */
  41746. _getSharedGizmoLight(): HemisphericLight;
  41747. /**
  41748. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41749. */
  41750. pickUtilitySceneFirst: boolean;
  41751. /**
  41752. * 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)
  41753. */
  41754. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41755. /**
  41756. * 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)
  41757. */
  41758. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41759. /**
  41760. * The scene that is rendered on top of the original scene
  41761. */
  41762. utilityLayerScene: Scene;
  41763. /**
  41764. * If the utility layer should automatically be rendered on top of existing scene
  41765. */
  41766. shouldRender: boolean;
  41767. /**
  41768. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41769. */
  41770. onlyCheckPointerDownEvents: boolean;
  41771. /**
  41772. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41773. */
  41774. processAllEvents: boolean;
  41775. /**
  41776. * Observable raised when the pointer move from the utility layer scene to the main scene
  41777. */
  41778. onPointerOutObservable: Observable<number>;
  41779. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41780. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41781. private _afterRenderObserver;
  41782. private _sceneDisposeObserver;
  41783. private _originalPointerObserver;
  41784. /**
  41785. * Instantiates a UtilityLayerRenderer
  41786. * @param originalScene the original scene that will be rendered on top of
  41787. * @param handleEvents boolean indicating if the utility layer should handle events
  41788. */
  41789. constructor(
  41790. /** the original scene that will be rendered on top of */
  41791. originalScene: Scene, handleEvents?: boolean);
  41792. private _notifyObservers;
  41793. /**
  41794. * Renders the utility layers scene on top of the original scene
  41795. */
  41796. render(): void;
  41797. /**
  41798. * Disposes of the renderer
  41799. */
  41800. dispose(): void;
  41801. private _updateCamera;
  41802. }
  41803. }
  41804. declare module "babylonjs/Gizmos/gizmo" {
  41805. import { Nullable } from "babylonjs/types";
  41806. import { IDisposable } from "babylonjs/scene";
  41807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41808. import { Mesh } from "babylonjs/Meshes/mesh";
  41809. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41810. /**
  41811. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41812. */
  41813. export class Gizmo implements IDisposable {
  41814. /** The utility layer the gizmo will be added to */
  41815. gizmoLayer: UtilityLayerRenderer;
  41816. /**
  41817. * The root mesh of the gizmo
  41818. */
  41819. _rootMesh: Mesh;
  41820. private _attachedMesh;
  41821. /**
  41822. * Ratio for the scale of the gizmo (Default: 1)
  41823. */
  41824. scaleRatio: number;
  41825. private _tmpMatrix;
  41826. /**
  41827. * If a custom mesh has been set (Default: false)
  41828. */
  41829. protected _customMeshSet: boolean;
  41830. /**
  41831. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41832. * * When set, interactions will be enabled
  41833. */
  41834. attachedMesh: Nullable<AbstractMesh>;
  41835. /**
  41836. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41837. * @param mesh The mesh to replace the default mesh of the gizmo
  41838. */
  41839. setCustomMesh(mesh: Mesh): void;
  41840. /**
  41841. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41842. */
  41843. updateGizmoRotationToMatchAttachedMesh: boolean;
  41844. /**
  41845. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41846. */
  41847. updateGizmoPositionToMatchAttachedMesh: boolean;
  41848. /**
  41849. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41850. */
  41851. protected _updateScale: boolean;
  41852. protected _interactionsEnabled: boolean;
  41853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41854. private _beforeRenderObserver;
  41855. /**
  41856. * Creates a gizmo
  41857. * @param gizmoLayer The utility layer the gizmo will be added to
  41858. */
  41859. constructor(
  41860. /** The utility layer the gizmo will be added to */
  41861. gizmoLayer?: UtilityLayerRenderer);
  41862. private _tempVector;
  41863. /**
  41864. * @hidden
  41865. * Updates the gizmo to match the attached mesh's position/rotation
  41866. */
  41867. protected _update(): void;
  41868. /**
  41869. * Disposes of the gizmo
  41870. */
  41871. dispose(): void;
  41872. }
  41873. }
  41874. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41875. import { Observable } from "babylonjs/Misc/observable";
  41876. import { Nullable } from "babylonjs/types";
  41877. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41880. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41881. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41883. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41884. import { Scene } from "babylonjs/scene";
  41885. /**
  41886. * Single axis drag gizmo
  41887. */
  41888. export class AxisDragGizmo extends Gizmo {
  41889. /**
  41890. * Drag behavior responsible for the gizmos dragging interactions
  41891. */
  41892. dragBehavior: PointerDragBehavior;
  41893. private _pointerObserver;
  41894. /**
  41895. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41896. */
  41897. snapDistance: number;
  41898. /**
  41899. * Event that fires each time the gizmo snaps to a new location.
  41900. * * snapDistance is the the change in distance
  41901. */
  41902. onSnapObservable: Observable<{
  41903. snapDistance: number;
  41904. }>;
  41905. /** @hidden */
  41906. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41907. /** @hidden */
  41908. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41909. /**
  41910. * Creates an AxisDragGizmo
  41911. * @param gizmoLayer The utility layer the gizmo will be added to
  41912. * @param dragAxis The axis which the gizmo will be able to drag on
  41913. * @param color The color of the gizmo
  41914. */
  41915. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41917. /**
  41918. * Disposes of the gizmo
  41919. */
  41920. dispose(): void;
  41921. }
  41922. }
  41923. declare module "babylonjs/Debug/axesViewer" {
  41924. import { Vector3 } from "babylonjs/Maths/math";
  41925. import { Nullable } from "babylonjs/types";
  41926. import { Scene } from "babylonjs/scene";
  41927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41928. /**
  41929. * The Axes viewer will show 3 axes in a specific point in space
  41930. */
  41931. export class AxesViewer {
  41932. private _xAxis;
  41933. private _yAxis;
  41934. private _zAxis;
  41935. private _scaleLinesFactor;
  41936. private _instanced;
  41937. /**
  41938. * Gets the hosting scene
  41939. */
  41940. scene: Scene;
  41941. /**
  41942. * Gets or sets a number used to scale line length
  41943. */
  41944. scaleLines: number;
  41945. /** Gets the node hierarchy used to render x-axis */
  41946. readonly xAxis: TransformNode;
  41947. /** Gets the node hierarchy used to render y-axis */
  41948. readonly yAxis: TransformNode;
  41949. /** Gets the node hierarchy used to render z-axis */
  41950. readonly zAxis: TransformNode;
  41951. /**
  41952. * Creates a new AxesViewer
  41953. * @param scene defines the hosting scene
  41954. * @param scaleLines defines a number used to scale line length (1 by default)
  41955. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41956. * @param xAxis defines the node hierarchy used to render the x-axis
  41957. * @param yAxis defines the node hierarchy used to render the y-axis
  41958. * @param zAxis defines the node hierarchy used to render the z-axis
  41959. */
  41960. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41961. /**
  41962. * Force the viewer to update
  41963. * @param position defines the position of the viewer
  41964. * @param xaxis defines the x axis of the viewer
  41965. * @param yaxis defines the y axis of the viewer
  41966. * @param zaxis defines the z axis of the viewer
  41967. */
  41968. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41969. /**
  41970. * Creates an instance of this axes viewer.
  41971. * @returns a new axes viewer with instanced meshes
  41972. */
  41973. createInstance(): AxesViewer;
  41974. /** Releases resources */
  41975. dispose(): void;
  41976. private static _SetRenderingGroupId;
  41977. }
  41978. }
  41979. declare module "babylonjs/Debug/boneAxesViewer" {
  41980. import { Nullable } from "babylonjs/types";
  41981. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41982. import { Vector3 } from "babylonjs/Maths/math";
  41983. import { Mesh } from "babylonjs/Meshes/mesh";
  41984. import { Bone } from "babylonjs/Bones/bone";
  41985. import { Scene } from "babylonjs/scene";
  41986. /**
  41987. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41988. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41989. */
  41990. export class BoneAxesViewer extends AxesViewer {
  41991. /**
  41992. * Gets or sets the target mesh where to display the axes viewer
  41993. */
  41994. mesh: Nullable<Mesh>;
  41995. /**
  41996. * Gets or sets the target bone where to display the axes viewer
  41997. */
  41998. bone: Nullable<Bone>;
  41999. /** Gets current position */
  42000. pos: Vector3;
  42001. /** Gets direction of X axis */
  42002. xaxis: Vector3;
  42003. /** Gets direction of Y axis */
  42004. yaxis: Vector3;
  42005. /** Gets direction of Z axis */
  42006. zaxis: Vector3;
  42007. /**
  42008. * Creates a new BoneAxesViewer
  42009. * @param scene defines the hosting scene
  42010. * @param bone defines the target bone
  42011. * @param mesh defines the target mesh
  42012. * @param scaleLines defines a scaling factor for line length (1 by default)
  42013. */
  42014. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42015. /**
  42016. * Force the viewer to update
  42017. */
  42018. update(): void;
  42019. /** Releases resources */
  42020. dispose(): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Debug/debugLayer" {
  42024. import { Observable } from "babylonjs/Misc/observable";
  42025. import { Scene } from "babylonjs/scene";
  42026. /**
  42027. * Interface used to define scene explorer extensibility option
  42028. */
  42029. export interface IExplorerExtensibilityOption {
  42030. /**
  42031. * Define the option label
  42032. */
  42033. label: string;
  42034. /**
  42035. * Defines the action to execute on click
  42036. */
  42037. action: (entity: any) => void;
  42038. }
  42039. /**
  42040. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42041. */
  42042. export interface IExplorerExtensibilityGroup {
  42043. /**
  42044. * Defines a predicate to test if a given type mut be extended
  42045. */
  42046. predicate: (entity: any) => boolean;
  42047. /**
  42048. * Gets the list of options added to a type
  42049. */
  42050. entries: IExplorerExtensibilityOption[];
  42051. }
  42052. /**
  42053. * Interface used to define the options to use to create the Inspector
  42054. */
  42055. export interface IInspectorOptions {
  42056. /**
  42057. * Display in overlay mode (default: false)
  42058. */
  42059. overlay?: boolean;
  42060. /**
  42061. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42062. */
  42063. globalRoot?: HTMLElement;
  42064. /**
  42065. * Display the Scene explorer
  42066. */
  42067. showExplorer?: boolean;
  42068. /**
  42069. * Display the property inspector
  42070. */
  42071. showInspector?: boolean;
  42072. /**
  42073. * Display in embed mode (both panes on the right)
  42074. */
  42075. embedMode?: boolean;
  42076. /**
  42077. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42078. */
  42079. handleResize?: boolean;
  42080. /**
  42081. * Allow the panes to popup (default: true)
  42082. */
  42083. enablePopup?: boolean;
  42084. /**
  42085. * Allow the panes to be closed by users (default: true)
  42086. */
  42087. enableClose?: boolean;
  42088. /**
  42089. * Optional list of extensibility entries
  42090. */
  42091. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42092. /**
  42093. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42094. */
  42095. inspectorURL?: string;
  42096. }
  42097. module "babylonjs/scene" {
  42098. interface Scene {
  42099. /**
  42100. * @hidden
  42101. * Backing field
  42102. */
  42103. _debugLayer: DebugLayer;
  42104. /**
  42105. * Gets the debug layer (aka Inspector) associated with the scene
  42106. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42107. */
  42108. debugLayer: DebugLayer;
  42109. }
  42110. }
  42111. /**
  42112. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42113. * what is happening in your scene
  42114. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42115. */
  42116. export class DebugLayer {
  42117. /**
  42118. * Define the url to get the inspector script from.
  42119. * By default it uses the babylonjs CDN.
  42120. * @ignoreNaming
  42121. */
  42122. static InspectorURL: string;
  42123. private _scene;
  42124. private BJSINSPECTOR;
  42125. /**
  42126. * Observable triggered when a property is changed through the inspector.
  42127. */
  42128. onPropertyChangedObservable: Observable<{
  42129. object: any;
  42130. property: string;
  42131. value: any;
  42132. initialValue: any;
  42133. }>;
  42134. /**
  42135. * Instantiates a new debug layer.
  42136. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42137. * what is happening in your scene
  42138. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42139. * @param scene Defines the scene to inspect
  42140. */
  42141. constructor(scene: Scene);
  42142. /** Creates the inspector window. */
  42143. private _createInspector;
  42144. /**
  42145. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42146. * @param entity defines the entity to select
  42147. * @param lineContainerTitle defines the specific block to highlight
  42148. */
  42149. select(entity: any, lineContainerTitle?: string): void;
  42150. /** Get the inspector from bundle or global */
  42151. private _getGlobalInspector;
  42152. /**
  42153. * Get if the inspector is visible or not.
  42154. * @returns true if visible otherwise, false
  42155. */
  42156. isVisible(): boolean;
  42157. /**
  42158. * Hide the inspector and close its window.
  42159. */
  42160. hide(): void;
  42161. /**
  42162. * Launch the debugLayer.
  42163. * @param config Define the configuration of the inspector
  42164. * @return a promise fulfilled when the debug layer is visible
  42165. */
  42166. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42167. }
  42168. }
  42169. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42170. import { Nullable } from "babylonjs/types";
  42171. import { Scene } from "babylonjs/scene";
  42172. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42173. import { Mesh } from "babylonjs/Meshes/mesh";
  42174. /**
  42175. * Class containing static functions to help procedurally build meshes
  42176. */
  42177. export class BoxBuilder {
  42178. /**
  42179. * Creates a box mesh
  42180. * * The parameter `size` sets the size (float) of each box side (default 1)
  42181. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42182. * * 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)
  42183. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42187. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42188. * @param name defines the name of the mesh
  42189. * @param options defines the options used to create the mesh
  42190. * @param scene defines the hosting scene
  42191. * @returns the box mesh
  42192. */
  42193. static CreateBox(name: string, options: {
  42194. size?: number;
  42195. width?: number;
  42196. height?: number;
  42197. depth?: number;
  42198. faceUV?: Vector4[];
  42199. faceColors?: Color4[];
  42200. sideOrientation?: number;
  42201. frontUVs?: Vector4;
  42202. backUVs?: Vector4;
  42203. updatable?: boolean;
  42204. }, scene?: Nullable<Scene>): Mesh;
  42205. }
  42206. }
  42207. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42208. import { Vector4 } from "babylonjs/Maths/math";
  42209. import { Mesh } from "babylonjs/Meshes/mesh";
  42210. /**
  42211. * Class containing static functions to help procedurally build meshes
  42212. */
  42213. export class SphereBuilder {
  42214. /**
  42215. * Creates a sphere mesh
  42216. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42217. * * 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`)
  42218. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42219. * * 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
  42220. * * 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)
  42221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42224. * @param name defines the name of the mesh
  42225. * @param options defines the options used to create the mesh
  42226. * @param scene defines the hosting scene
  42227. * @returns the sphere mesh
  42228. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42229. */
  42230. static CreateSphere(name: string, options: {
  42231. segments?: number;
  42232. diameter?: number;
  42233. diameterX?: number;
  42234. diameterY?: number;
  42235. diameterZ?: number;
  42236. arc?: number;
  42237. slice?: number;
  42238. sideOrientation?: number;
  42239. frontUVs?: Vector4;
  42240. backUVs?: Vector4;
  42241. updatable?: boolean;
  42242. }, scene: any): Mesh;
  42243. }
  42244. }
  42245. declare module "babylonjs/Debug/physicsViewer" {
  42246. import { Nullable } from "babylonjs/types";
  42247. import { Scene } from "babylonjs/scene";
  42248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42249. import { Mesh } from "babylonjs/Meshes/mesh";
  42250. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42251. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42252. /**
  42253. * Used to show the physics impostor around the specific mesh
  42254. */
  42255. export class PhysicsViewer {
  42256. /** @hidden */
  42257. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42258. /** @hidden */
  42259. protected _meshes: Array<Nullable<AbstractMesh>>;
  42260. /** @hidden */
  42261. protected _scene: Nullable<Scene>;
  42262. /** @hidden */
  42263. protected _numMeshes: number;
  42264. /** @hidden */
  42265. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42266. private _renderFunction;
  42267. private _utilityLayer;
  42268. private _debugBoxMesh;
  42269. private _debugSphereMesh;
  42270. private _debugMaterial;
  42271. private _debugMeshMeshes;
  42272. /**
  42273. * Creates a new PhysicsViewer
  42274. * @param scene defines the hosting scene
  42275. */
  42276. constructor(scene: Scene);
  42277. /** @hidden */
  42278. protected _updateDebugMeshes(): void;
  42279. /**
  42280. * Renders a specified physic impostor
  42281. * @param impostor defines the impostor to render
  42282. * @param targetMesh defines the mesh represented by the impostor
  42283. * @returns the new debug mesh used to render the impostor
  42284. */
  42285. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42286. /**
  42287. * Hides a specified physic impostor
  42288. * @param impostor defines the impostor to hide
  42289. */
  42290. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42291. private _getDebugMaterial;
  42292. private _getDebugBoxMesh;
  42293. private _getDebugSphereMesh;
  42294. private _getDebugMeshMesh;
  42295. private _getDebugMesh;
  42296. /** Releases all resources */
  42297. dispose(): void;
  42298. }
  42299. }
  42300. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42301. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42302. import { Nullable } from "babylonjs/types";
  42303. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42304. import { Scene } from "babylonjs/scene";
  42305. /**
  42306. * Class containing static functions to help procedurally build meshes
  42307. */
  42308. export class LinesBuilder {
  42309. /**
  42310. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42311. * * 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
  42312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42313. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42314. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42315. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42317. * * 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
  42318. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42321. * @param name defines the name of the new line system
  42322. * @param options defines the options used to create the line system
  42323. * @param scene defines the hosting scene
  42324. * @returns a new line system mesh
  42325. */
  42326. static CreateLineSystem(name: string, options: {
  42327. lines: Vector3[][];
  42328. updatable?: boolean;
  42329. instance?: Nullable<LinesMesh>;
  42330. colors?: Nullable<Color4[][]>;
  42331. useVertexAlpha?: boolean;
  42332. }, scene: Nullable<Scene>): LinesMesh;
  42333. /**
  42334. * Creates a line mesh
  42335. * 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
  42336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42337. * * The parameter `points` is an array successive Vector3
  42338. * * 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
  42339. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42341. * * When updating an instance, remember that only point positions can change, not the number of points
  42342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42344. * @param name defines the name of the new line system
  42345. * @param options defines the options used to create the line system
  42346. * @param scene defines the hosting scene
  42347. * @returns a new line mesh
  42348. */
  42349. static CreateLines(name: string, options: {
  42350. points: Vector3[];
  42351. updatable?: boolean;
  42352. instance?: Nullable<LinesMesh>;
  42353. colors?: Color4[];
  42354. useVertexAlpha?: boolean;
  42355. }, scene?: Nullable<Scene>): LinesMesh;
  42356. /**
  42357. * Creates a dashed line mesh
  42358. * * 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
  42359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42360. * * The parameter `points` is an array successive Vector3
  42361. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42362. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42363. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42364. * * 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
  42365. * * When updating an instance, remember that only point positions can change, not the number of points
  42366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42367. * @param name defines the name of the mesh
  42368. * @param options defines the options used to create the mesh
  42369. * @param scene defines the hosting scene
  42370. * @returns the dashed line mesh
  42371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42372. */
  42373. static CreateDashedLines(name: string, options: {
  42374. points: Vector3[];
  42375. dashSize?: number;
  42376. gapSize?: number;
  42377. dashNb?: number;
  42378. updatable?: boolean;
  42379. instance?: LinesMesh;
  42380. }, scene?: Nullable<Scene>): LinesMesh;
  42381. }
  42382. }
  42383. declare module "babylonjs/Debug/rayHelper" {
  42384. import { Nullable } from "babylonjs/types";
  42385. import { Ray } from "babylonjs/Culling/ray";
  42386. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42387. import { Scene } from "babylonjs/scene";
  42388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42389. import "babylonjs/Meshes/Builders/linesBuilder";
  42390. /**
  42391. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42392. * in order to better appreciate the issue one might have.
  42393. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42394. */
  42395. export class RayHelper {
  42396. /**
  42397. * Defines the ray we are currently tryin to visualize.
  42398. */
  42399. ray: Nullable<Ray>;
  42400. private _renderPoints;
  42401. private _renderLine;
  42402. private _renderFunction;
  42403. private _scene;
  42404. private _updateToMeshFunction;
  42405. private _attachedToMesh;
  42406. private _meshSpaceDirection;
  42407. private _meshSpaceOrigin;
  42408. /**
  42409. * Helper function to create a colored helper in a scene in one line.
  42410. * @param ray Defines the ray we are currently tryin to visualize
  42411. * @param scene Defines the scene the ray is used in
  42412. * @param color Defines the color we want to see the ray in
  42413. * @returns The newly created ray helper.
  42414. */
  42415. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42416. /**
  42417. * Instantiate a new ray helper.
  42418. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42419. * in order to better appreciate the issue one might have.
  42420. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42421. * @param ray Defines the ray we are currently tryin to visualize
  42422. */
  42423. constructor(ray: Ray);
  42424. /**
  42425. * Shows the ray we are willing to debug.
  42426. * @param scene Defines the scene the ray needs to be rendered in
  42427. * @param color Defines the color the ray needs to be rendered in
  42428. */
  42429. show(scene: Scene, color?: Color3): void;
  42430. /**
  42431. * Hides the ray we are debugging.
  42432. */
  42433. hide(): void;
  42434. private _render;
  42435. /**
  42436. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42437. * @param mesh Defines the mesh we want the helper attached to
  42438. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42439. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42440. * @param length Defines the length of the ray
  42441. */
  42442. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42443. /**
  42444. * Detach the ray helper from the mesh it has previously been attached to.
  42445. */
  42446. detachFromMesh(): void;
  42447. private _updateToMesh;
  42448. /**
  42449. * Dispose the helper and release its associated resources.
  42450. */
  42451. dispose(): void;
  42452. }
  42453. }
  42454. declare module "babylonjs/Debug/skeletonViewer" {
  42455. import { Color3 } from "babylonjs/Maths/math";
  42456. import { Scene } from "babylonjs/scene";
  42457. import { Nullable } from "babylonjs/types";
  42458. import { Skeleton } from "babylonjs/Bones/skeleton";
  42459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42460. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42461. /**
  42462. * Class used to render a debug view of a given skeleton
  42463. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42464. */
  42465. export class SkeletonViewer {
  42466. /** defines the skeleton to render */
  42467. skeleton: Skeleton;
  42468. /** defines the mesh attached to the skeleton */
  42469. mesh: AbstractMesh;
  42470. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42471. autoUpdateBonesMatrices: boolean;
  42472. /** defines the rendering group id to use with the viewer */
  42473. renderingGroupId: number;
  42474. /** Gets or sets the color used to render the skeleton */
  42475. color: Color3;
  42476. private _scene;
  42477. private _debugLines;
  42478. private _debugMesh;
  42479. private _isEnabled;
  42480. private _renderFunction;
  42481. private _utilityLayer;
  42482. /**
  42483. * Returns the mesh used to render the bones
  42484. */
  42485. readonly debugMesh: Nullable<LinesMesh>;
  42486. /**
  42487. * Creates a new SkeletonViewer
  42488. * @param skeleton defines the skeleton to render
  42489. * @param mesh defines the mesh attached to the skeleton
  42490. * @param scene defines the hosting scene
  42491. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42492. * @param renderingGroupId defines the rendering group id to use with the viewer
  42493. */
  42494. constructor(
  42495. /** defines the skeleton to render */
  42496. skeleton: Skeleton,
  42497. /** defines the mesh attached to the skeleton */
  42498. mesh: AbstractMesh, scene: Scene,
  42499. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42500. autoUpdateBonesMatrices?: boolean,
  42501. /** defines the rendering group id to use with the viewer */
  42502. renderingGroupId?: number);
  42503. /** Gets or sets a boolean indicating if the viewer is enabled */
  42504. isEnabled: boolean;
  42505. private _getBonePosition;
  42506. private _getLinesForBonesWithLength;
  42507. private _getLinesForBonesNoLength;
  42508. /** Update the viewer to sync with current skeleton state */
  42509. update(): void;
  42510. /** Release associated resources */
  42511. dispose(): void;
  42512. }
  42513. }
  42514. declare module "babylonjs/Debug/index" {
  42515. export * from "babylonjs/Debug/axesViewer";
  42516. export * from "babylonjs/Debug/boneAxesViewer";
  42517. export * from "babylonjs/Debug/debugLayer";
  42518. export * from "babylonjs/Debug/physicsViewer";
  42519. export * from "babylonjs/Debug/rayHelper";
  42520. export * from "babylonjs/Debug/skeletonViewer";
  42521. }
  42522. declare module "babylonjs/Engines/nullEngine" {
  42523. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42524. import { Scene } from "babylonjs/scene";
  42525. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42526. import { Engine } from "babylonjs/Engines/engine";
  42527. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42529. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42530. import { Effect } from "babylonjs/Materials/effect";
  42531. /**
  42532. * Options to create the null engine
  42533. */
  42534. export class NullEngineOptions {
  42535. /**
  42536. * Render width (Default: 512)
  42537. */
  42538. renderWidth: number;
  42539. /**
  42540. * Render height (Default: 256)
  42541. */
  42542. renderHeight: number;
  42543. /**
  42544. * Texture size (Default: 512)
  42545. */
  42546. textureSize: number;
  42547. /**
  42548. * If delta time between frames should be constant
  42549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42550. */
  42551. deterministicLockstep: boolean;
  42552. /**
  42553. * Maximum about of steps between frames (Default: 4)
  42554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42555. */
  42556. lockstepMaxSteps: number;
  42557. }
  42558. /**
  42559. * The null engine class provides support for headless version of babylon.js.
  42560. * This can be used in server side scenario or for testing purposes
  42561. */
  42562. export class NullEngine extends Engine {
  42563. private _options;
  42564. /**
  42565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42566. */
  42567. isDeterministicLockStep(): boolean;
  42568. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42569. getLockstepMaxSteps(): number;
  42570. /**
  42571. * Sets hardware scaling, used to save performance if needed
  42572. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42573. */
  42574. getHardwareScalingLevel(): number;
  42575. constructor(options?: NullEngineOptions);
  42576. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42577. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42578. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42579. getRenderWidth(useScreen?: boolean): number;
  42580. getRenderHeight(useScreen?: boolean): number;
  42581. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42582. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42583. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42584. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42585. bindSamplers(effect: Effect): void;
  42586. enableEffect(effect: Effect): void;
  42587. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42588. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42589. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42590. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42591. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42592. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42593. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42594. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42595. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42596. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42597. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42598. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42599. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42600. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42601. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42602. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42603. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42604. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42605. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42606. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42607. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42608. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42609. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42610. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42611. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42612. bindBuffers(vertexBuffers: {
  42613. [key: string]: VertexBuffer;
  42614. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42615. wipeCaches(bruteForce?: boolean): void;
  42616. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42617. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42618. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42619. /** @hidden */
  42620. _createTexture(): WebGLTexture;
  42621. /** @hidden */
  42622. _releaseTexture(texture: InternalTexture): void;
  42623. 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;
  42624. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42625. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42626. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42627. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42628. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42629. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42630. areAllEffectsReady(): boolean;
  42631. /**
  42632. * @hidden
  42633. * Get the current error code of the webGL context
  42634. * @returns the error code
  42635. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42636. */
  42637. getError(): number;
  42638. /** @hidden */
  42639. _getUnpackAlignement(): number;
  42640. /** @hidden */
  42641. _unpackFlipY(value: boolean): void;
  42642. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42643. /**
  42644. * Updates a dynamic vertex buffer.
  42645. * @param vertexBuffer the vertex buffer to update
  42646. * @param data the data used to update the vertex buffer
  42647. * @param byteOffset the byte offset of the data (optional)
  42648. * @param byteLength the byte length of the data (optional)
  42649. */
  42650. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42651. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42652. /** @hidden */
  42653. _bindTexture(channel: number, texture: InternalTexture): void;
  42654. /** @hidden */
  42655. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42656. releaseEffects(): void;
  42657. displayLoadingUI(): void;
  42658. hideLoadingUI(): void;
  42659. /** @hidden */
  42660. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42661. /** @hidden */
  42662. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42663. /** @hidden */
  42664. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42665. /** @hidden */
  42666. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42667. }
  42668. }
  42669. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42670. import { Nullable, int } from "babylonjs/types";
  42671. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42672. /** @hidden */
  42673. export class _OcclusionDataStorage {
  42674. /** @hidden */
  42675. occlusionInternalRetryCounter: number;
  42676. /** @hidden */
  42677. isOcclusionQueryInProgress: boolean;
  42678. /** @hidden */
  42679. isOccluded: boolean;
  42680. /** @hidden */
  42681. occlusionRetryCount: number;
  42682. /** @hidden */
  42683. occlusionType: number;
  42684. /** @hidden */
  42685. occlusionQueryAlgorithmType: number;
  42686. }
  42687. module "babylonjs/Engines/engine" {
  42688. interface Engine {
  42689. /**
  42690. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42691. * @return the new query
  42692. */
  42693. createQuery(): WebGLQuery;
  42694. /**
  42695. * Delete and release a webGL query
  42696. * @param query defines the query to delete
  42697. * @return the current engine
  42698. */
  42699. deleteQuery(query: WebGLQuery): Engine;
  42700. /**
  42701. * Check if a given query has resolved and got its value
  42702. * @param query defines the query to check
  42703. * @returns true if the query got its value
  42704. */
  42705. isQueryResultAvailable(query: WebGLQuery): boolean;
  42706. /**
  42707. * Gets the value of a given query
  42708. * @param query defines the query to check
  42709. * @returns the value of the query
  42710. */
  42711. getQueryResult(query: WebGLQuery): number;
  42712. /**
  42713. * Initiates an occlusion query
  42714. * @param algorithmType defines the algorithm to use
  42715. * @param query defines the query to use
  42716. * @returns the current engine
  42717. * @see http://doc.babylonjs.com/features/occlusionquery
  42718. */
  42719. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42720. /**
  42721. * Ends an occlusion query
  42722. * @see http://doc.babylonjs.com/features/occlusionquery
  42723. * @param algorithmType defines the algorithm to use
  42724. * @returns the current engine
  42725. */
  42726. endOcclusionQuery(algorithmType: number): Engine;
  42727. /**
  42728. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42729. * Please note that only one query can be issued at a time
  42730. * @returns a time token used to track the time span
  42731. */
  42732. startTimeQuery(): Nullable<_TimeToken>;
  42733. /**
  42734. * Ends a time query
  42735. * @param token defines the token used to measure the time span
  42736. * @returns the time spent (in ns)
  42737. */
  42738. endTimeQuery(token: _TimeToken): int;
  42739. /** @hidden */
  42740. _currentNonTimestampToken: Nullable<_TimeToken>;
  42741. /** @hidden */
  42742. _createTimeQuery(): WebGLQuery;
  42743. /** @hidden */
  42744. _deleteTimeQuery(query: WebGLQuery): void;
  42745. /** @hidden */
  42746. _getGlAlgorithmType(algorithmType: number): number;
  42747. /** @hidden */
  42748. _getTimeQueryResult(query: WebGLQuery): any;
  42749. /** @hidden */
  42750. _getTimeQueryAvailability(query: WebGLQuery): any;
  42751. }
  42752. }
  42753. module "babylonjs/Meshes/abstractMesh" {
  42754. interface AbstractMesh {
  42755. /**
  42756. * Backing filed
  42757. * @hidden
  42758. */
  42759. __occlusionDataStorage: _OcclusionDataStorage;
  42760. /**
  42761. * Access property
  42762. * @hidden
  42763. */
  42764. _occlusionDataStorage: _OcclusionDataStorage;
  42765. /**
  42766. * 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.
  42767. * The default value is -1 which means don't break the query and wait till the result
  42768. * @see http://doc.babylonjs.com/features/occlusionquery
  42769. */
  42770. occlusionRetryCount: number;
  42771. /**
  42772. * 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:
  42773. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42774. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42775. * * 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.
  42776. * @see http://doc.babylonjs.com/features/occlusionquery
  42777. */
  42778. occlusionType: number;
  42779. /**
  42780. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42781. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42782. * * 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.
  42783. * @see http://doc.babylonjs.com/features/occlusionquery
  42784. */
  42785. occlusionQueryAlgorithmType: number;
  42786. /**
  42787. * 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
  42788. * @see http://doc.babylonjs.com/features/occlusionquery
  42789. */
  42790. isOccluded: boolean;
  42791. /**
  42792. * Flag to check the progress status of the query
  42793. * @see http://doc.babylonjs.com/features/occlusionquery
  42794. */
  42795. isOcclusionQueryInProgress: boolean;
  42796. }
  42797. }
  42798. }
  42799. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42800. import { Nullable } from "babylonjs/types";
  42801. /** @hidden */
  42802. export var _forceTransformFeedbackToBundle: boolean;
  42803. module "babylonjs/Engines/engine" {
  42804. interface Engine {
  42805. /**
  42806. * Creates a webGL transform feedback object
  42807. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42808. * @returns the webGL transform feedback object
  42809. */
  42810. createTransformFeedback(): WebGLTransformFeedback;
  42811. /**
  42812. * Delete a webGL transform feedback object
  42813. * @param value defines the webGL transform feedback object to delete
  42814. */
  42815. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42816. /**
  42817. * Bind a webGL transform feedback object to the webgl context
  42818. * @param value defines the webGL transform feedback object to bind
  42819. */
  42820. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42821. /**
  42822. * Begins a transform feedback operation
  42823. * @param usePoints defines if points or triangles must be used
  42824. */
  42825. beginTransformFeedback(usePoints: boolean): void;
  42826. /**
  42827. * Ends a transform feedback operation
  42828. */
  42829. endTransformFeedback(): void;
  42830. /**
  42831. * Specify the varyings to use with transform feedback
  42832. * @param program defines the associated webGL program
  42833. * @param value defines the list of strings representing the varying names
  42834. */
  42835. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42836. /**
  42837. * Bind a webGL buffer for a transform feedback operation
  42838. * @param value defines the webGL buffer to bind
  42839. */
  42840. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42841. }
  42842. }
  42843. }
  42844. declare module "babylonjs/Engines/Extensions/index" {
  42845. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42846. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42847. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42848. }
  42849. declare module "babylonjs/Engines/index" {
  42850. export * from "babylonjs/Engines/constants";
  42851. export * from "babylonjs/Engines/engine";
  42852. export * from "babylonjs/Engines/engineStore";
  42853. export * from "babylonjs/Engines/nullEngine";
  42854. export * from "babylonjs/Engines/Extensions/index";
  42855. }
  42856. declare module "babylonjs/Events/clipboardEvents" {
  42857. /**
  42858. * Gather the list of clipboard event types as constants.
  42859. */
  42860. export class ClipboardEventTypes {
  42861. /**
  42862. * The clipboard event is fired when a copy command is active (pressed).
  42863. */
  42864. static readonly COPY: number;
  42865. /**
  42866. * The clipboard event is fired when a cut command is active (pressed).
  42867. */
  42868. static readonly CUT: number;
  42869. /**
  42870. * The clipboard event is fired when a paste command is active (pressed).
  42871. */
  42872. static readonly PASTE: number;
  42873. }
  42874. /**
  42875. * This class is used to store clipboard related info for the onClipboardObservable event.
  42876. */
  42877. export class ClipboardInfo {
  42878. /**
  42879. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42880. */
  42881. type: number;
  42882. /**
  42883. * Defines the related dom event
  42884. */
  42885. event: ClipboardEvent;
  42886. /**
  42887. *Creates an instance of ClipboardInfo.
  42888. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42889. * @param event Defines the related dom event
  42890. */
  42891. constructor(
  42892. /**
  42893. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42894. */
  42895. type: number,
  42896. /**
  42897. * Defines the related dom event
  42898. */
  42899. event: ClipboardEvent);
  42900. /**
  42901. * Get the clipboard event's type from the keycode.
  42902. * @param keyCode Defines the keyCode for the current keyboard event.
  42903. * @return {number}
  42904. */
  42905. static GetTypeFromCharacter(keyCode: number): number;
  42906. }
  42907. }
  42908. declare module "babylonjs/Events/index" {
  42909. export * from "babylonjs/Events/keyboardEvents";
  42910. export * from "babylonjs/Events/pointerEvents";
  42911. export * from "babylonjs/Events/clipboardEvents";
  42912. }
  42913. declare module "babylonjs/Loading/sceneLoader" {
  42914. import { Observable } from "babylonjs/Misc/observable";
  42915. import { Nullable } from "babylonjs/types";
  42916. import { Scene } from "babylonjs/scene";
  42917. import { Engine } from "babylonjs/Engines/engine";
  42918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42919. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42920. import { AssetContainer } from "babylonjs/assetContainer";
  42921. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42922. import { Skeleton } from "babylonjs/Bones/skeleton";
  42923. /**
  42924. * Class used to represent data loading progression
  42925. */
  42926. export class SceneLoaderProgressEvent {
  42927. /** defines if data length to load can be evaluated */
  42928. readonly lengthComputable: boolean;
  42929. /** defines the loaded data length */
  42930. readonly loaded: number;
  42931. /** defines the data length to load */
  42932. readonly total: number;
  42933. /**
  42934. * Create a new progress event
  42935. * @param lengthComputable defines if data length to load can be evaluated
  42936. * @param loaded defines the loaded data length
  42937. * @param total defines the data length to load
  42938. */
  42939. constructor(
  42940. /** defines if data length to load can be evaluated */
  42941. lengthComputable: boolean,
  42942. /** defines the loaded data length */
  42943. loaded: number,
  42944. /** defines the data length to load */
  42945. total: number);
  42946. /**
  42947. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42948. * @param event defines the source event
  42949. * @returns a new SceneLoaderProgressEvent
  42950. */
  42951. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42952. }
  42953. /**
  42954. * Interface used by SceneLoader plugins to define supported file extensions
  42955. */
  42956. export interface ISceneLoaderPluginExtensions {
  42957. /**
  42958. * Defines the list of supported extensions
  42959. */
  42960. [extension: string]: {
  42961. isBinary: boolean;
  42962. };
  42963. }
  42964. /**
  42965. * Interface used by SceneLoader plugin factory
  42966. */
  42967. export interface ISceneLoaderPluginFactory {
  42968. /**
  42969. * Defines the name of the factory
  42970. */
  42971. name: string;
  42972. /**
  42973. * Function called to create a new plugin
  42974. * @return the new plugin
  42975. */
  42976. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42977. /**
  42978. * Boolean indicating if the plugin can direct load specific data
  42979. */
  42980. canDirectLoad?: (data: string) => boolean;
  42981. }
  42982. /**
  42983. * Interface used to define a SceneLoader plugin
  42984. */
  42985. export interface ISceneLoaderPlugin {
  42986. /**
  42987. * The friendly name of this plugin.
  42988. */
  42989. name: string;
  42990. /**
  42991. * The file extensions supported by this plugin.
  42992. */
  42993. extensions: string | ISceneLoaderPluginExtensions;
  42994. /**
  42995. * Import meshes into a scene.
  42996. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42997. * @param scene The scene to import into
  42998. * @param data The data to import
  42999. * @param rootUrl The root url for scene and resources
  43000. * @param meshes The meshes array to import into
  43001. * @param particleSystems The particle systems array to import into
  43002. * @param skeletons The skeletons array to import into
  43003. * @param onError The callback when import fails
  43004. * @returns True if successful or false otherwise
  43005. */
  43006. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43007. /**
  43008. * Load into a scene.
  43009. * @param scene The scene to load into
  43010. * @param data The data to import
  43011. * @param rootUrl The root url for scene and resources
  43012. * @param onError The callback when import fails
  43013. * @returns true if successful or false otherwise
  43014. */
  43015. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43016. /**
  43017. * The callback that returns true if the data can be directly loaded.
  43018. */
  43019. canDirectLoad?: (data: string) => boolean;
  43020. /**
  43021. * The callback that allows custom handling of the root url based on the response url.
  43022. */
  43023. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43024. /**
  43025. * Load into an asset container.
  43026. * @param scene The scene to load into
  43027. * @param data The data to import
  43028. * @param rootUrl The root url for scene and resources
  43029. * @param onError The callback when import fails
  43030. * @returns The loaded asset container
  43031. */
  43032. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43033. }
  43034. /**
  43035. * Interface used to define an async SceneLoader plugin
  43036. */
  43037. export interface ISceneLoaderPluginAsync {
  43038. /**
  43039. * The friendly name of this plugin.
  43040. */
  43041. name: string;
  43042. /**
  43043. * The file extensions supported by this plugin.
  43044. */
  43045. extensions: string | ISceneLoaderPluginExtensions;
  43046. /**
  43047. * Import meshes into a scene.
  43048. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43049. * @param scene The scene to import into
  43050. * @param data The data to import
  43051. * @param rootUrl The root url for scene and resources
  43052. * @param onProgress The callback when the load progresses
  43053. * @param fileName Defines the name of the file to load
  43054. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43055. */
  43056. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43057. meshes: AbstractMesh[];
  43058. particleSystems: IParticleSystem[];
  43059. skeletons: Skeleton[];
  43060. animationGroups: AnimationGroup[];
  43061. }>;
  43062. /**
  43063. * Load into a scene.
  43064. * @param scene The scene to load into
  43065. * @param data The data to import
  43066. * @param rootUrl The root url for scene and resources
  43067. * @param onProgress The callback when the load progresses
  43068. * @param fileName Defines the name of the file to load
  43069. * @returns Nothing
  43070. */
  43071. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43072. /**
  43073. * The callback that returns true if the data can be directly loaded.
  43074. */
  43075. canDirectLoad?: (data: string) => boolean;
  43076. /**
  43077. * The callback that allows custom handling of the root url based on the response url.
  43078. */
  43079. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43080. /**
  43081. * Load into an asset container.
  43082. * @param scene The scene to load into
  43083. * @param data The data to import
  43084. * @param rootUrl The root url for scene and resources
  43085. * @param onProgress The callback when the load progresses
  43086. * @param fileName Defines the name of the file to load
  43087. * @returns The loaded asset container
  43088. */
  43089. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43090. }
  43091. /**
  43092. * Class used to load scene from various file formats using registered plugins
  43093. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43094. */
  43095. export class SceneLoader {
  43096. /**
  43097. * No logging while loading
  43098. */
  43099. static readonly NO_LOGGING: number;
  43100. /**
  43101. * Minimal logging while loading
  43102. */
  43103. static readonly MINIMAL_LOGGING: number;
  43104. /**
  43105. * Summary logging while loading
  43106. */
  43107. static readonly SUMMARY_LOGGING: number;
  43108. /**
  43109. * Detailled logging while loading
  43110. */
  43111. static readonly DETAILED_LOGGING: number;
  43112. /**
  43113. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43114. */
  43115. static ForceFullSceneLoadingForIncremental: boolean;
  43116. /**
  43117. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43118. */
  43119. static ShowLoadingScreen: boolean;
  43120. /**
  43121. * Defines the current logging level (while loading the scene)
  43122. * @ignorenaming
  43123. */
  43124. static loggingLevel: number;
  43125. /**
  43126. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43127. */
  43128. static CleanBoneMatrixWeights: boolean;
  43129. /**
  43130. * Event raised when a plugin is used to load a scene
  43131. */
  43132. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43133. private static _registeredPlugins;
  43134. private static _getDefaultPlugin;
  43135. private static _getPluginForExtension;
  43136. private static _getPluginForDirectLoad;
  43137. private static _getPluginForFilename;
  43138. private static _getDirectLoad;
  43139. private static _loadData;
  43140. private static _getFileInfo;
  43141. /**
  43142. * Gets a plugin that can load the given extension
  43143. * @param extension defines the extension to load
  43144. * @returns a plugin or null if none works
  43145. */
  43146. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43147. /**
  43148. * Gets a boolean indicating that the given extension can be loaded
  43149. * @param extension defines the extension to load
  43150. * @returns true if the extension is supported
  43151. */
  43152. static IsPluginForExtensionAvailable(extension: string): boolean;
  43153. /**
  43154. * Adds a new plugin to the list of registered plugins
  43155. * @param plugin defines the plugin to add
  43156. */
  43157. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43158. /**
  43159. * Import meshes into a scene
  43160. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43161. * @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)
  43162. * @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)
  43163. * @param scene the instance of BABYLON.Scene to append to
  43164. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43165. * @param onProgress a callback with a progress event for each file being loaded
  43166. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43167. * @param pluginExtension the extension used to determine the plugin
  43168. * @returns The loaded plugin
  43169. */
  43170. 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>;
  43171. /**
  43172. * Import meshes into a scene
  43173. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43174. * @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)
  43175. * @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)
  43176. * @param scene the instance of BABYLON.Scene to append to
  43177. * @param onProgress a callback with a progress event for each file being loaded
  43178. * @param pluginExtension the extension used to determine the plugin
  43179. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43180. */
  43181. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43182. meshes: AbstractMesh[];
  43183. particleSystems: IParticleSystem[];
  43184. skeletons: Skeleton[];
  43185. animationGroups: AnimationGroup[];
  43186. }>;
  43187. /**
  43188. * Load a scene
  43189. * @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)
  43190. * @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)
  43191. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43192. * @param onSuccess a callback with the scene when import succeeds
  43193. * @param onProgress a callback with a progress event for each file being loaded
  43194. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43195. * @param pluginExtension the extension used to determine the plugin
  43196. * @returns The loaded plugin
  43197. */
  43198. 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>;
  43199. /**
  43200. * Load a scene
  43201. * @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)
  43202. * @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)
  43203. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43204. * @param onProgress a callback with a progress event for each file being loaded
  43205. * @param pluginExtension the extension used to determine the plugin
  43206. * @returns The loaded scene
  43207. */
  43208. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43209. /**
  43210. * Append a scene
  43211. * @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)
  43212. * @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)
  43213. * @param scene is the instance of BABYLON.Scene to append to
  43214. * @param onSuccess a callback with the scene when import succeeds
  43215. * @param onProgress a callback with a progress event for each file being loaded
  43216. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43217. * @param pluginExtension the extension used to determine the plugin
  43218. * @returns The loaded plugin
  43219. */
  43220. 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>;
  43221. /**
  43222. * Append a scene
  43223. * @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)
  43224. * @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)
  43225. * @param scene is the instance of BABYLON.Scene to append to
  43226. * @param onProgress a callback with a progress event for each file being loaded
  43227. * @param pluginExtension the extension used to determine the plugin
  43228. * @returns The given scene
  43229. */
  43230. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43231. /**
  43232. * Load a scene into an asset container
  43233. * @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)
  43234. * @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)
  43235. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43236. * @param onSuccess a callback with the scene when import succeeds
  43237. * @param onProgress a callback with a progress event for each file being loaded
  43238. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43239. * @param pluginExtension the extension used to determine the plugin
  43240. * @returns The loaded plugin
  43241. */
  43242. 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>;
  43243. /**
  43244. * Load a scene into an asset container
  43245. * @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)
  43246. * @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)
  43247. * @param scene is the instance of Scene to append to
  43248. * @param onProgress a callback with a progress event for each file being loaded
  43249. * @param pluginExtension the extension used to determine the plugin
  43250. * @returns The loaded asset container
  43251. */
  43252. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43253. }
  43254. }
  43255. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43256. import { Scene } from "babylonjs/scene";
  43257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43258. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43259. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43260. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43261. /**
  43262. * Google Daydream controller
  43263. */
  43264. export class DaydreamController extends WebVRController {
  43265. /**
  43266. * Base Url for the controller model.
  43267. */
  43268. static MODEL_BASE_URL: string;
  43269. /**
  43270. * File name for the controller model.
  43271. */
  43272. static MODEL_FILENAME: string;
  43273. /**
  43274. * Gamepad Id prefix used to identify Daydream Controller.
  43275. */
  43276. static readonly GAMEPAD_ID_PREFIX: string;
  43277. /**
  43278. * Creates a new DaydreamController from a gamepad
  43279. * @param vrGamepad the gamepad that the controller should be created from
  43280. */
  43281. constructor(vrGamepad: any);
  43282. /**
  43283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43284. * @param scene scene in which to add meshes
  43285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43286. */
  43287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43288. /**
  43289. * Called once for each button that changed state since the last frame
  43290. * @param buttonIdx Which button index changed
  43291. * @param state New state of the button
  43292. * @param changes Which properties on the state changed since last frame
  43293. */
  43294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43298. import { Scene } from "babylonjs/scene";
  43299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43300. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43302. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43303. /**
  43304. * Gear VR Controller
  43305. */
  43306. export class GearVRController extends WebVRController {
  43307. /**
  43308. * Base Url for the controller model.
  43309. */
  43310. static MODEL_BASE_URL: string;
  43311. /**
  43312. * File name for the controller model.
  43313. */
  43314. static MODEL_FILENAME: string;
  43315. /**
  43316. * Gamepad Id prefix used to identify this controller.
  43317. */
  43318. static readonly GAMEPAD_ID_PREFIX: string;
  43319. private readonly _buttonIndexToObservableNameMap;
  43320. /**
  43321. * Creates a new GearVRController from a gamepad
  43322. * @param vrGamepad the gamepad that the controller should be created from
  43323. */
  43324. constructor(vrGamepad: any);
  43325. /**
  43326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43327. * @param scene scene in which to add meshes
  43328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43329. */
  43330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43331. /**
  43332. * Called once for each button that changed state since the last frame
  43333. * @param buttonIdx Which button index changed
  43334. * @param state New state of the button
  43335. * @param changes Which properties on the state changed since last frame
  43336. */
  43337. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43338. }
  43339. }
  43340. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43341. import { Scene } from "babylonjs/scene";
  43342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43343. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43344. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43345. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43346. /**
  43347. * Generic Controller
  43348. */
  43349. export class GenericController extends WebVRController {
  43350. /**
  43351. * Base Url for the controller model.
  43352. */
  43353. static readonly MODEL_BASE_URL: string;
  43354. /**
  43355. * File name for the controller model.
  43356. */
  43357. static readonly MODEL_FILENAME: string;
  43358. /**
  43359. * Creates a new GenericController from a gamepad
  43360. * @param vrGamepad the gamepad that the controller should be created from
  43361. */
  43362. constructor(vrGamepad: any);
  43363. /**
  43364. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43365. * @param scene scene in which to add meshes
  43366. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43367. */
  43368. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43369. /**
  43370. * Called once for each button that changed state since the last frame
  43371. * @param buttonIdx Which button index changed
  43372. * @param state New state of the button
  43373. * @param changes Which properties on the state changed since last frame
  43374. */
  43375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43376. }
  43377. }
  43378. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43379. import { Observable } from "babylonjs/Misc/observable";
  43380. import { Scene } from "babylonjs/scene";
  43381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43382. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43383. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43384. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43385. /**
  43386. * Oculus Touch Controller
  43387. */
  43388. export class OculusTouchController extends WebVRController {
  43389. /**
  43390. * Base Url for the controller model.
  43391. */
  43392. static MODEL_BASE_URL: string;
  43393. /**
  43394. * File name for the left controller model.
  43395. */
  43396. static MODEL_LEFT_FILENAME: string;
  43397. /**
  43398. * File name for the right controller model.
  43399. */
  43400. static MODEL_RIGHT_FILENAME: string;
  43401. /**
  43402. * Fired when the secondary trigger on this controller is modified
  43403. */
  43404. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43405. /**
  43406. * Fired when the thumb rest on this controller is modified
  43407. */
  43408. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Creates a new OculusTouchController from a gamepad
  43411. * @param vrGamepad the gamepad that the controller should be created from
  43412. */
  43413. constructor(vrGamepad: any);
  43414. /**
  43415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43416. * @param scene scene in which to add meshes
  43417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43418. */
  43419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43420. /**
  43421. * Fired when the A button on this controller is modified
  43422. */
  43423. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43424. /**
  43425. * Fired when the B button on this controller is modified
  43426. */
  43427. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43428. /**
  43429. * Fired when the X button on this controller is modified
  43430. */
  43431. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43432. /**
  43433. * Fired when the Y button on this controller is modified
  43434. */
  43435. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43436. /**
  43437. * Called once for each button that changed state since the last frame
  43438. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43439. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43440. * 2) secondary trigger (same)
  43441. * 3) A (right) X (left), touch, pressed = value
  43442. * 4) B / Y
  43443. * 5) thumb rest
  43444. * @param buttonIdx Which button index changed
  43445. * @param state New state of the button
  43446. * @param changes Which properties on the state changed since last frame
  43447. */
  43448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43449. }
  43450. }
  43451. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43452. import { Scene } from "babylonjs/scene";
  43453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43454. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43455. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43456. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43457. import { Observable } from "babylonjs/Misc/observable";
  43458. /**
  43459. * Vive Controller
  43460. */
  43461. export class ViveController extends WebVRController {
  43462. /**
  43463. * Base Url for the controller model.
  43464. */
  43465. static MODEL_BASE_URL: string;
  43466. /**
  43467. * File name for the controller model.
  43468. */
  43469. static MODEL_FILENAME: string;
  43470. /**
  43471. * Creates a new ViveController from a gamepad
  43472. * @param vrGamepad the gamepad that the controller should be created from
  43473. */
  43474. constructor(vrGamepad: any);
  43475. /**
  43476. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43477. * @param scene scene in which to add meshes
  43478. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43479. */
  43480. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43481. /**
  43482. * Fired when the left button on this controller is modified
  43483. */
  43484. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43485. /**
  43486. * Fired when the right button on this controller is modified
  43487. */
  43488. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43489. /**
  43490. * Fired when the menu button on this controller is modified
  43491. */
  43492. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43493. /**
  43494. * Called once for each button that changed state since the last frame
  43495. * Vive mapping:
  43496. * 0: touchpad
  43497. * 1: trigger
  43498. * 2: left AND right buttons
  43499. * 3: menu button
  43500. * @param buttonIdx Which button index changed
  43501. * @param state New state of the button
  43502. * @param changes Which properties on the state changed since last frame
  43503. */
  43504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43505. }
  43506. }
  43507. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43508. import { Observable } from "babylonjs/Misc/observable";
  43509. import { Scene } from "babylonjs/scene";
  43510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43511. import { Ray } from "babylonjs/Culling/ray";
  43512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43513. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43514. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43515. /**
  43516. * Defines the WindowsMotionController object that the state of the windows motion controller
  43517. */
  43518. export class WindowsMotionController extends WebVRController {
  43519. /**
  43520. * The base url used to load the left and right controller models
  43521. */
  43522. static MODEL_BASE_URL: string;
  43523. /**
  43524. * The name of the left controller model file
  43525. */
  43526. static MODEL_LEFT_FILENAME: string;
  43527. /**
  43528. * The name of the right controller model file
  43529. */
  43530. static MODEL_RIGHT_FILENAME: string;
  43531. /**
  43532. * The controller name prefix for this controller type
  43533. */
  43534. static readonly GAMEPAD_ID_PREFIX: string;
  43535. /**
  43536. * The controller id pattern for this controller type
  43537. */
  43538. private static readonly GAMEPAD_ID_PATTERN;
  43539. private _loadedMeshInfo;
  43540. private readonly _mapping;
  43541. /**
  43542. * Fired when the trackpad on this controller is clicked
  43543. */
  43544. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43545. /**
  43546. * Fired when the trackpad on this controller is modified
  43547. */
  43548. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43549. /**
  43550. * The current x and y values of this controller's trackpad
  43551. */
  43552. trackpad: StickValues;
  43553. /**
  43554. * Creates a new WindowsMotionController from a gamepad
  43555. * @param vrGamepad the gamepad that the controller should be created from
  43556. */
  43557. constructor(vrGamepad: any);
  43558. /**
  43559. * Fired when the trigger on this controller is modified
  43560. */
  43561. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43562. /**
  43563. * Fired when the menu button on this controller is modified
  43564. */
  43565. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43566. /**
  43567. * Fired when the grip button on this controller is modified
  43568. */
  43569. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43570. /**
  43571. * Fired when the thumbstick button on this controller is modified
  43572. */
  43573. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43574. /**
  43575. * Fired when the touchpad button on this controller is modified
  43576. */
  43577. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43578. /**
  43579. * Fired when the touchpad values on this controller are modified
  43580. */
  43581. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43582. private _updateTrackpad;
  43583. /**
  43584. * Called once per frame by the engine.
  43585. */
  43586. update(): void;
  43587. /**
  43588. * Called once for each button that changed state since the last frame
  43589. * @param buttonIdx Which button index changed
  43590. * @param state New state of the button
  43591. * @param changes Which properties on the state changed since last frame
  43592. */
  43593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43594. /**
  43595. * Moves the buttons on the controller mesh based on their current state
  43596. * @param buttonName the name of the button to move
  43597. * @param buttonValue the value of the button which determines the buttons new position
  43598. */
  43599. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43600. /**
  43601. * Moves the axis on the controller mesh based on its current state
  43602. * @param axis the index of the axis
  43603. * @param axisValue the value of the axis which determines the meshes new position
  43604. * @hidden
  43605. */
  43606. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43607. /**
  43608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43609. * @param scene scene in which to add meshes
  43610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43611. */
  43612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43613. /**
  43614. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43615. * can be transformed by button presses and axes values, based on this._mapping.
  43616. *
  43617. * @param scene scene in which the meshes exist
  43618. * @param meshes list of meshes that make up the controller model to process
  43619. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43620. */
  43621. private processModel;
  43622. private createMeshInfo;
  43623. /**
  43624. * Gets the ray of the controller in the direction the controller is pointing
  43625. * @param length the length the resulting ray should be
  43626. * @returns a ray in the direction the controller is pointing
  43627. */
  43628. getForwardRay(length?: number): Ray;
  43629. /**
  43630. * Disposes of the controller
  43631. */
  43632. dispose(): void;
  43633. }
  43634. }
  43635. declare module "babylonjs/Gamepads/Controllers/index" {
  43636. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43637. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43638. export * from "babylonjs/Gamepads/Controllers/genericController";
  43639. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43640. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43641. export * from "babylonjs/Gamepads/Controllers/viveController";
  43642. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43643. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43644. }
  43645. declare module "babylonjs/Gamepads/index" {
  43646. export * from "babylonjs/Gamepads/Controllers/index";
  43647. export * from "babylonjs/Gamepads/gamepad";
  43648. export * from "babylonjs/Gamepads/gamepadManager";
  43649. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43650. export * from "babylonjs/Gamepads/xboxGamepad";
  43651. }
  43652. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43653. import { Observable } from "babylonjs/Misc/observable";
  43654. import { Nullable } from "babylonjs/types";
  43655. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43657. import { Mesh } from "babylonjs/Meshes/mesh";
  43658. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43659. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43660. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43661. /**
  43662. * Single axis scale gizmo
  43663. */
  43664. export class AxisScaleGizmo extends Gizmo {
  43665. private _coloredMaterial;
  43666. /**
  43667. * Drag behavior responsible for the gizmos dragging interactions
  43668. */
  43669. dragBehavior: PointerDragBehavior;
  43670. private _pointerObserver;
  43671. /**
  43672. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43673. */
  43674. snapDistance: number;
  43675. /**
  43676. * Event that fires each time the gizmo snaps to a new location.
  43677. * * snapDistance is the the change in distance
  43678. */
  43679. onSnapObservable: Observable<{
  43680. snapDistance: number;
  43681. }>;
  43682. /**
  43683. * If the scaling operation should be done on all axis (default: false)
  43684. */
  43685. uniformScaling: boolean;
  43686. /**
  43687. * Creates an AxisScaleGizmo
  43688. * @param gizmoLayer The utility layer the gizmo will be added to
  43689. * @param dragAxis The axis which the gizmo will be able to scale on
  43690. * @param color The color of the gizmo
  43691. */
  43692. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43694. /**
  43695. * Disposes of the gizmo
  43696. */
  43697. dispose(): void;
  43698. /**
  43699. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43700. * @param mesh The mesh to replace the default mesh of the gizmo
  43701. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43702. */
  43703. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43704. }
  43705. }
  43706. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43707. import { Observable } from "babylonjs/Misc/observable";
  43708. import { Nullable } from "babylonjs/types";
  43709. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43711. import { Mesh } from "babylonjs/Meshes/mesh";
  43712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43713. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43714. import "babylonjs/Meshes/Builders/boxBuilder";
  43715. /**
  43716. * Bounding box gizmo
  43717. */
  43718. export class BoundingBoxGizmo extends Gizmo {
  43719. private _lineBoundingBox;
  43720. private _rotateSpheresParent;
  43721. private _scaleBoxesParent;
  43722. private _boundingDimensions;
  43723. private _renderObserver;
  43724. private _pointerObserver;
  43725. private _scaleDragSpeed;
  43726. private _tmpQuaternion;
  43727. private _tmpVector;
  43728. private _tmpRotationMatrix;
  43729. /**
  43730. * 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)
  43731. */
  43732. ignoreChildren: boolean;
  43733. /**
  43734. * 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)
  43735. */
  43736. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43737. /**
  43738. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43739. */
  43740. rotationSphereSize: number;
  43741. /**
  43742. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43743. */
  43744. scaleBoxSize: number;
  43745. /**
  43746. * 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)
  43747. */
  43748. fixedDragMeshScreenSize: boolean;
  43749. /**
  43750. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43751. */
  43752. fixedDragMeshScreenSizeDistanceFactor: number;
  43753. /**
  43754. * Fired when a rotation sphere or scale box is dragged
  43755. */
  43756. onDragStartObservable: Observable<{}>;
  43757. /**
  43758. * Fired when a scale box is dragged
  43759. */
  43760. onScaleBoxDragObservable: Observable<{}>;
  43761. /**
  43762. * Fired when a scale box drag is ended
  43763. */
  43764. onScaleBoxDragEndObservable: Observable<{}>;
  43765. /**
  43766. * Fired when a rotation sphere is dragged
  43767. */
  43768. onRotationSphereDragObservable: Observable<{}>;
  43769. /**
  43770. * Fired when a rotation sphere drag is ended
  43771. */
  43772. onRotationSphereDragEndObservable: Observable<{}>;
  43773. /**
  43774. * 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)
  43775. */
  43776. scalePivot: Nullable<Vector3>;
  43777. private _anchorMesh;
  43778. private _existingMeshScale;
  43779. private _dragMesh;
  43780. private pointerDragBehavior;
  43781. private coloredMaterial;
  43782. private hoverColoredMaterial;
  43783. /**
  43784. * Sets the color of the bounding box gizmo
  43785. * @param color the color to set
  43786. */
  43787. setColor(color: Color3): void;
  43788. /**
  43789. * Creates an BoundingBoxGizmo
  43790. * @param gizmoLayer The utility layer the gizmo will be added to
  43791. * @param color The color of the gizmo
  43792. */
  43793. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43794. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43795. private _selectNode;
  43796. /**
  43797. * Updates the bounding box information for the Gizmo
  43798. */
  43799. updateBoundingBox(): void;
  43800. private _updateRotationSpheres;
  43801. private _updateScaleBoxes;
  43802. /**
  43803. * Enables rotation on the specified axis and disables rotation on the others
  43804. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43805. */
  43806. setEnabledRotationAxis(axis: string): void;
  43807. /**
  43808. * Enables/disables scaling
  43809. * @param enable if scaling should be enabled
  43810. */
  43811. setEnabledScaling(enable: boolean): void;
  43812. private _updateDummy;
  43813. /**
  43814. * Enables a pointer drag behavior on the bounding box of the gizmo
  43815. */
  43816. enableDragBehavior(): void;
  43817. /**
  43818. * Disposes of the gizmo
  43819. */
  43820. dispose(): void;
  43821. /**
  43822. * 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)
  43823. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43824. * @returns the bounding box mesh with the passed in mesh as a child
  43825. */
  43826. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43827. /**
  43828. * CustomMeshes are not supported by this gizmo
  43829. * @param mesh The mesh to replace the default mesh of the gizmo
  43830. */
  43831. setCustomMesh(mesh: Mesh): void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43835. import { Observable } from "babylonjs/Misc/observable";
  43836. import { Nullable } from "babylonjs/types";
  43837. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43839. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43840. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43841. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43842. import "babylonjs/Meshes/Builders/linesBuilder";
  43843. /**
  43844. * Single plane rotation gizmo
  43845. */
  43846. export class PlaneRotationGizmo extends Gizmo {
  43847. /**
  43848. * Drag behavior responsible for the gizmos dragging interactions
  43849. */
  43850. dragBehavior: PointerDragBehavior;
  43851. private _pointerObserver;
  43852. /**
  43853. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43854. */
  43855. snapDistance: number;
  43856. /**
  43857. * Event that fires each time the gizmo snaps to a new location.
  43858. * * snapDistance is the the change in distance
  43859. */
  43860. onSnapObservable: Observable<{
  43861. snapDistance: number;
  43862. }>;
  43863. /**
  43864. * Creates a PlaneRotationGizmo
  43865. * @param gizmoLayer The utility layer the gizmo will be added to
  43866. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43867. * @param color The color of the gizmo
  43868. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43869. */
  43870. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43871. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43872. /**
  43873. * Disposes of the gizmo
  43874. */
  43875. dispose(): void;
  43876. }
  43877. }
  43878. declare module "babylonjs/Gizmos/rotationGizmo" {
  43879. import { Observable } from "babylonjs/Misc/observable";
  43880. import { Nullable } from "babylonjs/types";
  43881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43882. import { Mesh } from "babylonjs/Meshes/mesh";
  43883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43884. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43885. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43886. /**
  43887. * Gizmo that enables rotating a mesh along 3 axis
  43888. */
  43889. export class RotationGizmo extends Gizmo {
  43890. /**
  43891. * Internal gizmo used for interactions on the x axis
  43892. */
  43893. xGizmo: PlaneRotationGizmo;
  43894. /**
  43895. * Internal gizmo used for interactions on the y axis
  43896. */
  43897. yGizmo: PlaneRotationGizmo;
  43898. /**
  43899. * Internal gizmo used for interactions on the z axis
  43900. */
  43901. zGizmo: PlaneRotationGizmo;
  43902. /** Fires an event when any of it's sub gizmos are dragged */
  43903. onDragStartObservable: Observable<{}>;
  43904. /** Fires an event when any of it's sub gizmos are released from dragging */
  43905. onDragEndObservable: Observable<{}>;
  43906. attachedMesh: Nullable<AbstractMesh>;
  43907. /**
  43908. * Creates a RotationGizmo
  43909. * @param gizmoLayer The utility layer the gizmo will be added to
  43910. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43911. */
  43912. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43913. updateGizmoRotationToMatchAttachedMesh: boolean;
  43914. /**
  43915. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43916. */
  43917. snapDistance: number;
  43918. /**
  43919. * Ratio for the scale of the gizmo (Default: 1)
  43920. */
  43921. scaleRatio: number;
  43922. /**
  43923. * Disposes of the gizmo
  43924. */
  43925. dispose(): void;
  43926. /**
  43927. * CustomMeshes are not supported by this gizmo
  43928. * @param mesh The mesh to replace the default mesh of the gizmo
  43929. */
  43930. setCustomMesh(mesh: Mesh): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Gizmos/positionGizmo" {
  43934. import { Observable } from "babylonjs/Misc/observable";
  43935. import { Nullable } from "babylonjs/types";
  43936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43937. import { Mesh } from "babylonjs/Meshes/mesh";
  43938. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43939. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43940. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43941. /**
  43942. * Gizmo that enables dragging a mesh along 3 axis
  43943. */
  43944. export class PositionGizmo extends Gizmo {
  43945. /**
  43946. * Internal gizmo used for interactions on the x axis
  43947. */
  43948. xGizmo: AxisDragGizmo;
  43949. /**
  43950. * Internal gizmo used for interactions on the y axis
  43951. */
  43952. yGizmo: AxisDragGizmo;
  43953. /**
  43954. * Internal gizmo used for interactions on the z axis
  43955. */
  43956. zGizmo: AxisDragGizmo;
  43957. /** Fires an event when any of it's sub gizmos are dragged */
  43958. onDragStartObservable: Observable<{}>;
  43959. /** Fires an event when any of it's sub gizmos are released from dragging */
  43960. onDragEndObservable: Observable<{}>;
  43961. attachedMesh: Nullable<AbstractMesh>;
  43962. /**
  43963. * Creates a PositionGizmo
  43964. * @param gizmoLayer The utility layer the gizmo will be added to
  43965. */
  43966. constructor(gizmoLayer?: UtilityLayerRenderer);
  43967. updateGizmoRotationToMatchAttachedMesh: boolean;
  43968. /**
  43969. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43970. */
  43971. snapDistance: number;
  43972. /**
  43973. * Ratio for the scale of the gizmo (Default: 1)
  43974. */
  43975. scaleRatio: number;
  43976. /**
  43977. * Disposes of the gizmo
  43978. */
  43979. dispose(): void;
  43980. /**
  43981. * CustomMeshes are not supported by this gizmo
  43982. * @param mesh The mesh to replace the default mesh of the gizmo
  43983. */
  43984. setCustomMesh(mesh: Mesh): void;
  43985. }
  43986. }
  43987. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43988. import { Scene } from "babylonjs/scene";
  43989. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43990. import { Mesh } from "babylonjs/Meshes/mesh";
  43991. /**
  43992. * Class containing static functions to help procedurally build meshes
  43993. */
  43994. export class PolyhedronBuilder {
  43995. /**
  43996. * Creates a polyhedron mesh
  43997. * * 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
  43998. * * The parameter `size` (positive float, default 1) sets the polygon size
  43999. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44000. * * 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`
  44001. * * 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
  44002. * * 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)`)
  44003. * * 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
  44004. * * 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
  44005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44008. * @param name defines the name of the mesh
  44009. * @param options defines the options used to create the mesh
  44010. * @param scene defines the hosting scene
  44011. * @returns the polyhedron mesh
  44012. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44013. */
  44014. static CreatePolyhedron(name: string, options: {
  44015. type?: number;
  44016. size?: number;
  44017. sizeX?: number;
  44018. sizeY?: number;
  44019. sizeZ?: number;
  44020. custom?: any;
  44021. faceUV?: Vector4[];
  44022. faceColors?: Color4[];
  44023. flat?: boolean;
  44024. updatable?: boolean;
  44025. sideOrientation?: number;
  44026. frontUVs?: Vector4;
  44027. backUVs?: Vector4;
  44028. }, scene: Scene): Mesh;
  44029. }
  44030. }
  44031. declare module "babylonjs/Gizmos/scaleGizmo" {
  44032. import { Observable } from "babylonjs/Misc/observable";
  44033. import { Nullable } from "babylonjs/types";
  44034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44035. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44036. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44037. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44038. /**
  44039. * Gizmo that enables scaling a mesh along 3 axis
  44040. */
  44041. export class ScaleGizmo extends Gizmo {
  44042. /**
  44043. * Internal gizmo used for interactions on the x axis
  44044. */
  44045. xGizmo: AxisScaleGizmo;
  44046. /**
  44047. * Internal gizmo used for interactions on the y axis
  44048. */
  44049. yGizmo: AxisScaleGizmo;
  44050. /**
  44051. * Internal gizmo used for interactions on the z axis
  44052. */
  44053. zGizmo: AxisScaleGizmo;
  44054. /**
  44055. * Internal gizmo used to scale all axis equally
  44056. */
  44057. uniformScaleGizmo: AxisScaleGizmo;
  44058. /** Fires an event when any of it's sub gizmos are dragged */
  44059. onDragStartObservable: Observable<{}>;
  44060. /** Fires an event when any of it's sub gizmos are released from dragging */
  44061. onDragEndObservable: Observable<{}>;
  44062. attachedMesh: Nullable<AbstractMesh>;
  44063. /**
  44064. * Creates a ScaleGizmo
  44065. * @param gizmoLayer The utility layer the gizmo will be added to
  44066. */
  44067. constructor(gizmoLayer?: UtilityLayerRenderer);
  44068. updateGizmoRotationToMatchAttachedMesh: boolean;
  44069. /**
  44070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44071. */
  44072. snapDistance: number;
  44073. /**
  44074. * Ratio for the scale of the gizmo (Default: 1)
  44075. */
  44076. scaleRatio: number;
  44077. /**
  44078. * Disposes of the gizmo
  44079. */
  44080. dispose(): void;
  44081. }
  44082. }
  44083. declare module "babylonjs/Gizmos/gizmoManager" {
  44084. import { Observable } from "babylonjs/Misc/observable";
  44085. import { Nullable } from "babylonjs/types";
  44086. import { Scene, IDisposable } from "babylonjs/scene";
  44087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44088. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44089. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44090. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44091. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44092. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44093. /**
  44094. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44095. */
  44096. export class GizmoManager implements IDisposable {
  44097. private scene;
  44098. /**
  44099. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44100. */
  44101. gizmos: {
  44102. positionGizmo: Nullable<PositionGizmo>;
  44103. rotationGizmo: Nullable<RotationGizmo>;
  44104. scaleGizmo: Nullable<ScaleGizmo>;
  44105. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44106. };
  44107. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44108. clearGizmoOnEmptyPointerEvent: boolean;
  44109. /** Fires an event when the manager is attached to a mesh */
  44110. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44111. private _gizmosEnabled;
  44112. private _pointerObserver;
  44113. private _attachedMesh;
  44114. private _boundingBoxColor;
  44115. private _defaultUtilityLayer;
  44116. private _defaultKeepDepthUtilityLayer;
  44117. /**
  44118. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44119. */
  44120. boundingBoxDragBehavior: SixDofDragBehavior;
  44121. /**
  44122. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44123. */
  44124. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44125. /**
  44126. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44127. */
  44128. usePointerToAttachGizmos: boolean;
  44129. /**
  44130. * Instatiates a gizmo manager
  44131. * @param scene the scene to overlay the gizmos on top of
  44132. */
  44133. constructor(scene: Scene);
  44134. /**
  44135. * Attaches a set of gizmos to the specified mesh
  44136. * @param mesh The mesh the gizmo's should be attached to
  44137. */
  44138. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44139. /**
  44140. * If the position gizmo is enabled
  44141. */
  44142. positionGizmoEnabled: boolean;
  44143. /**
  44144. * If the rotation gizmo is enabled
  44145. */
  44146. rotationGizmoEnabled: boolean;
  44147. /**
  44148. * If the scale gizmo is enabled
  44149. */
  44150. scaleGizmoEnabled: boolean;
  44151. /**
  44152. * If the boundingBox gizmo is enabled
  44153. */
  44154. boundingBoxGizmoEnabled: boolean;
  44155. /**
  44156. * Disposes of the gizmo manager
  44157. */
  44158. dispose(): void;
  44159. }
  44160. }
  44161. declare module "babylonjs/Lights/directionalLight" {
  44162. import { Camera } from "babylonjs/Cameras/camera";
  44163. import { Scene } from "babylonjs/scene";
  44164. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44166. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44167. import { Effect } from "babylonjs/Materials/effect";
  44168. /**
  44169. * A directional light is defined by a direction (what a surprise!).
  44170. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44171. * 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.
  44172. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44173. */
  44174. export class DirectionalLight extends ShadowLight {
  44175. private _shadowFrustumSize;
  44176. /**
  44177. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44178. */
  44179. /**
  44180. * Specifies a fix frustum size for the shadow generation.
  44181. */
  44182. shadowFrustumSize: number;
  44183. private _shadowOrthoScale;
  44184. /**
  44185. * Gets 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. /**
  44190. * Sets the shadow projection scale against the optimal computed one.
  44191. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44192. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44193. */
  44194. shadowOrthoScale: number;
  44195. /**
  44196. * Automatically compute the projection matrix to best fit (including all the casters)
  44197. * on each frame.
  44198. */
  44199. autoUpdateExtends: boolean;
  44200. private _orthoLeft;
  44201. private _orthoRight;
  44202. private _orthoTop;
  44203. private _orthoBottom;
  44204. /**
  44205. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44206. * The directional light is emitted from everywhere in the given direction.
  44207. * It can cast shadows.
  44208. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44209. * @param name The friendly name of the light
  44210. * @param direction The direction of the light
  44211. * @param scene The scene the light belongs to
  44212. */
  44213. constructor(name: string, direction: Vector3, scene: Scene);
  44214. /**
  44215. * Returns the string "DirectionalLight".
  44216. * @return The class name
  44217. */
  44218. getClassName(): string;
  44219. /**
  44220. * Returns the integer 1.
  44221. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44222. */
  44223. getTypeID(): number;
  44224. /**
  44225. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44229. /**
  44230. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44234. /**
  44235. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44236. * Returns the DirectionalLight Shadow projection matrix.
  44237. */
  44238. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44239. protected _buildUniformLayout(): void;
  44240. /**
  44241. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44242. * @param effect The effect to update
  44243. * @param lightIndex The index of the light in the effect to update
  44244. * @returns The directional light
  44245. */
  44246. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44247. /**
  44248. * Gets the minZ used for shadow according to both the scene and the light.
  44249. *
  44250. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44251. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44252. * @param activeCamera The camera we are returning the min for
  44253. * @returns the depth min z
  44254. */
  44255. getDepthMinZ(activeCamera: Camera): number;
  44256. /**
  44257. * Gets the maxZ used for shadow according to both the scene and the light.
  44258. *
  44259. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44260. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44261. * @param activeCamera The camera we are returning the max for
  44262. * @returns the depth max z
  44263. */
  44264. getDepthMaxZ(activeCamera: Camera): number;
  44265. /**
  44266. * Prepares the list of defines specific to the light type.
  44267. * @param defines the list of defines
  44268. * @param lightIndex defines the index of the light for the effect
  44269. */
  44270. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44274. import { Mesh } from "babylonjs/Meshes/mesh";
  44275. /**
  44276. * Class containing static functions to help procedurally build meshes
  44277. */
  44278. export class HemisphereBuilder {
  44279. /**
  44280. * Creates a hemisphere mesh
  44281. * @param name defines the name of the mesh
  44282. * @param options defines the options used to create the mesh
  44283. * @param scene defines the hosting scene
  44284. * @returns the hemisphere mesh
  44285. */
  44286. static CreateHemisphere(name: string, options: {
  44287. segments?: number;
  44288. diameter?: number;
  44289. sideOrientation?: number;
  44290. }, scene: any): Mesh;
  44291. }
  44292. }
  44293. declare module "babylonjs/Lights/spotLight" {
  44294. import { Nullable } from "babylonjs/types";
  44295. import { Scene } from "babylonjs/scene";
  44296. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44298. import { Effect } from "babylonjs/Materials/effect";
  44299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44300. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44301. /**
  44302. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44303. * These values define a cone of light starting from the position, emitting toward the direction.
  44304. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44305. * and the exponent defines the speed of the decay of the light with distance (reach).
  44306. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44307. */
  44308. export class SpotLight extends ShadowLight {
  44309. private _angle;
  44310. private _innerAngle;
  44311. private _cosHalfAngle;
  44312. private _lightAngleScale;
  44313. private _lightAngleOffset;
  44314. /**
  44315. * Gets the cone angle of the spot light in Radians.
  44316. */
  44317. /**
  44318. * Sets the cone angle of the spot light in Radians.
  44319. */
  44320. angle: number;
  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. /**
  44327. * Only used in gltf falloff mode, this defines the angle where
  44328. * the directional falloff will start before cutting at angle which could be seen
  44329. * as outer angle.
  44330. */
  44331. innerAngle: number;
  44332. private _shadowAngleScale;
  44333. /**
  44334. * Allows scaling the angle of the light for shadow generation only.
  44335. */
  44336. /**
  44337. * Allows scaling the angle of the light for shadow generation only.
  44338. */
  44339. shadowAngleScale: number;
  44340. /**
  44341. * The light decay speed with the distance from the emission spot.
  44342. */
  44343. exponent: number;
  44344. private _projectionTextureMatrix;
  44345. /**
  44346. * Allows reading the projecton texture
  44347. */
  44348. readonly projectionTextureMatrix: Matrix;
  44349. protected _projectionTextureLightNear: number;
  44350. /**
  44351. * Gets the near clip of the Spotlight for texture projection.
  44352. */
  44353. /**
  44354. * Sets the near clip of the Spotlight for texture projection.
  44355. */
  44356. projectionTextureLightNear: number;
  44357. protected _projectionTextureLightFar: number;
  44358. /**
  44359. * Gets the far clip of the Spotlight for texture projection.
  44360. */
  44361. /**
  44362. * Sets the far clip of the Spotlight for texture projection.
  44363. */
  44364. projectionTextureLightFar: number;
  44365. protected _projectionTextureUpDirection: Vector3;
  44366. /**
  44367. * Gets the Up vector of the Spotlight for texture projection.
  44368. */
  44369. /**
  44370. * Sets the Up vector of the Spotlight for texture projection.
  44371. */
  44372. projectionTextureUpDirection: Vector3;
  44373. private _projectionTexture;
  44374. /**
  44375. * Gets the projection texture of the light.
  44376. */
  44377. /**
  44378. * Sets the projection texture of the light.
  44379. */
  44380. projectionTexture: Nullable<BaseTexture>;
  44381. private _projectionTextureViewLightDirty;
  44382. private _projectionTextureProjectionLightDirty;
  44383. private _projectionTextureDirty;
  44384. private _projectionTextureViewTargetVector;
  44385. private _projectionTextureViewLightMatrix;
  44386. private _projectionTextureProjectionLightMatrix;
  44387. private _projectionTextureScalingMatrix;
  44388. /**
  44389. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44390. * It can cast shadows.
  44391. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44392. * @param name The light friendly name
  44393. * @param position The position of the spot light in the scene
  44394. * @param direction The direction of the light in the scene
  44395. * @param angle The cone angle of the light in Radians
  44396. * @param exponent The light decay speed with the distance from the emission spot
  44397. * @param scene The scene the lights belongs to
  44398. */
  44399. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44400. /**
  44401. * Returns the string "SpotLight".
  44402. * @returns the class name
  44403. */
  44404. getClassName(): string;
  44405. /**
  44406. * Returns the integer 2.
  44407. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44408. */
  44409. getTypeID(): number;
  44410. /**
  44411. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44412. */
  44413. protected _setDirection(value: Vector3): void;
  44414. /**
  44415. * Overrides the position setter to recompute the projection texture view light Matrix.
  44416. */
  44417. protected _setPosition(value: Vector3): void;
  44418. /**
  44419. * 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.
  44420. * Returns the SpotLight.
  44421. */
  44422. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44423. protected _computeProjectionTextureViewLightMatrix(): void;
  44424. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44425. /**
  44426. * Main function for light texture projection matrix computing.
  44427. */
  44428. protected _computeProjectionTextureMatrix(): void;
  44429. protected _buildUniformLayout(): void;
  44430. private _computeAngleValues;
  44431. /**
  44432. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44433. * @param effect The effect to update
  44434. * @param lightIndex The index of the light in the effect to update
  44435. * @returns The spot light
  44436. */
  44437. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44438. /**
  44439. * Disposes the light and the associated resources.
  44440. */
  44441. dispose(): void;
  44442. /**
  44443. * Prepares the list of defines specific to the light type.
  44444. * @param defines the list of defines
  44445. * @param lightIndex defines the index of the light for the effect
  44446. */
  44447. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44448. }
  44449. }
  44450. declare module "babylonjs/Gizmos/lightGizmo" {
  44451. import { Nullable } from "babylonjs/types";
  44452. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44453. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44454. import { Light } from "babylonjs/Lights/light";
  44455. /**
  44456. * Gizmo that enables viewing a light
  44457. */
  44458. export class LightGizmo extends Gizmo {
  44459. private _lightMesh;
  44460. private _material;
  44461. /**
  44462. * Creates a LightGizmo
  44463. * @param gizmoLayer The utility layer the gizmo will be added to
  44464. */
  44465. constructor(gizmoLayer?: UtilityLayerRenderer);
  44466. private _light;
  44467. /**
  44468. * The light that the gizmo is attached to
  44469. */
  44470. light: Nullable<Light>;
  44471. /**
  44472. * @hidden
  44473. * Updates the gizmo to match the attached mesh's position/rotation
  44474. */
  44475. protected _update(): void;
  44476. private static _Scale;
  44477. /**
  44478. * Creates the lines for a light mesh
  44479. */
  44480. private static _createLightLines;
  44481. private static _CreateHemisphericLightMesh;
  44482. private static _CreatePointLightMesh;
  44483. private static _CreateSpotLightMesh;
  44484. private static _CreateDirectionalLightMesh;
  44485. }
  44486. }
  44487. declare module "babylonjs/Gizmos/index" {
  44488. export * from "babylonjs/Gizmos/axisDragGizmo";
  44489. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44490. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44491. export * from "babylonjs/Gizmos/gizmo";
  44492. export * from "babylonjs/Gizmos/gizmoManager";
  44493. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44494. export * from "babylonjs/Gizmos/positionGizmo";
  44495. export * from "babylonjs/Gizmos/rotationGizmo";
  44496. export * from "babylonjs/Gizmos/scaleGizmo";
  44497. export * from "babylonjs/Gizmos/lightGizmo";
  44498. }
  44499. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44500. /** @hidden */
  44501. export var backgroundFragmentDeclaration: {
  44502. name: string;
  44503. shader: string;
  44504. };
  44505. }
  44506. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44507. /** @hidden */
  44508. export var backgroundUboDeclaration: {
  44509. name: string;
  44510. shader: string;
  44511. };
  44512. }
  44513. declare module "babylonjs/Shaders/background.fragment" {
  44514. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44515. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44516. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44517. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44518. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44519. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44521. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44522. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44523. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44524. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44525. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44526. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44527. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44528. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44529. /** @hidden */
  44530. export var backgroundPixelShader: {
  44531. name: string;
  44532. shader: string;
  44533. };
  44534. }
  44535. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44536. /** @hidden */
  44537. export var backgroundVertexDeclaration: {
  44538. name: string;
  44539. shader: string;
  44540. };
  44541. }
  44542. declare module "babylonjs/Shaders/background.vertex" {
  44543. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44544. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44546. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44547. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44548. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44549. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44550. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44551. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44555. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44556. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44557. /** @hidden */
  44558. export var backgroundVertexShader: {
  44559. name: string;
  44560. shader: string;
  44561. };
  44562. }
  44563. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44564. import { Nullable, int, float } from "babylonjs/types";
  44565. import { Scene } from "babylonjs/scene";
  44566. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { Mesh } from "babylonjs/Meshes/mesh";
  44570. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44571. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44572. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44574. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44575. import "babylonjs/Shaders/background.fragment";
  44576. import "babylonjs/Shaders/background.vertex";
  44577. /**
  44578. * Background material used to create an efficient environement around your scene.
  44579. */
  44580. export class BackgroundMaterial extends PushMaterial {
  44581. /**
  44582. * Standard reflectance value at parallel view angle.
  44583. */
  44584. static StandardReflectance0: number;
  44585. /**
  44586. * Standard reflectance value at grazing angle.
  44587. */
  44588. static StandardReflectance90: number;
  44589. protected _primaryColor: Color3;
  44590. /**
  44591. * Key light Color (multiply against the environement texture)
  44592. */
  44593. primaryColor: Color3;
  44594. protected __perceptualColor: Nullable<Color3>;
  44595. /**
  44596. * Experimental Internal Use Only.
  44597. *
  44598. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44599. * This acts as a helper to set the primary color to a more "human friendly" value.
  44600. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44601. * output color as close as possible from the chosen value.
  44602. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44603. * part of lighting setup.)
  44604. */
  44605. _perceptualColor: Nullable<Color3>;
  44606. protected _primaryColorShadowLevel: float;
  44607. /**
  44608. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44609. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44610. */
  44611. primaryColorShadowLevel: float;
  44612. protected _primaryColorHighlightLevel: float;
  44613. /**
  44614. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44615. * The primary color is used at the level chosen to define what the white area would look.
  44616. */
  44617. primaryColorHighlightLevel: float;
  44618. protected _reflectionTexture: Nullable<BaseTexture>;
  44619. /**
  44620. * Reflection Texture used in the material.
  44621. * Should be author in a specific way for the best result (refer to the documentation).
  44622. */
  44623. reflectionTexture: Nullable<BaseTexture>;
  44624. protected _reflectionBlur: float;
  44625. /**
  44626. * Reflection Texture level of blur.
  44627. *
  44628. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44629. * texture twice.
  44630. */
  44631. reflectionBlur: float;
  44632. protected _diffuseTexture: Nullable<BaseTexture>;
  44633. /**
  44634. * Diffuse Texture used in the material.
  44635. * Should be author in a specific way for the best result (refer to the documentation).
  44636. */
  44637. diffuseTexture: Nullable<BaseTexture>;
  44638. protected _shadowLights: Nullable<IShadowLight[]>;
  44639. /**
  44640. * Specify the list of lights casting shadow on the material.
  44641. * All scene shadow lights will be included if null.
  44642. */
  44643. shadowLights: Nullable<IShadowLight[]>;
  44644. protected _shadowLevel: float;
  44645. /**
  44646. * Helps adjusting the shadow to a softer level if required.
  44647. * 0 means black shadows and 1 means no shadows.
  44648. */
  44649. shadowLevel: float;
  44650. protected _sceneCenter: Vector3;
  44651. /**
  44652. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44653. * It is usually zero but might be interesting to modify according to your setup.
  44654. */
  44655. sceneCenter: Vector3;
  44656. protected _opacityFresnel: boolean;
  44657. /**
  44658. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44659. * This helps ensuring a nice transition when the camera goes under the ground.
  44660. */
  44661. opacityFresnel: boolean;
  44662. protected _reflectionFresnel: boolean;
  44663. /**
  44664. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44665. * This helps adding a mirror texture on the ground.
  44666. */
  44667. reflectionFresnel: boolean;
  44668. protected _reflectionFalloffDistance: number;
  44669. /**
  44670. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44671. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44672. */
  44673. reflectionFalloffDistance: number;
  44674. protected _reflectionAmount: number;
  44675. /**
  44676. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44677. */
  44678. reflectionAmount: number;
  44679. protected _reflectionReflectance0: number;
  44680. /**
  44681. * This specifies the weight of the reflection at grazing angle.
  44682. */
  44683. reflectionReflectance0: number;
  44684. protected _reflectionReflectance90: number;
  44685. /**
  44686. * This specifies the weight of the reflection at a perpendicular point of view.
  44687. */
  44688. reflectionReflectance90: number;
  44689. /**
  44690. * Sets the reflection reflectance fresnel values according to the default standard
  44691. * empirically know to work well :-)
  44692. */
  44693. reflectionStandardFresnelWeight: number;
  44694. protected _useRGBColor: boolean;
  44695. /**
  44696. * Helps to directly use the maps channels instead of their level.
  44697. */
  44698. useRGBColor: boolean;
  44699. protected _enableNoise: boolean;
  44700. /**
  44701. * This helps reducing the banding effect that could occur on the background.
  44702. */
  44703. enableNoise: boolean;
  44704. /**
  44705. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44706. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44707. * Recommended to be keep at 1.0 except for special cases.
  44708. */
  44709. fovMultiplier: number;
  44710. private _fovMultiplier;
  44711. /**
  44712. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44713. */
  44714. useEquirectangularFOV: boolean;
  44715. private _maxSimultaneousLights;
  44716. /**
  44717. * Number of Simultaneous lights allowed on the material.
  44718. */
  44719. maxSimultaneousLights: int;
  44720. /**
  44721. * Default configuration related to image processing available in the Background Material.
  44722. */
  44723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44724. /**
  44725. * Keep track of the image processing observer to allow dispose and replace.
  44726. */
  44727. private _imageProcessingObserver;
  44728. /**
  44729. * Attaches a new image processing configuration to the PBR Material.
  44730. * @param configuration (if null the scene configuration will be use)
  44731. */
  44732. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44733. /**
  44734. * Gets the image processing configuration used either in this material.
  44735. */
  44736. /**
  44737. * Sets the Default image processing configuration used either in the this material.
  44738. *
  44739. * If sets to null, the scene one is in use.
  44740. */
  44741. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44742. /**
  44743. * Gets wether the color curves effect is enabled.
  44744. */
  44745. /**
  44746. * Sets wether the color curves effect is enabled.
  44747. */
  44748. cameraColorCurvesEnabled: boolean;
  44749. /**
  44750. * Gets wether the color grading effect is enabled.
  44751. */
  44752. /**
  44753. * Gets wether the color grading effect is enabled.
  44754. */
  44755. cameraColorGradingEnabled: boolean;
  44756. /**
  44757. * Gets wether tonemapping is enabled or not.
  44758. */
  44759. /**
  44760. * Sets wether tonemapping is enabled or not
  44761. */
  44762. cameraToneMappingEnabled: boolean;
  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. /**
  44769. * The camera exposure used on this material.
  44770. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44771. * This corresponds to a photographic exposure.
  44772. */
  44773. cameraExposure: float;
  44774. /**
  44775. * Gets The camera contrast used on this material.
  44776. */
  44777. /**
  44778. * Sets The camera contrast used on this material.
  44779. */
  44780. cameraContrast: float;
  44781. /**
  44782. * Gets the Color Grading 2D Lookup Texture.
  44783. */
  44784. /**
  44785. * Sets the Color Grading 2D Lookup Texture.
  44786. */
  44787. cameraColorGradingTexture: Nullable<BaseTexture>;
  44788. /**
  44789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44791. * 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;
  44792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44793. */
  44794. /**
  44795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44797. * 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;
  44798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44799. */
  44800. cameraColorCurves: Nullable<ColorCurves>;
  44801. /**
  44802. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44803. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44804. */
  44805. switchToBGR: boolean;
  44806. private _renderTargets;
  44807. private _reflectionControls;
  44808. private _white;
  44809. private _primaryShadowColor;
  44810. private _primaryHighlightColor;
  44811. /**
  44812. * Instantiates a Background Material in the given scene
  44813. * @param name The friendly name of the material
  44814. * @param scene The scene to add the material to
  44815. */
  44816. constructor(name: string, scene: Scene);
  44817. /**
  44818. * Gets a boolean indicating that current material needs to register RTT
  44819. */
  44820. readonly hasRenderTargetTextures: boolean;
  44821. /**
  44822. * The entire material has been created in order to prevent overdraw.
  44823. * @returns false
  44824. */
  44825. needAlphaTesting(): boolean;
  44826. /**
  44827. * The entire material has been created in order to prevent overdraw.
  44828. * @returns true if blending is enable
  44829. */
  44830. needAlphaBlending(): boolean;
  44831. /**
  44832. * Checks wether the material is ready to be rendered for a given mesh.
  44833. * @param mesh The mesh to render
  44834. * @param subMesh The submesh to check against
  44835. * @param useInstances Specify wether or not the material is used with instances
  44836. * @returns true if all the dependencies are ready (Textures, Effects...)
  44837. */
  44838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44839. /**
  44840. * Compute the primary color according to the chosen perceptual color.
  44841. */
  44842. private _computePrimaryColorFromPerceptualColor;
  44843. /**
  44844. * Compute the highlights and shadow colors according to their chosen levels.
  44845. */
  44846. private _computePrimaryColors;
  44847. /**
  44848. * Build the uniform buffer used in the material.
  44849. */
  44850. buildUniformLayout(): void;
  44851. /**
  44852. * Unbind the material.
  44853. */
  44854. unbind(): void;
  44855. /**
  44856. * Bind only the world matrix to the material.
  44857. * @param world The world matrix to bind.
  44858. */
  44859. bindOnlyWorldMatrix(world: Matrix): void;
  44860. /**
  44861. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44862. * @param world The world matrix to bind.
  44863. * @param subMesh The submesh to bind for.
  44864. */
  44865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44866. /**
  44867. * Dispose the material.
  44868. * @param forceDisposeEffect Force disposal of the associated effect.
  44869. * @param forceDisposeTextures Force disposal of the associated textures.
  44870. */
  44871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44872. /**
  44873. * Clones the material.
  44874. * @param name The cloned name.
  44875. * @returns The cloned material.
  44876. */
  44877. clone(name: string): BackgroundMaterial;
  44878. /**
  44879. * Serializes the current material to its JSON representation.
  44880. * @returns The JSON representation.
  44881. */
  44882. serialize(): any;
  44883. /**
  44884. * Gets the class name of the material
  44885. * @returns "BackgroundMaterial"
  44886. */
  44887. getClassName(): string;
  44888. /**
  44889. * Parse a JSON input to create back a background material.
  44890. * @param source The JSON data to parse
  44891. * @param scene The scene to create the parsed material in
  44892. * @param rootUrl The root url of the assets the material depends upon
  44893. * @returns the instantiated BackgroundMaterial.
  44894. */
  44895. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44896. }
  44897. }
  44898. declare module "babylonjs/Helpers/environmentHelper" {
  44899. import { Observable } from "babylonjs/Misc/observable";
  44900. import { Nullable } from "babylonjs/types";
  44901. import { Scene } from "babylonjs/scene";
  44902. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44904. import { Mesh } from "babylonjs/Meshes/mesh";
  44905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44906. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44907. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44908. import "babylonjs/Meshes/Builders/planeBuilder";
  44909. import "babylonjs/Meshes/Builders/boxBuilder";
  44910. /**
  44911. * Represents the different options available during the creation of
  44912. * a Environment helper.
  44913. *
  44914. * This can control the default ground, skybox and image processing setup of your scene.
  44915. */
  44916. export interface IEnvironmentHelperOptions {
  44917. /**
  44918. * Specifies wether or not to create a ground.
  44919. * True by default.
  44920. */
  44921. createGround: boolean;
  44922. /**
  44923. * Specifies the ground size.
  44924. * 15 by default.
  44925. */
  44926. groundSize: number;
  44927. /**
  44928. * The texture used on the ground for the main color.
  44929. * Comes from the BabylonJS CDN by default.
  44930. *
  44931. * Remarks: Can be either a texture or a url.
  44932. */
  44933. groundTexture: string | BaseTexture;
  44934. /**
  44935. * The color mixed in the ground texture by default.
  44936. * BabylonJS clearColor by default.
  44937. */
  44938. groundColor: Color3;
  44939. /**
  44940. * Specifies the ground opacity.
  44941. * 1 by default.
  44942. */
  44943. groundOpacity: number;
  44944. /**
  44945. * Enables the ground to receive shadows.
  44946. * True by default.
  44947. */
  44948. enableGroundShadow: boolean;
  44949. /**
  44950. * Helps preventing the shadow to be fully black on the ground.
  44951. * 0.5 by default.
  44952. */
  44953. groundShadowLevel: number;
  44954. /**
  44955. * Creates a mirror texture attach to the ground.
  44956. * false by default.
  44957. */
  44958. enableGroundMirror: boolean;
  44959. /**
  44960. * Specifies the ground mirror size ratio.
  44961. * 0.3 by default as the default kernel is 64.
  44962. */
  44963. groundMirrorSizeRatio: number;
  44964. /**
  44965. * Specifies the ground mirror blur kernel size.
  44966. * 64 by default.
  44967. */
  44968. groundMirrorBlurKernel: number;
  44969. /**
  44970. * Specifies the ground mirror visibility amount.
  44971. * 1 by default
  44972. */
  44973. groundMirrorAmount: number;
  44974. /**
  44975. * Specifies the ground mirror reflectance weight.
  44976. * This uses the standard weight of the background material to setup the fresnel effect
  44977. * of the mirror.
  44978. * 1 by default.
  44979. */
  44980. groundMirrorFresnelWeight: number;
  44981. /**
  44982. * Specifies the ground mirror Falloff distance.
  44983. * This can helps reducing the size of the reflection.
  44984. * 0 by Default.
  44985. */
  44986. groundMirrorFallOffDistance: number;
  44987. /**
  44988. * Specifies the ground mirror texture type.
  44989. * Unsigned Int by Default.
  44990. */
  44991. groundMirrorTextureType: number;
  44992. /**
  44993. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44994. * the shown objects.
  44995. */
  44996. groundYBias: number;
  44997. /**
  44998. * Specifies wether or not to create a skybox.
  44999. * True by default.
  45000. */
  45001. createSkybox: boolean;
  45002. /**
  45003. * Specifies the skybox size.
  45004. * 20 by default.
  45005. */
  45006. skyboxSize: number;
  45007. /**
  45008. * The texture used on the skybox for the main color.
  45009. * Comes from the BabylonJS CDN by default.
  45010. *
  45011. * Remarks: Can be either a texture or a url.
  45012. */
  45013. skyboxTexture: string | BaseTexture;
  45014. /**
  45015. * The color mixed in the skybox texture by default.
  45016. * BabylonJS clearColor by default.
  45017. */
  45018. skyboxColor: Color3;
  45019. /**
  45020. * The background rotation around the Y axis of the scene.
  45021. * This helps aligning the key lights of your scene with the background.
  45022. * 0 by default.
  45023. */
  45024. backgroundYRotation: number;
  45025. /**
  45026. * Compute automatically the size of the elements to best fit with the scene.
  45027. */
  45028. sizeAuto: boolean;
  45029. /**
  45030. * Default position of the rootMesh if autoSize is not true.
  45031. */
  45032. rootPosition: Vector3;
  45033. /**
  45034. * Sets up the image processing in the scene.
  45035. * true by default.
  45036. */
  45037. setupImageProcessing: boolean;
  45038. /**
  45039. * The texture used as your environment texture in the scene.
  45040. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45041. *
  45042. * Remarks: Can be either a texture or a url.
  45043. */
  45044. environmentTexture: string | BaseTexture;
  45045. /**
  45046. * The value of the exposure to apply to the scene.
  45047. * 0.6 by default if setupImageProcessing is true.
  45048. */
  45049. cameraExposure: number;
  45050. /**
  45051. * The value of the contrast to apply to the scene.
  45052. * 1.6 by default if setupImageProcessing is true.
  45053. */
  45054. cameraContrast: number;
  45055. /**
  45056. * Specifies wether or not tonemapping should be enabled in the scene.
  45057. * true by default if setupImageProcessing is true.
  45058. */
  45059. toneMappingEnabled: boolean;
  45060. }
  45061. /**
  45062. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45063. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45064. * It also helps with the default setup of your imageProcessing configuration.
  45065. */
  45066. export class EnvironmentHelper {
  45067. /**
  45068. * Default ground texture URL.
  45069. */
  45070. private static _groundTextureCDNUrl;
  45071. /**
  45072. * Default skybox texture URL.
  45073. */
  45074. private static _skyboxTextureCDNUrl;
  45075. /**
  45076. * Default environment texture URL.
  45077. */
  45078. private static _environmentTextureCDNUrl;
  45079. /**
  45080. * Creates the default options for the helper.
  45081. */
  45082. private static _getDefaultOptions;
  45083. private _rootMesh;
  45084. /**
  45085. * Gets the root mesh created by the helper.
  45086. */
  45087. readonly rootMesh: Mesh;
  45088. private _skybox;
  45089. /**
  45090. * Gets the skybox created by the helper.
  45091. */
  45092. readonly skybox: Nullable<Mesh>;
  45093. private _skyboxTexture;
  45094. /**
  45095. * Gets the skybox texture created by the helper.
  45096. */
  45097. readonly skyboxTexture: Nullable<BaseTexture>;
  45098. private _skyboxMaterial;
  45099. /**
  45100. * Gets the skybox material created by the helper.
  45101. */
  45102. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45103. private _ground;
  45104. /**
  45105. * Gets the ground mesh created by the helper.
  45106. */
  45107. readonly ground: Nullable<Mesh>;
  45108. private _groundTexture;
  45109. /**
  45110. * Gets the ground texture created by the helper.
  45111. */
  45112. readonly groundTexture: Nullable<BaseTexture>;
  45113. private _groundMirror;
  45114. /**
  45115. * Gets the ground mirror created by the helper.
  45116. */
  45117. readonly groundMirror: Nullable<MirrorTexture>;
  45118. /**
  45119. * Gets the ground mirror render list to helps pushing the meshes
  45120. * you wish in the ground reflection.
  45121. */
  45122. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45123. private _groundMaterial;
  45124. /**
  45125. * Gets the ground material created by the helper.
  45126. */
  45127. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45128. /**
  45129. * Stores the creation options.
  45130. */
  45131. private readonly _scene;
  45132. private _options;
  45133. /**
  45134. * This observable will be notified with any error during the creation of the environment,
  45135. * mainly texture creation errors.
  45136. */
  45137. onErrorObservable: Observable<{
  45138. message?: string;
  45139. exception?: any;
  45140. }>;
  45141. /**
  45142. * constructor
  45143. * @param options Defines the options we want to customize the helper
  45144. * @param scene The scene to add the material to
  45145. */
  45146. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45147. /**
  45148. * Updates the background according to the new options
  45149. * @param options
  45150. */
  45151. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45152. /**
  45153. * Sets the primary color of all the available elements.
  45154. * @param color the main color to affect to the ground and the background
  45155. */
  45156. setMainColor(color: Color3): void;
  45157. /**
  45158. * Setup the image processing according to the specified options.
  45159. */
  45160. private _setupImageProcessing;
  45161. /**
  45162. * Setup the environment texture according to the specified options.
  45163. */
  45164. private _setupEnvironmentTexture;
  45165. /**
  45166. * Setup the background according to the specified options.
  45167. */
  45168. private _setupBackground;
  45169. /**
  45170. * Get the scene sizes according to the setup.
  45171. */
  45172. private _getSceneSize;
  45173. /**
  45174. * Setup the ground according to the specified options.
  45175. */
  45176. private _setupGround;
  45177. /**
  45178. * Setup the ground material according to the specified options.
  45179. */
  45180. private _setupGroundMaterial;
  45181. /**
  45182. * Setup the ground diffuse texture according to the specified options.
  45183. */
  45184. private _setupGroundDiffuseTexture;
  45185. /**
  45186. * Setup the ground mirror texture according to the specified options.
  45187. */
  45188. private _setupGroundMirrorTexture;
  45189. /**
  45190. * Setup the ground to receive the mirror texture.
  45191. */
  45192. private _setupMirrorInGroundMaterial;
  45193. /**
  45194. * Setup the skybox according to the specified options.
  45195. */
  45196. private _setupSkybox;
  45197. /**
  45198. * Setup the skybox material according to the specified options.
  45199. */
  45200. private _setupSkyboxMaterial;
  45201. /**
  45202. * Setup the skybox reflection texture according to the specified options.
  45203. */
  45204. private _setupSkyboxReflectionTexture;
  45205. private _errorHandler;
  45206. /**
  45207. * Dispose all the elements created by the Helper.
  45208. */
  45209. dispose(): void;
  45210. }
  45211. }
  45212. declare module "babylonjs/Helpers/photoDome" {
  45213. import { Observable } from "babylonjs/Misc/observable";
  45214. import { Nullable } from "babylonjs/types";
  45215. import { Scene } from "babylonjs/scene";
  45216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45217. import { Mesh } from "babylonjs/Meshes/mesh";
  45218. import { Texture } from "babylonjs/Materials/Textures/texture";
  45219. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45220. import "babylonjs/Meshes/Builders/sphereBuilder";
  45221. /**
  45222. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45223. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45224. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45225. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45226. */
  45227. export class PhotoDome extends TransformNode {
  45228. private _useDirectMapping;
  45229. /**
  45230. * The texture being displayed on the sphere
  45231. */
  45232. protected _photoTexture: Texture;
  45233. /**
  45234. * Gets or sets the texture being displayed on the sphere
  45235. */
  45236. photoTexture: Texture;
  45237. /**
  45238. * Observable raised when an error occured while loading the 360 image
  45239. */
  45240. onLoadErrorObservable: Observable<string>;
  45241. /**
  45242. * The skybox material
  45243. */
  45244. protected _material: BackgroundMaterial;
  45245. /**
  45246. * The surface used for the skybox
  45247. */
  45248. protected _mesh: Mesh;
  45249. /**
  45250. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45251. * Also see the options.resolution property.
  45252. */
  45253. fovMultiplier: number;
  45254. /**
  45255. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45256. * @param name Element's name, child elements will append suffixes for their own names.
  45257. * @param urlsOfPhoto defines the url of the photo to display
  45258. * @param options defines an object containing optional or exposed sub element properties
  45259. * @param onError defines a callback called when an error occured while loading the texture
  45260. */
  45261. constructor(name: string, urlOfPhoto: string, options: {
  45262. resolution?: number;
  45263. size?: number;
  45264. useDirectMapping?: boolean;
  45265. faceForward?: boolean;
  45266. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45267. /**
  45268. * Releases resources associated with this node.
  45269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45271. */
  45272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45273. }
  45274. }
  45275. declare module "babylonjs/Misc/brdfTextureTools" {
  45276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45277. import { Scene } from "babylonjs/scene";
  45278. /**
  45279. * Class used to host texture specific utilities
  45280. */
  45281. export class BRDFTextureTools {
  45282. /**
  45283. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45284. * @param texture the texture to expand.
  45285. */
  45286. private static _ExpandDefaultBRDFTexture;
  45287. /**
  45288. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45289. * @param scene defines the hosting scene
  45290. * @returns the environment BRDF texture
  45291. */
  45292. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45293. private static _environmentBRDFBase64Texture;
  45294. }
  45295. }
  45296. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45297. import { Nullable } from "babylonjs/types";
  45298. import { IAnimatable } from "babylonjs/Misc/tools";
  45299. import { Color3 } from "babylonjs/Maths/math";
  45300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45301. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45302. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45303. import { Engine } from "babylonjs/Engines/engine";
  45304. import { Scene } from "babylonjs/scene";
  45305. /**
  45306. * @hidden
  45307. */
  45308. export interface IMaterialClearCoatDefines {
  45309. CLEARCOAT: boolean;
  45310. CLEARCOAT_DEFAULTIOR: boolean;
  45311. CLEARCOAT_TEXTURE: boolean;
  45312. CLEARCOAT_TEXTUREDIRECTUV: number;
  45313. CLEARCOAT_BUMP: boolean;
  45314. CLEARCOAT_BUMPDIRECTUV: number;
  45315. CLEARCOAT_TINT: boolean;
  45316. CLEARCOAT_TINT_TEXTURE: boolean;
  45317. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45318. /** @hidden */
  45319. _areTexturesDirty: boolean;
  45320. }
  45321. /**
  45322. * Define the code related to the clear coat parameters of the pbr material.
  45323. */
  45324. export class PBRClearCoatConfiguration {
  45325. /**
  45326. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45327. * The default fits with a polyurethane material.
  45328. */
  45329. private static readonly _DefaultIndiceOfRefraction;
  45330. private _isEnabled;
  45331. /**
  45332. * Defines if the clear coat is enabled in the material.
  45333. */
  45334. isEnabled: boolean;
  45335. /**
  45336. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45337. */
  45338. intensity: number;
  45339. /**
  45340. * Defines the clear coat layer roughness.
  45341. */
  45342. roughness: number;
  45343. private _indiceOfRefraction;
  45344. /**
  45345. * Defines the indice of refraction of the clear coat.
  45346. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45347. * The default fits with a polyurethane material.
  45348. * Changing the default value is more performance intensive.
  45349. */
  45350. indiceOfRefraction: number;
  45351. private _texture;
  45352. /**
  45353. * Stores the clear coat values in a texture.
  45354. */
  45355. texture: Nullable<BaseTexture>;
  45356. private _bumpTexture;
  45357. /**
  45358. * Define the clear coat specific bump texture.
  45359. */
  45360. bumpTexture: Nullable<BaseTexture>;
  45361. private _isTintEnabled;
  45362. /**
  45363. * Defines if the clear coat tint is enabled in the material.
  45364. */
  45365. isTintEnabled: boolean;
  45366. /**
  45367. * Defines if the clear coat tint is enabled in the material.
  45368. * This is only use if tint is enabled
  45369. */
  45370. tintColor: Color3;
  45371. /**
  45372. * Defines if the distance at which the tint color should be found in the
  45373. * clear coat media.
  45374. * This is only use if tint is enabled
  45375. */
  45376. tintColorAtDistance: number;
  45377. /**
  45378. * Defines the clear coat layer thickness.
  45379. * This is only use if tint is enabled
  45380. */
  45381. tintThickness: number;
  45382. private _tintTexture;
  45383. /**
  45384. * Stores the clear tint values in a texture.
  45385. * rgb is tint
  45386. * a is a thickness factor
  45387. */
  45388. tintTexture: Nullable<BaseTexture>;
  45389. /** @hidden */
  45390. private _internalMarkAllSubMeshesAsTexturesDirty;
  45391. /** @hidden */
  45392. _markAllSubMeshesAsTexturesDirty(): void;
  45393. /**
  45394. * Instantiate a new istance of clear coat configuration.
  45395. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45396. */
  45397. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45398. /**
  45399. * Specifies that the submesh is ready to be used.
  45400. * @param defines the list of "defines" to update.
  45401. * @param scene defines the scene the material belongs to.
  45402. * @param engine defines the engine the material belongs to.
  45403. * @param disableBumpMap defines wether the material disables bump or not.
  45404. * @returns - boolean indicating that the submesh is ready or not.
  45405. */
  45406. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45407. /**
  45408. * Checks to see if a texture is used in the material.
  45409. * @param defines the list of "defines" to update.
  45410. * @param scene defines the scene to the material belongs to.
  45411. */
  45412. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45413. /**
  45414. * Binds the material data.
  45415. * @param uniformBuffer defines the Uniform buffer to fill in.
  45416. * @param scene defines the scene the material belongs to.
  45417. * @param engine defines the engine the material belongs to.
  45418. * @param disableBumpMap defines wether the material disables bump or not.
  45419. * @param isFrozen defines wether the material is frozen or not.
  45420. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45421. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45422. */
  45423. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45424. /**
  45425. * Checks to see if a texture is used in the material.
  45426. * @param texture - Base texture to use.
  45427. * @returns - Boolean specifying if a texture is used in the material.
  45428. */
  45429. hasTexture(texture: BaseTexture): boolean;
  45430. /**
  45431. * Returns an array of the actively used textures.
  45432. * @param activeTextures Array of BaseTextures
  45433. */
  45434. getActiveTextures(activeTextures: BaseTexture[]): void;
  45435. /**
  45436. * Returns the animatable textures.
  45437. * @param animatables Array of animatable textures.
  45438. */
  45439. getAnimatables(animatables: IAnimatable[]): void;
  45440. /**
  45441. * Disposes the resources of the material.
  45442. * @param forceDisposeTextures - Forces the disposal of all textures.
  45443. */
  45444. dispose(forceDisposeTextures?: boolean): void;
  45445. /**
  45446. * Get the current class name of the texture useful for serialization or dynamic coding.
  45447. * @returns "PBRClearCoatConfiguration"
  45448. */
  45449. getClassName(): string;
  45450. /**
  45451. * Add fallbacks to the effect fallbacks list.
  45452. * @param defines defines the Base texture to use.
  45453. * @param fallbacks defines the current fallback list.
  45454. * @param currentRank defines the current fallback rank.
  45455. * @returns the new fallback rank.
  45456. */
  45457. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45458. /**
  45459. * Add the required uniforms to the current list.
  45460. * @param uniforms defines the current uniform list.
  45461. */
  45462. static AddUniforms(uniforms: string[]): void;
  45463. /**
  45464. * Add the required samplers to the current list.
  45465. * @param samplers defines the current sampler list.
  45466. */
  45467. static AddSamplers(samplers: string[]): void;
  45468. /**
  45469. * Add the required uniforms to the current buffer.
  45470. * @param uniformBuffer defines the current uniform buffer.
  45471. */
  45472. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45473. /**
  45474. * Makes a duplicate of the current configuration into another one.
  45475. * @param clearCoatConfiguration define the config where to copy the info
  45476. */
  45477. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45478. /**
  45479. * Serializes this clear coat configuration.
  45480. * @returns - An object with the serialized config.
  45481. */
  45482. serialize(): any;
  45483. /**
  45484. * Parses a Clear Coat Configuration from a serialized object.
  45485. * @param source - Serialized object.
  45486. */
  45487. parse(source: any): void;
  45488. }
  45489. }
  45490. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45491. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45492. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45494. import { Vector2 } from "babylonjs/Maths/math";
  45495. import { Scene } from "babylonjs/scene";
  45496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45497. import { IAnimatable } from "babylonjs/Misc/tools";
  45498. import { Nullable } from "babylonjs/types";
  45499. /**
  45500. * @hidden
  45501. */
  45502. export interface IMaterialAnisotropicDefines {
  45503. ANISOTROPIC: boolean;
  45504. ANISOTROPIC_TEXTURE: boolean;
  45505. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45506. MAINUV1: boolean;
  45507. _areTexturesDirty: boolean;
  45508. _needUVs: boolean;
  45509. }
  45510. /**
  45511. * Define the code related to the anisotropic parameters of the pbr material.
  45512. */
  45513. export class PBRAnisotropicConfiguration {
  45514. private _isEnabled;
  45515. /**
  45516. * Defines if the anisotropy is enabled in the material.
  45517. */
  45518. isEnabled: boolean;
  45519. /**
  45520. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45521. */
  45522. intensity: number;
  45523. /**
  45524. * Defines if the effect is along the tangents, bitangents or in between.
  45525. * By default, the effect is "strectching" the highlights along the tangents.
  45526. */
  45527. direction: Vector2;
  45528. private _texture;
  45529. /**
  45530. * Stores the anisotropy values in a texture.
  45531. * rg is direction (like normal from -1 to 1)
  45532. * b is a intensity
  45533. */
  45534. texture: Nullable<BaseTexture>;
  45535. /** @hidden */
  45536. private _internalMarkAllSubMeshesAsTexturesDirty;
  45537. /** @hidden */
  45538. _markAllSubMeshesAsTexturesDirty(): void;
  45539. /**
  45540. * Instantiate a new istance of anisotropy configuration.
  45541. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45542. */
  45543. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45544. /**
  45545. * Specifies that the submesh is ready to be used.
  45546. * @param defines the list of "defines" to update.
  45547. * @param scene defines the scene the material belongs to.
  45548. * @returns - boolean indicating that the submesh is ready or not.
  45549. */
  45550. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45551. /**
  45552. * Checks to see if a texture is used in the material.
  45553. * @param defines the list of "defines" to update.
  45554. * @param mesh the mesh we are preparing the defines for.
  45555. * @param scene defines the scene the material belongs to.
  45556. */
  45557. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45558. /**
  45559. * Binds the material data.
  45560. * @param uniformBuffer defines the Uniform buffer to fill in.
  45561. * @param scene defines the scene the material belongs to.
  45562. * @param isFrozen defines wether the material is frozen or not.
  45563. */
  45564. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45565. /**
  45566. * Checks to see if a texture is used in the material.
  45567. * @param texture - Base texture to use.
  45568. * @returns - Boolean specifying if a texture is used in the material.
  45569. */
  45570. hasTexture(texture: BaseTexture): boolean;
  45571. /**
  45572. * Returns an array of the actively used textures.
  45573. * @param activeTextures Array of BaseTextures
  45574. */
  45575. getActiveTextures(activeTextures: BaseTexture[]): void;
  45576. /**
  45577. * Returns the animatable textures.
  45578. * @param animatables Array of animatable textures.
  45579. */
  45580. getAnimatables(animatables: IAnimatable[]): void;
  45581. /**
  45582. * Disposes the resources of the material.
  45583. * @param forceDisposeTextures - Forces the disposal of all textures.
  45584. */
  45585. dispose(forceDisposeTextures?: boolean): void;
  45586. /**
  45587. * Get the current class name of the texture useful for serialization or dynamic coding.
  45588. * @returns "PBRAnisotropicConfiguration"
  45589. */
  45590. getClassName(): string;
  45591. /**
  45592. * Add fallbacks to the effect fallbacks list.
  45593. * @param defines defines the Base texture to use.
  45594. * @param fallbacks defines the current fallback list.
  45595. * @param currentRank defines the current fallback rank.
  45596. * @returns the new fallback rank.
  45597. */
  45598. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45599. /**
  45600. * Add the required uniforms to the current list.
  45601. * @param uniforms defines the current uniform list.
  45602. */
  45603. static AddUniforms(uniforms: string[]): void;
  45604. /**
  45605. * Add the required uniforms to the current buffer.
  45606. * @param uniformBuffer defines the current uniform buffer.
  45607. */
  45608. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45609. /**
  45610. * Add the required samplers to the current list.
  45611. * @param samplers defines the current sampler list.
  45612. */
  45613. static AddSamplers(samplers: string[]): void;
  45614. /**
  45615. * Makes a duplicate of the current configuration into another one.
  45616. * @param anisotropicConfiguration define the config where to copy the info
  45617. */
  45618. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45619. /**
  45620. * Serializes this anisotropy configuration.
  45621. * @returns - An object with the serialized config.
  45622. */
  45623. serialize(): any;
  45624. /**
  45625. * Parses a anisotropy Configuration from a serialized object.
  45626. * @param source - Serialized object.
  45627. */
  45628. parse(source: any): void;
  45629. }
  45630. }
  45631. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45632. /**
  45633. * @hidden
  45634. */
  45635. export interface IMaterialBRDFDefines {
  45636. BRDF_V_HEIGHT_CORRELATED: boolean;
  45637. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45638. /** @hidden */
  45639. _areMiscDirty: boolean;
  45640. }
  45641. /**
  45642. * Define the code related to the BRDF parameters of the pbr material.
  45643. */
  45644. export class PBRBRDFConfiguration {
  45645. /**
  45646. * Default value used for the energy conservation.
  45647. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45648. */
  45649. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45650. /**
  45651. * Default value used for the Smith Visibility Height Correlated mode.
  45652. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45653. */
  45654. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45655. private _useEnergyConservation;
  45656. /**
  45657. * Defines if the material uses energy conservation.
  45658. */
  45659. useEnergyConservation: boolean;
  45660. private _useSmithVisibilityHeightCorrelated;
  45661. /**
  45662. * LEGACY Mode set to false
  45663. * Defines if the material uses height smith correlated visibility term.
  45664. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45665. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45666. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45667. * Not relying on height correlated will also disable energy conservation.
  45668. */
  45669. useSmithVisibilityHeightCorrelated: boolean;
  45670. /** @hidden */
  45671. private _internalMarkAllSubMeshesAsMiscDirty;
  45672. /** @hidden */
  45673. _markAllSubMeshesAsMiscDirty(): void;
  45674. /**
  45675. * Instantiate a new istance of clear coat configuration.
  45676. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45677. */
  45678. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45679. /**
  45680. * Checks to see if a texture is used in the material.
  45681. * @param defines the list of "defines" to update.
  45682. */
  45683. prepareDefines(defines: IMaterialBRDFDefines): void;
  45684. /**
  45685. * Get the current class name of the texture useful for serialization or dynamic coding.
  45686. * @returns "PBRClearCoatConfiguration"
  45687. */
  45688. getClassName(): string;
  45689. /**
  45690. * Makes a duplicate of the current configuration into another one.
  45691. * @param brdfConfiguration define the config where to copy the info
  45692. */
  45693. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45694. /**
  45695. * Serializes this BRDF configuration.
  45696. * @returns - An object with the serialized config.
  45697. */
  45698. serialize(): any;
  45699. /**
  45700. * Parses a BRDF Configuration from a serialized object.
  45701. * @param source - Serialized object.
  45702. */
  45703. parse(source: any): void;
  45704. }
  45705. }
  45706. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45707. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45708. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45709. import { Color3 } from "babylonjs/Maths/math";
  45710. import { Scene } from "babylonjs/scene";
  45711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45712. import { IAnimatable } from "babylonjs/Misc/tools";
  45713. import { Nullable } from "babylonjs/types";
  45714. /**
  45715. * @hidden
  45716. */
  45717. export interface IMaterialSheenDefines {
  45718. SHEEN: boolean;
  45719. SHEEN_TEXTURE: boolean;
  45720. SHEEN_TEXTUREDIRECTUV: number;
  45721. SHEEN_LINKWITHALBEDO: boolean;
  45722. /** @hidden */
  45723. _areTexturesDirty: boolean;
  45724. }
  45725. /**
  45726. * Define the code related to the Sheen parameters of the pbr material.
  45727. */
  45728. export class PBRSheenConfiguration {
  45729. private _isEnabled;
  45730. /**
  45731. * Defines if the material uses sheen.
  45732. */
  45733. isEnabled: boolean;
  45734. private _linkSheenWithAlbedo;
  45735. /**
  45736. * Defines if the sheen is linked to the sheen color.
  45737. */
  45738. linkSheenWithAlbedo: boolean;
  45739. /**
  45740. * Defines the sheen intensity.
  45741. */
  45742. intensity: number;
  45743. /**
  45744. * Defines the sheen color.
  45745. */
  45746. color: Color3;
  45747. private _texture;
  45748. /**
  45749. * Stores the sheen tint values in a texture.
  45750. * rgb is tint
  45751. * a is a intensity
  45752. */
  45753. texture: Nullable<BaseTexture>;
  45754. /** @hidden */
  45755. private _internalMarkAllSubMeshesAsTexturesDirty;
  45756. /** @hidden */
  45757. _markAllSubMeshesAsTexturesDirty(): void;
  45758. /**
  45759. * Instantiate a new istance of clear coat configuration.
  45760. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45761. */
  45762. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45763. /**
  45764. * Specifies that the submesh is ready to be used.
  45765. * @param defines the list of "defines" to update.
  45766. * @param scene defines the scene the material belongs to.
  45767. * @returns - boolean indicating that the submesh is ready or not.
  45768. */
  45769. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45770. /**
  45771. * Checks to see if a texture is used in the material.
  45772. * @param defines the list of "defines" to update.
  45773. * @param scene defines the scene the material belongs to.
  45774. */
  45775. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45776. /**
  45777. * Binds the material data.
  45778. * @param uniformBuffer defines the Uniform buffer to fill in.
  45779. * @param scene defines the scene the material belongs to.
  45780. * @param isFrozen defines wether the material is frozen or not.
  45781. */
  45782. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45783. /**
  45784. * Checks to see if a texture is used in the material.
  45785. * @param texture - Base texture to use.
  45786. * @returns - Boolean specifying if a texture is used in the material.
  45787. */
  45788. hasTexture(texture: BaseTexture): boolean;
  45789. /**
  45790. * Returns an array of the actively used textures.
  45791. * @param activeTextures Array of BaseTextures
  45792. */
  45793. getActiveTextures(activeTextures: BaseTexture[]): void;
  45794. /**
  45795. * Returns the animatable textures.
  45796. * @param animatables Array of animatable textures.
  45797. */
  45798. getAnimatables(animatables: IAnimatable[]): void;
  45799. /**
  45800. * Disposes the resources of the material.
  45801. * @param forceDisposeTextures - Forces the disposal of all textures.
  45802. */
  45803. dispose(forceDisposeTextures?: boolean): void;
  45804. /**
  45805. * Get the current class name of the texture useful for serialization or dynamic coding.
  45806. * @returns "PBRSheenConfiguration"
  45807. */
  45808. getClassName(): string;
  45809. /**
  45810. * Add fallbacks to the effect fallbacks list.
  45811. * @param defines defines the Base texture to use.
  45812. * @param fallbacks defines the current fallback list.
  45813. * @param currentRank defines the current fallback rank.
  45814. * @returns the new fallback rank.
  45815. */
  45816. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45817. /**
  45818. * Add the required uniforms to the current list.
  45819. * @param uniforms defines the current uniform list.
  45820. */
  45821. static AddUniforms(uniforms: string[]): void;
  45822. /**
  45823. * Add the required uniforms to the current buffer.
  45824. * @param uniformBuffer defines the current uniform buffer.
  45825. */
  45826. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45827. /**
  45828. * Add the required samplers to the current list.
  45829. * @param samplers defines the current sampler list.
  45830. */
  45831. static AddSamplers(samplers: string[]): void;
  45832. /**
  45833. * Makes a duplicate of the current configuration into another one.
  45834. * @param sheenConfiguration define the config where to copy the info
  45835. */
  45836. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45837. /**
  45838. * Serializes this BRDF configuration.
  45839. * @returns - An object with the serialized config.
  45840. */
  45841. serialize(): any;
  45842. /**
  45843. * Parses a Sheen Configuration from a serialized object.
  45844. * @param source - Serialized object.
  45845. */
  45846. parse(source: any): void;
  45847. }
  45848. }
  45849. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45850. /** @hidden */
  45851. export var pbrFragmentDeclaration: {
  45852. name: string;
  45853. shader: string;
  45854. };
  45855. }
  45856. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45857. /** @hidden */
  45858. export var pbrUboDeclaration: {
  45859. name: string;
  45860. shader: string;
  45861. };
  45862. }
  45863. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45864. /** @hidden */
  45865. export var pbrFragmentExtraDeclaration: {
  45866. name: string;
  45867. shader: string;
  45868. };
  45869. }
  45870. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45871. /** @hidden */
  45872. export var pbrFragmentSamplersDeclaration: {
  45873. name: string;
  45874. shader: string;
  45875. };
  45876. }
  45877. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45878. /** @hidden */
  45879. export var pbrHelperFunctions: {
  45880. name: string;
  45881. shader: string;
  45882. };
  45883. }
  45884. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45885. /** @hidden */
  45886. export var harmonicsFunctions: {
  45887. name: string;
  45888. shader: string;
  45889. };
  45890. }
  45891. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45892. /** @hidden */
  45893. export var pbrDirectLightingSetupFunctions: {
  45894. name: string;
  45895. shader: string;
  45896. };
  45897. }
  45898. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45899. /** @hidden */
  45900. export var pbrDirectLightingFalloffFunctions: {
  45901. name: string;
  45902. shader: string;
  45903. };
  45904. }
  45905. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45906. /** @hidden */
  45907. export var pbrBRDFFunctions: {
  45908. name: string;
  45909. shader: string;
  45910. };
  45911. }
  45912. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45913. /** @hidden */
  45914. export var pbrDirectLightingFunctions: {
  45915. name: string;
  45916. shader: string;
  45917. };
  45918. }
  45919. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45920. /** @hidden */
  45921. export var pbrIBLFunctions: {
  45922. name: string;
  45923. shader: string;
  45924. };
  45925. }
  45926. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45927. /** @hidden */
  45928. export var pbrDebug: {
  45929. name: string;
  45930. shader: string;
  45931. };
  45932. }
  45933. declare module "babylonjs/Shaders/pbr.fragment" {
  45934. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45935. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45936. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45939. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45940. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45941. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45942. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45943. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45944. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45945. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45946. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45947. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45948. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45949. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45950. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45951. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45952. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45953. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45954. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45955. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45956. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45957. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45958. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45959. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45960. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45961. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45962. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45963. /** @hidden */
  45964. export var pbrPixelShader: {
  45965. name: string;
  45966. shader: string;
  45967. };
  45968. }
  45969. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45970. /** @hidden */
  45971. export var pbrVertexDeclaration: {
  45972. name: string;
  45973. shader: string;
  45974. };
  45975. }
  45976. declare module "babylonjs/Shaders/pbr.vertex" {
  45977. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45978. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45979. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45980. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45982. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45983. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45984. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45985. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45986. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45987. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45990. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45994. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45995. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45996. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45997. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45998. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45999. /** @hidden */
  46000. export var pbrVertexShader: {
  46001. name: string;
  46002. shader: string;
  46003. };
  46004. }
  46005. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46006. import { IAnimatable } from "babylonjs/Misc/tools";
  46007. import { Nullable } from "babylonjs/types";
  46008. import { Scene } from "babylonjs/scene";
  46009. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46012. import { Mesh } from "babylonjs/Meshes/mesh";
  46013. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46014. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46015. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46016. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46017. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46018. import { Material } from "babylonjs/Materials/material";
  46019. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46020. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46022. import "babylonjs/Shaders/pbr.fragment";
  46023. import "babylonjs/Shaders/pbr.vertex";
  46024. /**
  46025. * Manages the defines for the PBR Material.
  46026. * @hidden
  46027. */
  46028. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  46029. PBR: boolean;
  46030. MAINUV1: boolean;
  46031. MAINUV2: boolean;
  46032. UV1: boolean;
  46033. UV2: boolean;
  46034. ALBEDO: boolean;
  46035. ALBEDODIRECTUV: number;
  46036. VERTEXCOLOR: boolean;
  46037. AMBIENT: boolean;
  46038. AMBIENTDIRECTUV: number;
  46039. AMBIENTINGRAYSCALE: boolean;
  46040. OPACITY: boolean;
  46041. VERTEXALPHA: boolean;
  46042. OPACITYDIRECTUV: number;
  46043. OPACITYRGB: boolean;
  46044. ALPHATEST: boolean;
  46045. DEPTHPREPASS: boolean;
  46046. ALPHABLEND: boolean;
  46047. ALPHAFROMALBEDO: boolean;
  46048. ALPHATESTVALUE: string;
  46049. SPECULAROVERALPHA: boolean;
  46050. RADIANCEOVERALPHA: boolean;
  46051. ALPHAFRESNEL: boolean;
  46052. LINEARALPHAFRESNEL: boolean;
  46053. PREMULTIPLYALPHA: boolean;
  46054. EMISSIVE: boolean;
  46055. EMISSIVEDIRECTUV: number;
  46056. REFLECTIVITY: boolean;
  46057. REFLECTIVITYDIRECTUV: number;
  46058. SPECULARTERM: boolean;
  46059. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46060. MICROSURFACEAUTOMATIC: boolean;
  46061. LODBASEDMICROSFURACE: boolean;
  46062. MICROSURFACEMAP: boolean;
  46063. MICROSURFACEMAPDIRECTUV: number;
  46064. METALLICWORKFLOW: boolean;
  46065. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46066. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46067. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46068. AOSTOREINMETALMAPRED: boolean;
  46069. ENVIRONMENTBRDF: boolean;
  46070. ENVIRONMENTBRDF_RGBD: boolean;
  46071. NORMAL: boolean;
  46072. TANGENT: boolean;
  46073. BUMP: boolean;
  46074. BUMPDIRECTUV: number;
  46075. OBJECTSPACE_NORMALMAP: boolean;
  46076. PARALLAX: boolean;
  46077. PARALLAXOCCLUSION: boolean;
  46078. NORMALXYSCALE: boolean;
  46079. LIGHTMAP: boolean;
  46080. LIGHTMAPDIRECTUV: number;
  46081. USELIGHTMAPASSHADOWMAP: boolean;
  46082. GAMMALIGHTMAP: boolean;
  46083. REFLECTION: boolean;
  46084. REFLECTIONMAP_3D: boolean;
  46085. REFLECTIONMAP_SPHERICAL: boolean;
  46086. REFLECTIONMAP_PLANAR: boolean;
  46087. REFLECTIONMAP_CUBIC: boolean;
  46088. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46089. REFLECTIONMAP_PROJECTION: boolean;
  46090. REFLECTIONMAP_SKYBOX: boolean;
  46091. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46092. REFLECTIONMAP_EXPLICIT: boolean;
  46093. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46094. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46095. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46096. INVERTCUBICMAP: boolean;
  46097. USESPHERICALFROMREFLECTIONMAP: boolean;
  46098. USESPHERICALINVERTEX: boolean;
  46099. REFLECTIONMAP_OPPOSITEZ: boolean;
  46100. LODINREFLECTIONALPHA: boolean;
  46101. GAMMAREFLECTION: boolean;
  46102. RGBDREFLECTION: boolean;
  46103. RADIANCEOCCLUSION: boolean;
  46104. HORIZONOCCLUSION: boolean;
  46105. REFRACTION: boolean;
  46106. REFRACTIONMAP_3D: boolean;
  46107. REFRACTIONMAP_OPPOSITEZ: boolean;
  46108. LODINREFRACTIONALPHA: boolean;
  46109. GAMMAREFRACTION: boolean;
  46110. RGBDREFRACTION: boolean;
  46111. LINKREFRACTIONTOTRANSPARENCY: boolean;
  46112. INSTANCES: boolean;
  46113. NUM_BONE_INFLUENCERS: number;
  46114. BonesPerMesh: number;
  46115. BONETEXTURE: boolean;
  46116. NONUNIFORMSCALING: boolean;
  46117. MORPHTARGETS: boolean;
  46118. MORPHTARGETS_NORMAL: boolean;
  46119. MORPHTARGETS_TANGENT: boolean;
  46120. NUM_MORPH_INFLUENCERS: number;
  46121. IMAGEPROCESSING: boolean;
  46122. VIGNETTE: boolean;
  46123. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46124. VIGNETTEBLENDMODEOPAQUE: boolean;
  46125. TONEMAPPING: boolean;
  46126. TONEMAPPING_ACES: boolean;
  46127. CONTRAST: boolean;
  46128. COLORCURVES: boolean;
  46129. COLORGRADING: boolean;
  46130. COLORGRADING3D: boolean;
  46131. SAMPLER3DGREENDEPTH: boolean;
  46132. SAMPLER3DBGRMAP: boolean;
  46133. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46134. EXPOSURE: boolean;
  46135. MULTIVIEW: boolean;
  46136. USEPHYSICALLIGHTFALLOFF: boolean;
  46137. USEGLTFLIGHTFALLOFF: boolean;
  46138. TWOSIDEDLIGHTING: boolean;
  46139. SHADOWFLOAT: boolean;
  46140. CLIPPLANE: boolean;
  46141. CLIPPLANE2: boolean;
  46142. CLIPPLANE3: boolean;
  46143. CLIPPLANE4: boolean;
  46144. POINTSIZE: boolean;
  46145. FOG: boolean;
  46146. LOGARITHMICDEPTH: boolean;
  46147. FORCENORMALFORWARD: boolean;
  46148. SPECULARAA: boolean;
  46149. CLEARCOAT: boolean;
  46150. CLEARCOAT_DEFAULTIOR: boolean;
  46151. CLEARCOAT_TEXTURE: boolean;
  46152. CLEARCOAT_TEXTUREDIRECTUV: number;
  46153. CLEARCOAT_BUMP: boolean;
  46154. CLEARCOAT_BUMPDIRECTUV: number;
  46155. CLEARCOAT_TINT: boolean;
  46156. CLEARCOAT_TINT_TEXTURE: boolean;
  46157. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46158. ANISOTROPIC: boolean;
  46159. ANISOTROPIC_TEXTURE: boolean;
  46160. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46161. BRDF_V_HEIGHT_CORRELATED: boolean;
  46162. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46163. SHEEN: boolean;
  46164. SHEEN_TEXTURE: boolean;
  46165. SHEEN_TEXTUREDIRECTUV: number;
  46166. SHEEN_LINKWITHALBEDO: boolean;
  46167. UNLIT: boolean;
  46168. DEBUGMODE: number;
  46169. /**
  46170. * Initializes the PBR Material defines.
  46171. */
  46172. constructor();
  46173. /**
  46174. * Resets the PBR Material defines.
  46175. */
  46176. reset(): void;
  46177. }
  46178. /**
  46179. * The Physically based material base class of BJS.
  46180. *
  46181. * This offers the main features of a standard PBR material.
  46182. * For more information, please refer to the documentation :
  46183. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46184. */
  46185. export abstract class PBRBaseMaterial extends PushMaterial {
  46186. /**
  46187. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46188. */
  46189. static readonly PBRMATERIAL_OPAQUE: number;
  46190. /**
  46191. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46192. */
  46193. static readonly PBRMATERIAL_ALPHATEST: number;
  46194. /**
  46195. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46196. */
  46197. static readonly PBRMATERIAL_ALPHABLEND: number;
  46198. /**
  46199. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46200. * They are also discarded below the alpha cutoff threshold to improve performances.
  46201. */
  46202. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46203. /**
  46204. * Defines the default value of how much AO map is occluding the analytical lights
  46205. * (point spot...).
  46206. */
  46207. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46208. /**
  46209. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46210. */
  46211. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46212. /**
  46213. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46214. * to enhance interoperability with other engines.
  46215. */
  46216. static readonly LIGHTFALLOFF_GLTF: number;
  46217. /**
  46218. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46219. * to enhance interoperability with other materials.
  46220. */
  46221. static readonly LIGHTFALLOFF_STANDARD: number;
  46222. /**
  46223. * Intensity of the direct lights e.g. the four lights available in your scene.
  46224. * This impacts both the direct diffuse and specular highlights.
  46225. */
  46226. protected _directIntensity: number;
  46227. /**
  46228. * Intensity of the emissive part of the material.
  46229. * This helps controlling the emissive effect without modifying the emissive color.
  46230. */
  46231. protected _emissiveIntensity: number;
  46232. /**
  46233. * Intensity of the environment e.g. how much the environment will light the object
  46234. * either through harmonics for rough material or through the refelction for shiny ones.
  46235. */
  46236. protected _environmentIntensity: number;
  46237. /**
  46238. * This is a special control allowing the reduction of the specular highlights coming from the
  46239. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46240. */
  46241. protected _specularIntensity: number;
  46242. /**
  46243. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46244. */
  46245. private _lightingInfos;
  46246. /**
  46247. * Debug Control allowing disabling the bump map on this material.
  46248. */
  46249. protected _disableBumpMap: boolean;
  46250. /**
  46251. * AKA Diffuse Texture in standard nomenclature.
  46252. */
  46253. protected _albedoTexture: BaseTexture;
  46254. /**
  46255. * AKA Occlusion Texture in other nomenclature.
  46256. */
  46257. protected _ambientTexture: BaseTexture;
  46258. /**
  46259. * AKA Occlusion Texture Intensity in other nomenclature.
  46260. */
  46261. protected _ambientTextureStrength: number;
  46262. /**
  46263. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46264. * 1 means it completely occludes it
  46265. * 0 mean it has no impact
  46266. */
  46267. protected _ambientTextureImpactOnAnalyticalLights: number;
  46268. /**
  46269. * Stores the alpha values in a texture.
  46270. */
  46271. protected _opacityTexture: BaseTexture;
  46272. /**
  46273. * Stores the reflection values in a texture.
  46274. */
  46275. protected _reflectionTexture: BaseTexture;
  46276. /**
  46277. * Stores the refraction values in a texture.
  46278. */
  46279. protected _refractionTexture: BaseTexture;
  46280. /**
  46281. * Stores the emissive values in a texture.
  46282. */
  46283. protected _emissiveTexture: BaseTexture;
  46284. /**
  46285. * AKA Specular texture in other nomenclature.
  46286. */
  46287. protected _reflectivityTexture: BaseTexture;
  46288. /**
  46289. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46290. */
  46291. protected _metallicTexture: BaseTexture;
  46292. /**
  46293. * Specifies the metallic scalar of the metallic/roughness workflow.
  46294. * Can also be used to scale the metalness values of the metallic texture.
  46295. */
  46296. protected _metallic: Nullable<number>;
  46297. /**
  46298. * Specifies the roughness scalar of the metallic/roughness workflow.
  46299. * Can also be used to scale the roughness values of the metallic texture.
  46300. */
  46301. protected _roughness: Nullable<number>;
  46302. /**
  46303. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46304. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46305. */
  46306. protected _microSurfaceTexture: BaseTexture;
  46307. /**
  46308. * Stores surface normal data used to displace a mesh in a texture.
  46309. */
  46310. protected _bumpTexture: BaseTexture;
  46311. /**
  46312. * Stores the pre-calculated light information of a mesh in a texture.
  46313. */
  46314. protected _lightmapTexture: BaseTexture;
  46315. /**
  46316. * The color of a material in ambient lighting.
  46317. */
  46318. protected _ambientColor: Color3;
  46319. /**
  46320. * AKA Diffuse Color in other nomenclature.
  46321. */
  46322. protected _albedoColor: Color3;
  46323. /**
  46324. * AKA Specular Color in other nomenclature.
  46325. */
  46326. protected _reflectivityColor: Color3;
  46327. /**
  46328. * The color applied when light is reflected from a material.
  46329. */
  46330. protected _reflectionColor: Color3;
  46331. /**
  46332. * The color applied when light is emitted from a material.
  46333. */
  46334. protected _emissiveColor: Color3;
  46335. /**
  46336. * AKA Glossiness in other nomenclature.
  46337. */
  46338. protected _microSurface: number;
  46339. /**
  46340. * source material index of refraction (IOR)' / 'destination material IOR.
  46341. */
  46342. protected _indexOfRefraction: number;
  46343. /**
  46344. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46345. */
  46346. protected _invertRefractionY: boolean;
  46347. /**
  46348. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46349. * Materials half opaque for instance using refraction could benefit from this control.
  46350. */
  46351. protected _linkRefractionWithTransparency: boolean;
  46352. /**
  46353. * Specifies that the material will use the light map as a show map.
  46354. */
  46355. protected _useLightmapAsShadowmap: boolean;
  46356. /**
  46357. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46358. * makes the reflect vector face the model (under horizon).
  46359. */
  46360. protected _useHorizonOcclusion: boolean;
  46361. /**
  46362. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46363. * too much the area relying on ambient texture to define their ambient occlusion.
  46364. */
  46365. protected _useRadianceOcclusion: boolean;
  46366. /**
  46367. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46368. */
  46369. protected _useAlphaFromAlbedoTexture: boolean;
  46370. /**
  46371. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46372. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46373. */
  46374. protected _useSpecularOverAlpha: boolean;
  46375. /**
  46376. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46377. */
  46378. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46379. /**
  46380. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46381. */
  46382. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46383. /**
  46384. * Specifies if the metallic texture contains the roughness information in its green channel.
  46385. */
  46386. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46387. /**
  46388. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46389. */
  46390. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46391. /**
  46392. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46393. */
  46394. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46395. /**
  46396. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46397. */
  46398. protected _useAmbientInGrayScale: boolean;
  46399. /**
  46400. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46401. * The material will try to infer what glossiness each pixel should be.
  46402. */
  46403. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46404. /**
  46405. * Defines the falloff type used in this material.
  46406. * It by default is Physical.
  46407. */
  46408. protected _lightFalloff: number;
  46409. /**
  46410. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46411. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46412. */
  46413. protected _useRadianceOverAlpha: boolean;
  46414. /**
  46415. * Allows using an object space normal map (instead of tangent space).
  46416. */
  46417. protected _useObjectSpaceNormalMap: boolean;
  46418. /**
  46419. * Allows using the bump map in parallax mode.
  46420. */
  46421. protected _useParallax: boolean;
  46422. /**
  46423. * Allows using the bump map in parallax occlusion mode.
  46424. */
  46425. protected _useParallaxOcclusion: boolean;
  46426. /**
  46427. * Controls the scale bias of the parallax mode.
  46428. */
  46429. protected _parallaxScaleBias: number;
  46430. /**
  46431. * If sets to true, disables all the lights affecting the material.
  46432. */
  46433. protected _disableLighting: boolean;
  46434. /**
  46435. * Number of Simultaneous lights allowed on the material.
  46436. */
  46437. protected _maxSimultaneousLights: number;
  46438. /**
  46439. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46440. */
  46441. protected _invertNormalMapX: boolean;
  46442. /**
  46443. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46444. */
  46445. protected _invertNormalMapY: boolean;
  46446. /**
  46447. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46448. */
  46449. protected _twoSidedLighting: boolean;
  46450. /**
  46451. * Defines the alpha limits in alpha test mode.
  46452. */
  46453. protected _alphaCutOff: number;
  46454. /**
  46455. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46456. */
  46457. protected _forceAlphaTest: boolean;
  46458. /**
  46459. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46460. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46461. */
  46462. protected _useAlphaFresnel: boolean;
  46463. /**
  46464. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46465. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46466. */
  46467. protected _useLinearAlphaFresnel: boolean;
  46468. /**
  46469. * The transparency mode of the material.
  46470. */
  46471. protected _transparencyMode: Nullable<number>;
  46472. /**
  46473. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46474. * from cos thetav and roughness:
  46475. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46476. */
  46477. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46478. /**
  46479. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46480. */
  46481. protected _forceIrradianceInFragment: boolean;
  46482. /**
  46483. * Force normal to face away from face.
  46484. */
  46485. protected _forceNormalForward: boolean;
  46486. /**
  46487. * Enables specular anti aliasing in the PBR shader.
  46488. * It will both interacts on the Geometry for analytical and IBL lighting.
  46489. * It also prefilter the roughness map based on the bump values.
  46490. */
  46491. protected _enableSpecularAntiAliasing: boolean;
  46492. /**
  46493. * Default configuration related to image processing available in the PBR Material.
  46494. */
  46495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46496. /**
  46497. * Keep track of the image processing observer to allow dispose and replace.
  46498. */
  46499. private _imageProcessingObserver;
  46500. /**
  46501. * Attaches a new image processing configuration to the PBR Material.
  46502. * @param configuration
  46503. */
  46504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46505. /**
  46506. * Stores the available render targets.
  46507. */
  46508. private _renderTargets;
  46509. /**
  46510. * Sets the global ambient color for the material used in lighting calculations.
  46511. */
  46512. private _globalAmbientColor;
  46513. /**
  46514. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46515. */
  46516. private _useLogarithmicDepth;
  46517. /**
  46518. * If set to true, no lighting calculations will be applied.
  46519. */
  46520. private _unlit;
  46521. private _debugMode;
  46522. /**
  46523. * @hidden
  46524. * This is reserved for the inspector.
  46525. * Defines the material debug mode.
  46526. * It helps seeing only some components of the material while troubleshooting.
  46527. */
  46528. debugMode: number;
  46529. /**
  46530. * @hidden
  46531. * This is reserved for the inspector.
  46532. * Specify from where on screen the debug mode should start.
  46533. * The value goes from -1 (full screen) to 1 (not visible)
  46534. * It helps with side by side comparison against the final render
  46535. * This defaults to -1
  46536. */
  46537. private debugLimit;
  46538. /**
  46539. * @hidden
  46540. * This is reserved for the inspector.
  46541. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46542. * You can use the factor to better multiply the final value.
  46543. */
  46544. private debugFactor;
  46545. /**
  46546. * Defines the clear coat layer parameters for the material.
  46547. */
  46548. readonly clearCoat: PBRClearCoatConfiguration;
  46549. /**
  46550. * Defines the anisotropic parameters for the material.
  46551. */
  46552. readonly anisotropy: PBRAnisotropicConfiguration;
  46553. /**
  46554. * Defines the BRDF parameters for the material.
  46555. */
  46556. readonly brdf: PBRBRDFConfiguration;
  46557. /**
  46558. * Defines the Sheen parameters for the material.
  46559. */
  46560. readonly sheen: PBRSheenConfiguration;
  46561. /**
  46562. * Custom callback helping to override the default shader used in the material.
  46563. */
  46564. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46565. /**
  46566. * Instantiates a new PBRMaterial instance.
  46567. *
  46568. * @param name The material name
  46569. * @param scene The scene the material will be use in.
  46570. */
  46571. constructor(name: string, scene: Scene);
  46572. /**
  46573. * Gets a boolean indicating that current material needs to register RTT
  46574. */
  46575. readonly hasRenderTargetTextures: boolean;
  46576. /**
  46577. * Gets the name of the material class.
  46578. */
  46579. getClassName(): string;
  46580. /**
  46581. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46582. */
  46583. /**
  46584. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46585. */
  46586. useLogarithmicDepth: boolean;
  46587. /**
  46588. * Gets the current transparency mode.
  46589. */
  46590. /**
  46591. * Sets the transparency mode of the material.
  46592. *
  46593. * | Value | Type | Description |
  46594. * | ----- | ----------------------------------- | ----------- |
  46595. * | 0 | OPAQUE | |
  46596. * | 1 | ALPHATEST | |
  46597. * | 2 | ALPHABLEND | |
  46598. * | 3 | ALPHATESTANDBLEND | |
  46599. *
  46600. */
  46601. transparencyMode: Nullable<number>;
  46602. /**
  46603. * Returns true if alpha blending should be disabled.
  46604. */
  46605. private readonly _disableAlphaBlending;
  46606. /**
  46607. * Specifies whether or not this material should be rendered in alpha blend mode.
  46608. */
  46609. needAlphaBlending(): boolean;
  46610. /**
  46611. * Specifies if the mesh will require alpha blending.
  46612. * @param mesh - BJS mesh.
  46613. */
  46614. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46615. /**
  46616. * Specifies whether or not this material should be rendered in alpha test mode.
  46617. */
  46618. needAlphaTesting(): boolean;
  46619. /**
  46620. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46621. */
  46622. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46623. /**
  46624. * Gets the texture used for the alpha test.
  46625. */
  46626. getAlphaTestTexture(): BaseTexture;
  46627. /**
  46628. * Specifies that the submesh is ready to be used.
  46629. * @param mesh - BJS mesh.
  46630. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46631. * @param useInstances - Specifies that instances should be used.
  46632. * @returns - boolean indicating that the submesh is ready or not.
  46633. */
  46634. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46635. /**
  46636. * Specifies if the material uses metallic roughness workflow.
  46637. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46638. */
  46639. isMetallicWorkflow(): boolean;
  46640. private _prepareEffect;
  46641. private _prepareDefines;
  46642. /**
  46643. * Force shader compilation
  46644. */
  46645. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46646. clipPlane: boolean;
  46647. }>): void;
  46648. /**
  46649. * Initializes the uniform buffer layout for the shader.
  46650. */
  46651. buildUniformLayout(): void;
  46652. /**
  46653. * Unbinds the textures.
  46654. */
  46655. unbind(): void;
  46656. /**
  46657. * Binds the submesh data.
  46658. * @param world - The world matrix.
  46659. * @param mesh - The BJS mesh.
  46660. * @param subMesh - A submesh of the BJS mesh.
  46661. */
  46662. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46663. /**
  46664. * Returns the animatable textures.
  46665. * @returns - Array of animatable textures.
  46666. */
  46667. getAnimatables(): IAnimatable[];
  46668. /**
  46669. * Returns the texture used for reflections.
  46670. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46671. */
  46672. private _getReflectionTexture;
  46673. /**
  46674. * Returns the texture used for refraction or null if none is used.
  46675. * @returns - Refection texture if present. If no refraction texture and refraction
  46676. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46677. */
  46678. private _getRefractionTexture;
  46679. /**
  46680. * Returns an array of the actively used textures.
  46681. * @returns - Array of BaseTextures
  46682. */
  46683. getActiveTextures(): BaseTexture[];
  46684. /**
  46685. * Checks to see if a texture is used in the material.
  46686. * @param texture - Base texture to use.
  46687. * @returns - Boolean specifying if a texture is used in the material.
  46688. */
  46689. hasTexture(texture: BaseTexture): boolean;
  46690. /**
  46691. * Disposes the resources of the material.
  46692. * @param forceDisposeEffect - Forces the disposal of effects.
  46693. * @param forceDisposeTextures - Forces the disposal of all textures.
  46694. */
  46695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46696. }
  46697. }
  46698. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46699. import { Nullable } from "babylonjs/types";
  46700. import { Scene } from "babylonjs/scene";
  46701. import { Color3 } from "babylonjs/Maths/math";
  46702. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46703. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46705. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46706. /**
  46707. * The Physically based material of BJS.
  46708. *
  46709. * This offers the main features of a standard PBR material.
  46710. * For more information, please refer to the documentation :
  46711. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46712. */
  46713. export class PBRMaterial extends PBRBaseMaterial {
  46714. /**
  46715. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46716. */
  46717. static readonly PBRMATERIAL_OPAQUE: number;
  46718. /**
  46719. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46720. */
  46721. static readonly PBRMATERIAL_ALPHATEST: number;
  46722. /**
  46723. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46724. */
  46725. static readonly PBRMATERIAL_ALPHABLEND: number;
  46726. /**
  46727. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46728. * They are also discarded below the alpha cutoff threshold to improve performances.
  46729. */
  46730. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46731. /**
  46732. * Defines the default value of how much AO map is occluding the analytical lights
  46733. * (point spot...).
  46734. */
  46735. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46736. /**
  46737. * Intensity of the direct lights e.g. the four lights available in your scene.
  46738. * This impacts both the direct diffuse and specular highlights.
  46739. */
  46740. directIntensity: number;
  46741. /**
  46742. * Intensity of the emissive part of the material.
  46743. * This helps controlling the emissive effect without modifying the emissive color.
  46744. */
  46745. emissiveIntensity: number;
  46746. /**
  46747. * Intensity of the environment e.g. how much the environment will light the object
  46748. * either through harmonics for rough material or through the refelction for shiny ones.
  46749. */
  46750. environmentIntensity: number;
  46751. /**
  46752. * This is a special control allowing the reduction of the specular highlights coming from the
  46753. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46754. */
  46755. specularIntensity: number;
  46756. /**
  46757. * Debug Control allowing disabling the bump map on this material.
  46758. */
  46759. disableBumpMap: boolean;
  46760. /**
  46761. * AKA Diffuse Texture in standard nomenclature.
  46762. */
  46763. albedoTexture: BaseTexture;
  46764. /**
  46765. * AKA Occlusion Texture in other nomenclature.
  46766. */
  46767. ambientTexture: BaseTexture;
  46768. /**
  46769. * AKA Occlusion Texture Intensity in other nomenclature.
  46770. */
  46771. ambientTextureStrength: number;
  46772. /**
  46773. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46774. * 1 means it completely occludes it
  46775. * 0 mean it has no impact
  46776. */
  46777. ambientTextureImpactOnAnalyticalLights: number;
  46778. /**
  46779. * Stores the alpha values in a texture.
  46780. */
  46781. opacityTexture: BaseTexture;
  46782. /**
  46783. * Stores the reflection values in a texture.
  46784. */
  46785. reflectionTexture: Nullable<BaseTexture>;
  46786. /**
  46787. * Stores the emissive values in a texture.
  46788. */
  46789. emissiveTexture: BaseTexture;
  46790. /**
  46791. * AKA Specular texture in other nomenclature.
  46792. */
  46793. reflectivityTexture: BaseTexture;
  46794. /**
  46795. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46796. */
  46797. metallicTexture: BaseTexture;
  46798. /**
  46799. * Specifies the metallic scalar of the metallic/roughness workflow.
  46800. * Can also be used to scale the metalness values of the metallic texture.
  46801. */
  46802. metallic: Nullable<number>;
  46803. /**
  46804. * Specifies the roughness scalar of the metallic/roughness workflow.
  46805. * Can also be used to scale the roughness values of the metallic texture.
  46806. */
  46807. roughness: Nullable<number>;
  46808. /**
  46809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46811. */
  46812. microSurfaceTexture: BaseTexture;
  46813. /**
  46814. * Stores surface normal data used to displace a mesh in a texture.
  46815. */
  46816. bumpTexture: BaseTexture;
  46817. /**
  46818. * Stores the pre-calculated light information of a mesh in a texture.
  46819. */
  46820. lightmapTexture: BaseTexture;
  46821. /**
  46822. * Stores the refracted light information in a texture.
  46823. */
  46824. refractionTexture: BaseTexture;
  46825. /**
  46826. * The color of a material in ambient lighting.
  46827. */
  46828. ambientColor: Color3;
  46829. /**
  46830. * AKA Diffuse Color in other nomenclature.
  46831. */
  46832. albedoColor: Color3;
  46833. /**
  46834. * AKA Specular Color in other nomenclature.
  46835. */
  46836. reflectivityColor: Color3;
  46837. /**
  46838. * The color reflected from the material.
  46839. */
  46840. reflectionColor: Color3;
  46841. /**
  46842. * The color emitted from the material.
  46843. */
  46844. emissiveColor: Color3;
  46845. /**
  46846. * AKA Glossiness in other nomenclature.
  46847. */
  46848. microSurface: number;
  46849. /**
  46850. * source material index of refraction (IOR)' / 'destination material IOR.
  46851. */
  46852. indexOfRefraction: number;
  46853. /**
  46854. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46855. */
  46856. invertRefractionY: boolean;
  46857. /**
  46858. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46859. * Materials half opaque for instance using refraction could benefit from this control.
  46860. */
  46861. linkRefractionWithTransparency: boolean;
  46862. /**
  46863. * If true, the light map contains occlusion information instead of lighting info.
  46864. */
  46865. useLightmapAsShadowmap: boolean;
  46866. /**
  46867. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46868. */
  46869. useAlphaFromAlbedoTexture: boolean;
  46870. /**
  46871. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46872. */
  46873. forceAlphaTest: boolean;
  46874. /**
  46875. * Defines the alpha limits in alpha test mode.
  46876. */
  46877. alphaCutOff: number;
  46878. /**
  46879. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46880. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46881. */
  46882. useSpecularOverAlpha: boolean;
  46883. /**
  46884. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46885. */
  46886. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46887. /**
  46888. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46889. */
  46890. useRoughnessFromMetallicTextureAlpha: boolean;
  46891. /**
  46892. * Specifies if the metallic texture contains the roughness information in its green channel.
  46893. */
  46894. useRoughnessFromMetallicTextureGreen: boolean;
  46895. /**
  46896. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46897. */
  46898. useMetallnessFromMetallicTextureBlue: boolean;
  46899. /**
  46900. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46901. */
  46902. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46903. /**
  46904. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46905. */
  46906. useAmbientInGrayScale: boolean;
  46907. /**
  46908. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46909. * The material will try to infer what glossiness each pixel should be.
  46910. */
  46911. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46912. /**
  46913. * BJS is using an harcoded light falloff based on a manually sets up range.
  46914. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46915. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46916. */
  46917. /**
  46918. * BJS is using an harcoded light falloff based on a manually sets up range.
  46919. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46920. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46921. */
  46922. usePhysicalLightFalloff: boolean;
  46923. /**
  46924. * In order to support the falloff compatibility with gltf, a special mode has been added
  46925. * to reproduce the gltf light falloff.
  46926. */
  46927. /**
  46928. * In order to support the falloff compatibility with gltf, a special mode has been added
  46929. * to reproduce the gltf light falloff.
  46930. */
  46931. useGLTFLightFalloff: boolean;
  46932. /**
  46933. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46934. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46935. */
  46936. useRadianceOverAlpha: boolean;
  46937. /**
  46938. * Allows using an object space normal map (instead of tangent space).
  46939. */
  46940. useObjectSpaceNormalMap: boolean;
  46941. /**
  46942. * Allows using the bump map in parallax mode.
  46943. */
  46944. useParallax: boolean;
  46945. /**
  46946. * Allows using the bump map in parallax occlusion mode.
  46947. */
  46948. useParallaxOcclusion: boolean;
  46949. /**
  46950. * Controls the scale bias of the parallax mode.
  46951. */
  46952. parallaxScaleBias: number;
  46953. /**
  46954. * If sets to true, disables all the lights affecting the material.
  46955. */
  46956. disableLighting: boolean;
  46957. /**
  46958. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46959. */
  46960. forceIrradianceInFragment: boolean;
  46961. /**
  46962. * Number of Simultaneous lights allowed on the material.
  46963. */
  46964. maxSimultaneousLights: number;
  46965. /**
  46966. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46967. */
  46968. invertNormalMapX: boolean;
  46969. /**
  46970. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46971. */
  46972. invertNormalMapY: boolean;
  46973. /**
  46974. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46975. */
  46976. twoSidedLighting: boolean;
  46977. /**
  46978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46979. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46980. */
  46981. useAlphaFresnel: boolean;
  46982. /**
  46983. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46984. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46985. */
  46986. useLinearAlphaFresnel: boolean;
  46987. /**
  46988. * Let user defines the brdf lookup texture used for IBL.
  46989. * A default 8bit version is embedded but you could point at :
  46990. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46991. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46992. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46993. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46994. */
  46995. environmentBRDFTexture: Nullable<BaseTexture>;
  46996. /**
  46997. * Force normal to face away from face.
  46998. */
  46999. forceNormalForward: boolean;
  47000. /**
  47001. * Enables specular anti aliasing in the PBR shader.
  47002. * It will both interacts on the Geometry for analytical and IBL lighting.
  47003. * It also prefilter the roughness map based on the bump values.
  47004. */
  47005. enableSpecularAntiAliasing: boolean;
  47006. /**
  47007. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47008. * makes the reflect vector face the model (under horizon).
  47009. */
  47010. useHorizonOcclusion: boolean;
  47011. /**
  47012. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47013. * too much the area relying on ambient texture to define their ambient occlusion.
  47014. */
  47015. useRadianceOcclusion: boolean;
  47016. /**
  47017. * If set to true, no lighting calculations will be applied.
  47018. */
  47019. unlit: boolean;
  47020. /**
  47021. * Gets the image processing configuration used either in this material.
  47022. */
  47023. /**
  47024. * Sets the Default image processing configuration used either in the this material.
  47025. *
  47026. * If sets to null, the scene one is in use.
  47027. */
  47028. imageProcessingConfiguration: ImageProcessingConfiguration;
  47029. /**
  47030. * Gets wether the color curves effect is enabled.
  47031. */
  47032. /**
  47033. * Sets wether the color curves effect is enabled.
  47034. */
  47035. cameraColorCurvesEnabled: boolean;
  47036. /**
  47037. * Gets wether the color grading effect is enabled.
  47038. */
  47039. /**
  47040. * Gets wether the color grading effect is enabled.
  47041. */
  47042. cameraColorGradingEnabled: boolean;
  47043. /**
  47044. * Gets wether tonemapping is enabled or not.
  47045. */
  47046. /**
  47047. * Sets wether tonemapping is enabled or not
  47048. */
  47049. cameraToneMappingEnabled: boolean;
  47050. /**
  47051. * The camera exposure used on this material.
  47052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47053. * This corresponds to a photographic exposure.
  47054. */
  47055. /**
  47056. * The camera exposure used on this material.
  47057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47058. * This corresponds to a photographic exposure.
  47059. */
  47060. cameraExposure: number;
  47061. /**
  47062. * Gets The camera contrast used on this material.
  47063. */
  47064. /**
  47065. * Sets The camera contrast used on this material.
  47066. */
  47067. cameraContrast: number;
  47068. /**
  47069. * Gets the Color Grading 2D Lookup Texture.
  47070. */
  47071. /**
  47072. * Sets the Color Grading 2D Lookup Texture.
  47073. */
  47074. cameraColorGradingTexture: Nullable<BaseTexture>;
  47075. /**
  47076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47078. * 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;
  47079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47080. */
  47081. /**
  47082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47084. * 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;
  47085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47086. */
  47087. cameraColorCurves: Nullable<ColorCurves>;
  47088. /**
  47089. * Instantiates a new PBRMaterial instance.
  47090. *
  47091. * @param name The material name
  47092. * @param scene The scene the material will be use in.
  47093. */
  47094. constructor(name: string, scene: Scene);
  47095. /**
  47096. * Returns the name of this material class.
  47097. */
  47098. getClassName(): string;
  47099. /**
  47100. * Makes a duplicate of the current material.
  47101. * @param name - name to use for the new material.
  47102. */
  47103. clone(name: string): PBRMaterial;
  47104. /**
  47105. * Serializes this PBR Material.
  47106. * @returns - An object with the serialized material.
  47107. */
  47108. serialize(): any;
  47109. /**
  47110. * Parses a PBR Material from a serialized object.
  47111. * @param source - Serialized object.
  47112. * @param scene - BJS scene instance.
  47113. * @param rootUrl - url for the scene object
  47114. * @returns - PBRMaterial
  47115. */
  47116. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47117. }
  47118. }
  47119. declare module "babylonjs/Misc/dds" {
  47120. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47121. import { Engine } from "babylonjs/Engines/engine";
  47122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47123. import { Nullable } from "babylonjs/types";
  47124. import { Scene } from "babylonjs/scene";
  47125. /**
  47126. * Direct draw surface info
  47127. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47128. */
  47129. export interface DDSInfo {
  47130. /**
  47131. * Width of the texture
  47132. */
  47133. width: number;
  47134. /**
  47135. * Width of the texture
  47136. */
  47137. height: number;
  47138. /**
  47139. * Number of Mipmaps for the texture
  47140. * @see https://en.wikipedia.org/wiki/Mipmap
  47141. */
  47142. mipmapCount: number;
  47143. /**
  47144. * If the textures format is a known fourCC format
  47145. * @see https://www.fourcc.org/
  47146. */
  47147. isFourCC: boolean;
  47148. /**
  47149. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47150. */
  47151. isRGB: boolean;
  47152. /**
  47153. * If the texture is a lumincance format
  47154. */
  47155. isLuminance: boolean;
  47156. /**
  47157. * If this is a cube texture
  47158. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47159. */
  47160. isCube: boolean;
  47161. /**
  47162. * If the texture is a compressed format eg. FOURCC_DXT1
  47163. */
  47164. isCompressed: boolean;
  47165. /**
  47166. * The dxgiFormat of the texture
  47167. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47168. */
  47169. dxgiFormat: number;
  47170. /**
  47171. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47172. */
  47173. textureType: number;
  47174. /**
  47175. * Sphericle polynomial created for the dds texture
  47176. */
  47177. sphericalPolynomial?: SphericalPolynomial;
  47178. }
  47179. /**
  47180. * Class used to provide DDS decompression tools
  47181. */
  47182. export class DDSTools {
  47183. /**
  47184. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47185. */
  47186. static StoreLODInAlphaChannel: boolean;
  47187. /**
  47188. * Gets DDS information from an array buffer
  47189. * @param arrayBuffer defines the array buffer to read data from
  47190. * @returns the DDS information
  47191. */
  47192. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47193. private static _FloatView;
  47194. private static _Int32View;
  47195. private static _ToHalfFloat;
  47196. private static _FromHalfFloat;
  47197. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47198. private static _GetHalfFloatRGBAArrayBuffer;
  47199. private static _GetFloatRGBAArrayBuffer;
  47200. private static _GetFloatAsUIntRGBAArrayBuffer;
  47201. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47202. private static _GetRGBAArrayBuffer;
  47203. private static _ExtractLongWordOrder;
  47204. private static _GetRGBArrayBuffer;
  47205. private static _GetLuminanceArrayBuffer;
  47206. /**
  47207. * Uploads DDS Levels to a Babylon Texture
  47208. * @hidden
  47209. */
  47210. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47211. }
  47212. module "babylonjs/Engines/engine" {
  47213. interface Engine {
  47214. /**
  47215. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47216. * @param rootUrl defines the url where the file to load is located
  47217. * @param scene defines the current scene
  47218. * @param lodScale defines scale to apply to the mip map selection
  47219. * @param lodOffset defines offset to apply to the mip map selection
  47220. * @param onLoad defines an optional callback raised when the texture is loaded
  47221. * @param onError defines an optional callback raised if there is an issue to load the texture
  47222. * @param format defines the format of the data
  47223. * @param forcedExtension defines the extension to use to pick the right loader
  47224. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47225. * @returns the cube texture as an InternalTexture
  47226. */
  47227. 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;
  47228. }
  47229. }
  47230. }
  47231. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47232. import { Nullable } from "babylonjs/types";
  47233. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47234. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47235. /**
  47236. * Implementation of the DDS Texture Loader.
  47237. * @hidden
  47238. */
  47239. export class _DDSTextureLoader implements IInternalTextureLoader {
  47240. /**
  47241. * Defines wether the loader supports cascade loading the different faces.
  47242. */
  47243. readonly supportCascades: boolean;
  47244. /**
  47245. * This returns if the loader support the current file information.
  47246. * @param extension defines the file extension of the file being loaded
  47247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47248. * @param fallback defines the fallback internal texture if any
  47249. * @param isBase64 defines whether the texture is encoded as a base64
  47250. * @param isBuffer defines whether the texture data are stored as a buffer
  47251. * @returns true if the loader can load the specified file
  47252. */
  47253. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47254. /**
  47255. * Transform the url before loading if required.
  47256. * @param rootUrl the url of the texture
  47257. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47258. * @returns the transformed texture
  47259. */
  47260. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47261. /**
  47262. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47263. * @param rootUrl the url of the texture
  47264. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47265. * @returns the fallback texture
  47266. */
  47267. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47268. /**
  47269. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47270. * @param data contains the texture data
  47271. * @param texture defines the BabylonJS internal texture
  47272. * @param createPolynomials will be true if polynomials have been requested
  47273. * @param onLoad defines the callback to trigger once the texture is ready
  47274. * @param onError defines the callback to trigger in case of error
  47275. */
  47276. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47277. /**
  47278. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47279. * @param data contains the texture data
  47280. * @param texture defines the BabylonJS internal texture
  47281. * @param callback defines the method to call once ready to upload
  47282. */
  47283. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47284. }
  47285. }
  47286. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47287. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47288. /** @hidden */
  47289. export var rgbdEncodePixelShader: {
  47290. name: string;
  47291. shader: string;
  47292. };
  47293. }
  47294. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47295. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47296. /** @hidden */
  47297. export var rgbdDecodePixelShader: {
  47298. name: string;
  47299. shader: string;
  47300. };
  47301. }
  47302. declare module "babylonjs/Misc/environmentTextureTools" {
  47303. import { Nullable } from "babylonjs/types";
  47304. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47305. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47306. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47307. import "babylonjs/Shaders/rgbdEncode.fragment";
  47308. import "babylonjs/Shaders/rgbdDecode.fragment";
  47309. /**
  47310. * Raw texture data and descriptor sufficient for WebGL texture upload
  47311. */
  47312. export interface EnvironmentTextureInfo {
  47313. /**
  47314. * Version of the environment map
  47315. */
  47316. version: number;
  47317. /**
  47318. * Width of image
  47319. */
  47320. width: number;
  47321. /**
  47322. * Irradiance information stored in the file.
  47323. */
  47324. irradiance: any;
  47325. /**
  47326. * Specular information stored in the file.
  47327. */
  47328. specular: any;
  47329. }
  47330. /**
  47331. * Sets of helpers addressing the serialization and deserialization of environment texture
  47332. * stored in a BabylonJS env file.
  47333. * Those files are usually stored as .env files.
  47334. */
  47335. export class EnvironmentTextureTools {
  47336. /**
  47337. * Magic number identifying the env file.
  47338. */
  47339. private static _MagicBytes;
  47340. /**
  47341. * Gets the environment info from an env file.
  47342. * @param data The array buffer containing the .env bytes.
  47343. * @returns the environment file info (the json header) if successfully parsed.
  47344. */
  47345. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47346. /**
  47347. * Creates an environment texture from a loaded cube texture.
  47348. * @param texture defines the cube texture to convert in env file
  47349. * @return a promise containing the environment data if succesfull.
  47350. */
  47351. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47352. /**
  47353. * Creates a JSON representation of the spherical data.
  47354. * @param texture defines the texture containing the polynomials
  47355. * @return the JSON representation of the spherical info
  47356. */
  47357. private static _CreateEnvTextureIrradiance;
  47358. /**
  47359. * Uploads the texture info contained in the env file to the GPU.
  47360. * @param texture defines the internal texture to upload to
  47361. * @param arrayBuffer defines the buffer cotaining the data to load
  47362. * @param info defines the texture info retrieved through the GetEnvInfo method
  47363. * @returns a promise
  47364. */
  47365. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47366. /**
  47367. * Uploads the levels of image data to the GPU.
  47368. * @param texture defines the internal texture to upload to
  47369. * @param imageData defines the array buffer views of image data [mipmap][face]
  47370. * @returns a promise
  47371. */
  47372. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47373. /**
  47374. * Uploads spherical polynomials information to the texture.
  47375. * @param texture defines the texture we are trying to upload the information to
  47376. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47377. */
  47378. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47379. /** @hidden */
  47380. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47381. }
  47382. }
  47383. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47384. import { Nullable } from "babylonjs/types";
  47385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47386. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47387. /**
  47388. * Implementation of the ENV Texture Loader.
  47389. * @hidden
  47390. */
  47391. export class _ENVTextureLoader implements IInternalTextureLoader {
  47392. /**
  47393. * Defines wether the loader supports cascade loading the different faces.
  47394. */
  47395. readonly supportCascades: boolean;
  47396. /**
  47397. * This returns if the loader support the current file information.
  47398. * @param extension defines the file extension of the file being loaded
  47399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47400. * @param fallback defines the fallback internal texture if any
  47401. * @param isBase64 defines whether the texture is encoded as a base64
  47402. * @param isBuffer defines whether the texture data are stored as a buffer
  47403. * @returns true if the loader can load the specified file
  47404. */
  47405. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47406. /**
  47407. * Transform the url before loading if required.
  47408. * @param rootUrl the url of the texture
  47409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47410. * @returns the transformed texture
  47411. */
  47412. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47413. /**
  47414. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47415. * @param rootUrl the url of the texture
  47416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47417. * @returns the fallback texture
  47418. */
  47419. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47420. /**
  47421. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47422. * @param data contains the texture data
  47423. * @param texture defines the BabylonJS internal texture
  47424. * @param createPolynomials will be true if polynomials have been requested
  47425. * @param onLoad defines the callback to trigger once the texture is ready
  47426. * @param onError defines the callback to trigger in case of error
  47427. */
  47428. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47429. /**
  47430. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47431. * @param data contains the texture data
  47432. * @param texture defines the BabylonJS internal texture
  47433. * @param callback defines the method to call once ready to upload
  47434. */
  47435. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47436. }
  47437. }
  47438. declare module "babylonjs/Misc/khronosTextureContainer" {
  47439. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47440. /**
  47441. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47442. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47443. */
  47444. export class KhronosTextureContainer {
  47445. /** contents of the KTX container file */
  47446. arrayBuffer: any;
  47447. private static HEADER_LEN;
  47448. private static COMPRESSED_2D;
  47449. private static COMPRESSED_3D;
  47450. private static TEX_2D;
  47451. private static TEX_3D;
  47452. /**
  47453. * Gets the openGL type
  47454. */
  47455. glType: number;
  47456. /**
  47457. * Gets the openGL type size
  47458. */
  47459. glTypeSize: number;
  47460. /**
  47461. * Gets the openGL format
  47462. */
  47463. glFormat: number;
  47464. /**
  47465. * Gets the openGL internal format
  47466. */
  47467. glInternalFormat: number;
  47468. /**
  47469. * Gets the base internal format
  47470. */
  47471. glBaseInternalFormat: number;
  47472. /**
  47473. * Gets image width in pixel
  47474. */
  47475. pixelWidth: number;
  47476. /**
  47477. * Gets image height in pixel
  47478. */
  47479. pixelHeight: number;
  47480. /**
  47481. * Gets image depth in pixels
  47482. */
  47483. pixelDepth: number;
  47484. /**
  47485. * Gets the number of array elements
  47486. */
  47487. numberOfArrayElements: number;
  47488. /**
  47489. * Gets the number of faces
  47490. */
  47491. numberOfFaces: number;
  47492. /**
  47493. * Gets the number of mipmap levels
  47494. */
  47495. numberOfMipmapLevels: number;
  47496. /**
  47497. * Gets the bytes of key value data
  47498. */
  47499. bytesOfKeyValueData: number;
  47500. /**
  47501. * Gets the load type
  47502. */
  47503. loadType: number;
  47504. /**
  47505. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47506. */
  47507. isInvalid: boolean;
  47508. /**
  47509. * Creates a new KhronosTextureContainer
  47510. * @param arrayBuffer contents of the KTX container file
  47511. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47512. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47513. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47514. */
  47515. constructor(
  47516. /** contents of the KTX container file */
  47517. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47518. /**
  47519. * Uploads KTX content to a Babylon Texture.
  47520. * It is assumed that the texture has already been created & is currently bound
  47521. * @hidden
  47522. */
  47523. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47524. private _upload2DCompressedLevels;
  47525. }
  47526. }
  47527. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47528. import { Nullable } from "babylonjs/types";
  47529. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47530. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47531. /**
  47532. * Implementation of the KTX Texture Loader.
  47533. * @hidden
  47534. */
  47535. export class _KTXTextureLoader implements IInternalTextureLoader {
  47536. /**
  47537. * Defines wether the loader supports cascade loading the different faces.
  47538. */
  47539. readonly supportCascades: boolean;
  47540. /**
  47541. * This returns if the loader support the current file information.
  47542. * @param extension defines the file extension of the file being loaded
  47543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47544. * @param fallback defines the fallback internal texture if any
  47545. * @param isBase64 defines whether the texture is encoded as a base64
  47546. * @param isBuffer defines whether the texture data are stored as a buffer
  47547. * @returns true if the loader can load the specified file
  47548. */
  47549. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47550. /**
  47551. * Transform the url before loading if required.
  47552. * @param rootUrl the url of the texture
  47553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47554. * @returns the transformed texture
  47555. */
  47556. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47557. /**
  47558. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47559. * @param rootUrl the url of the texture
  47560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47561. * @returns the fallback texture
  47562. */
  47563. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47564. /**
  47565. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47566. * @param data contains the texture data
  47567. * @param texture defines the BabylonJS internal texture
  47568. * @param createPolynomials will be true if polynomials have been requested
  47569. * @param onLoad defines the callback to trigger once the texture is ready
  47570. * @param onError defines the callback to trigger in case of error
  47571. */
  47572. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47573. /**
  47574. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47575. * @param data contains the texture data
  47576. * @param texture defines the BabylonJS internal texture
  47577. * @param callback defines the method to call once ready to upload
  47578. */
  47579. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47580. }
  47581. }
  47582. declare module "babylonjs/Helpers/sceneHelpers" {
  47583. import { Nullable } from "babylonjs/types";
  47584. import { Mesh } from "babylonjs/Meshes/mesh";
  47585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47586. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47587. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47588. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47589. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47590. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47591. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47592. import "babylonjs/Meshes/Builders/boxBuilder";
  47593. /** @hidden */
  47594. export var _forceSceneHelpersToBundle: boolean;
  47595. module "babylonjs/scene" {
  47596. interface Scene {
  47597. /**
  47598. * Creates a default light for the scene.
  47599. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47600. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47601. */
  47602. createDefaultLight(replace?: boolean): void;
  47603. /**
  47604. * Creates a default camera for the scene.
  47605. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47606. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47607. * @param replace has default false, when true replaces the active camera in the scene
  47608. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47609. */
  47610. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47611. /**
  47612. * Creates a default camera and a default light.
  47613. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47614. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47615. * @param replace has the default false, when true replaces the active camera/light in the scene
  47616. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47617. */
  47618. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47619. /**
  47620. * Creates a new sky box
  47621. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47622. * @param environmentTexture defines the texture to use as environment texture
  47623. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47624. * @param scale defines the overall scale of the skybox
  47625. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47626. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47627. * @returns a new mesh holding the sky box
  47628. */
  47629. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47630. /**
  47631. * Creates a new environment
  47632. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47633. * @param options defines the options you can use to configure the environment
  47634. * @returns the new EnvironmentHelper
  47635. */
  47636. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47637. /**
  47638. * Creates a new VREXperienceHelper
  47639. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47640. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47641. * @returns a new VREXperienceHelper
  47642. */
  47643. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47644. /**
  47645. * Creates a new XREXperienceHelper
  47646. * @see http://doc.babylonjs.com/how_to/webxr
  47647. * @returns a promise for a new XREXperienceHelper
  47648. */
  47649. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47650. }
  47651. }
  47652. }
  47653. declare module "babylonjs/Helpers/videoDome" {
  47654. import { Scene } from "babylonjs/scene";
  47655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47656. import { Mesh } from "babylonjs/Meshes/mesh";
  47657. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47658. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47659. import "babylonjs/Meshes/Builders/sphereBuilder";
  47660. /**
  47661. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47662. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47663. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47664. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47665. */
  47666. export class VideoDome extends TransformNode {
  47667. /**
  47668. * Define the video source as a Monoscopic panoramic 360 video.
  47669. */
  47670. static readonly MODE_MONOSCOPIC: number;
  47671. /**
  47672. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47673. */
  47674. static readonly MODE_TOPBOTTOM: number;
  47675. /**
  47676. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47677. */
  47678. static readonly MODE_SIDEBYSIDE: number;
  47679. private _useDirectMapping;
  47680. /**
  47681. * The video texture being displayed on the sphere
  47682. */
  47683. protected _videoTexture: VideoTexture;
  47684. /**
  47685. * Gets the video texture being displayed on the sphere
  47686. */
  47687. readonly videoTexture: VideoTexture;
  47688. /**
  47689. * The skybox material
  47690. */
  47691. protected _material: BackgroundMaterial;
  47692. /**
  47693. * The surface used for the skybox
  47694. */
  47695. protected _mesh: Mesh;
  47696. /**
  47697. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47698. * Also see the options.resolution property.
  47699. */
  47700. fovMultiplier: number;
  47701. private _videoMode;
  47702. /**
  47703. * Gets or set the current video mode for the video. It can be:
  47704. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47705. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47706. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47707. */
  47708. videoMode: number;
  47709. /**
  47710. * Oberserver used in Stereoscopic VR Mode.
  47711. */
  47712. private _onBeforeCameraRenderObserver;
  47713. /**
  47714. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47715. * @param name Element's name, child elements will append suffixes for their own names.
  47716. * @param urlsOrVideo defines the url(s) or the video element to use
  47717. * @param options An object containing optional or exposed sub element properties
  47718. */
  47719. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47720. resolution?: number;
  47721. clickToPlay?: boolean;
  47722. autoPlay?: boolean;
  47723. loop?: boolean;
  47724. size?: number;
  47725. poster?: string;
  47726. faceForward?: boolean;
  47727. useDirectMapping?: boolean;
  47728. }, scene: Scene);
  47729. private _changeVideoMode;
  47730. /**
  47731. * Releases resources associated with this node.
  47732. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47733. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47734. */
  47735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47736. }
  47737. }
  47738. declare module "babylonjs/Helpers/index" {
  47739. export * from "babylonjs/Helpers/environmentHelper";
  47740. export * from "babylonjs/Helpers/photoDome";
  47741. export * from "babylonjs/Helpers/sceneHelpers";
  47742. export * from "babylonjs/Helpers/videoDome";
  47743. }
  47744. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47745. import { PerfCounter } from "babylonjs/Misc/tools";
  47746. import { IDisposable } from "babylonjs/scene";
  47747. import { Engine } from "babylonjs/Engines/engine";
  47748. /**
  47749. * This class can be used to get instrumentation data from a Babylon engine
  47750. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47751. */
  47752. export class EngineInstrumentation implements IDisposable {
  47753. /**
  47754. * Define the instrumented engine.
  47755. */
  47756. engine: Engine;
  47757. private _captureGPUFrameTime;
  47758. private _gpuFrameTimeToken;
  47759. private _gpuFrameTime;
  47760. private _captureShaderCompilationTime;
  47761. private _shaderCompilationTime;
  47762. private _onBeginFrameObserver;
  47763. private _onEndFrameObserver;
  47764. private _onBeforeShaderCompilationObserver;
  47765. private _onAfterShaderCompilationObserver;
  47766. /**
  47767. * Gets the perf counter used for GPU frame time
  47768. */
  47769. readonly gpuFrameTimeCounter: PerfCounter;
  47770. /**
  47771. * Gets the GPU frame time capture status
  47772. */
  47773. /**
  47774. * Enable or disable the GPU frame time capture
  47775. */
  47776. captureGPUFrameTime: boolean;
  47777. /**
  47778. * Gets the perf counter used for shader compilation time
  47779. */
  47780. readonly shaderCompilationTimeCounter: PerfCounter;
  47781. /**
  47782. * Gets the shader compilation time capture status
  47783. */
  47784. /**
  47785. * Enable or disable the shader compilation time capture
  47786. */
  47787. captureShaderCompilationTime: boolean;
  47788. /**
  47789. * Instantiates a new engine instrumentation.
  47790. * This class can be used to get instrumentation data from a Babylon engine
  47791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47792. * @param engine Defines the engine to instrument
  47793. */
  47794. constructor(
  47795. /**
  47796. * Define the instrumented engine.
  47797. */
  47798. engine: Engine);
  47799. /**
  47800. * Dispose and release associated resources.
  47801. */
  47802. dispose(): void;
  47803. }
  47804. }
  47805. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47806. import { PerfCounter } from "babylonjs/Misc/tools";
  47807. import { Scene, IDisposable } from "babylonjs/scene";
  47808. /**
  47809. * This class can be used to get instrumentation data from a Babylon engine
  47810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47811. */
  47812. export class SceneInstrumentation implements IDisposable {
  47813. /**
  47814. * Defines the scene to instrument
  47815. */
  47816. scene: Scene;
  47817. private _captureActiveMeshesEvaluationTime;
  47818. private _activeMeshesEvaluationTime;
  47819. private _captureRenderTargetsRenderTime;
  47820. private _renderTargetsRenderTime;
  47821. private _captureFrameTime;
  47822. private _frameTime;
  47823. private _captureRenderTime;
  47824. private _renderTime;
  47825. private _captureInterFrameTime;
  47826. private _interFrameTime;
  47827. private _captureParticlesRenderTime;
  47828. private _particlesRenderTime;
  47829. private _captureSpritesRenderTime;
  47830. private _spritesRenderTime;
  47831. private _capturePhysicsTime;
  47832. private _physicsTime;
  47833. private _captureAnimationsTime;
  47834. private _animationsTime;
  47835. private _captureCameraRenderTime;
  47836. private _cameraRenderTime;
  47837. private _onBeforeActiveMeshesEvaluationObserver;
  47838. private _onAfterActiveMeshesEvaluationObserver;
  47839. private _onBeforeRenderTargetsRenderObserver;
  47840. private _onAfterRenderTargetsRenderObserver;
  47841. private _onAfterRenderObserver;
  47842. private _onBeforeDrawPhaseObserver;
  47843. private _onAfterDrawPhaseObserver;
  47844. private _onBeforeAnimationsObserver;
  47845. private _onBeforeParticlesRenderingObserver;
  47846. private _onAfterParticlesRenderingObserver;
  47847. private _onBeforeSpritesRenderingObserver;
  47848. private _onAfterSpritesRenderingObserver;
  47849. private _onBeforePhysicsObserver;
  47850. private _onAfterPhysicsObserver;
  47851. private _onAfterAnimationsObserver;
  47852. private _onBeforeCameraRenderObserver;
  47853. private _onAfterCameraRenderObserver;
  47854. /**
  47855. * Gets the perf counter used for active meshes evaluation time
  47856. */
  47857. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47858. /**
  47859. * Gets the active meshes evaluation time capture status
  47860. */
  47861. /**
  47862. * Enable or disable the active meshes evaluation time capture
  47863. */
  47864. captureActiveMeshesEvaluationTime: boolean;
  47865. /**
  47866. * Gets the perf counter used for render targets render time
  47867. */
  47868. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47869. /**
  47870. * Gets the render targets render time capture status
  47871. */
  47872. /**
  47873. * Enable or disable the render targets render time capture
  47874. */
  47875. captureRenderTargetsRenderTime: boolean;
  47876. /**
  47877. * Gets the perf counter used for particles render time
  47878. */
  47879. readonly particlesRenderTimeCounter: PerfCounter;
  47880. /**
  47881. * Gets the particles render time capture status
  47882. */
  47883. /**
  47884. * Enable or disable the particles render time capture
  47885. */
  47886. captureParticlesRenderTime: boolean;
  47887. /**
  47888. * Gets the perf counter used for sprites render time
  47889. */
  47890. readonly spritesRenderTimeCounter: PerfCounter;
  47891. /**
  47892. * Gets the sprites render time capture status
  47893. */
  47894. /**
  47895. * Enable or disable the sprites render time capture
  47896. */
  47897. captureSpritesRenderTime: boolean;
  47898. /**
  47899. * Gets the perf counter used for physics time
  47900. */
  47901. readonly physicsTimeCounter: PerfCounter;
  47902. /**
  47903. * Gets the physics time capture status
  47904. */
  47905. /**
  47906. * Enable or disable the physics time capture
  47907. */
  47908. capturePhysicsTime: boolean;
  47909. /**
  47910. * Gets the perf counter used for animations time
  47911. */
  47912. readonly animationsTimeCounter: PerfCounter;
  47913. /**
  47914. * Gets the animations time capture status
  47915. */
  47916. /**
  47917. * Enable or disable the animations time capture
  47918. */
  47919. captureAnimationsTime: boolean;
  47920. /**
  47921. * Gets the perf counter used for frame time capture
  47922. */
  47923. readonly frameTimeCounter: PerfCounter;
  47924. /**
  47925. * Gets the frame time capture status
  47926. */
  47927. /**
  47928. * Enable or disable the frame time capture
  47929. */
  47930. captureFrameTime: boolean;
  47931. /**
  47932. * Gets the perf counter used for inter-frames time capture
  47933. */
  47934. readonly interFrameTimeCounter: PerfCounter;
  47935. /**
  47936. * Gets the inter-frames time capture status
  47937. */
  47938. /**
  47939. * Enable or disable the inter-frames time capture
  47940. */
  47941. captureInterFrameTime: boolean;
  47942. /**
  47943. * Gets the perf counter used for render time capture
  47944. */
  47945. readonly renderTimeCounter: PerfCounter;
  47946. /**
  47947. * Gets the render time capture status
  47948. */
  47949. /**
  47950. * Enable or disable the render time capture
  47951. */
  47952. captureRenderTime: boolean;
  47953. /**
  47954. * Gets the perf counter used for camera render time capture
  47955. */
  47956. readonly cameraRenderTimeCounter: PerfCounter;
  47957. /**
  47958. * Gets the camera render time capture status
  47959. */
  47960. /**
  47961. * Enable or disable the camera render time capture
  47962. */
  47963. captureCameraRenderTime: boolean;
  47964. /**
  47965. * Gets the perf counter used for draw calls
  47966. */
  47967. readonly drawCallsCounter: PerfCounter;
  47968. /**
  47969. * Gets the perf counter used for texture collisions
  47970. */
  47971. readonly textureCollisionsCounter: PerfCounter;
  47972. /**
  47973. * Instantiates a new scene instrumentation.
  47974. * This class can be used to get instrumentation data from a Babylon engine
  47975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47976. * @param scene Defines the scene to instrument
  47977. */
  47978. constructor(
  47979. /**
  47980. * Defines the scene to instrument
  47981. */
  47982. scene: Scene);
  47983. /**
  47984. * Dispose and release associated resources.
  47985. */
  47986. dispose(): void;
  47987. }
  47988. }
  47989. declare module "babylonjs/Instrumentation/index" {
  47990. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47991. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47992. export * from "babylonjs/Instrumentation/timeToken";
  47993. }
  47994. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47995. /** @hidden */
  47996. export var glowMapGenerationPixelShader: {
  47997. name: string;
  47998. shader: string;
  47999. };
  48000. }
  48001. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48007. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48008. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48009. /** @hidden */
  48010. export var glowMapGenerationVertexShader: {
  48011. name: string;
  48012. shader: string;
  48013. };
  48014. }
  48015. declare module "babylonjs/Layers/effectLayer" {
  48016. import { Observable } from "babylonjs/Misc/observable";
  48017. import { Nullable } from "babylonjs/types";
  48018. import { Camera } from "babylonjs/Cameras/camera";
  48019. import { Scene } from "babylonjs/scene";
  48020. import { Color4, ISize } from "babylonjs/Maths/math";
  48021. import { Engine } from "babylonjs/Engines/engine";
  48022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48024. import { Mesh } from "babylonjs/Meshes/mesh";
  48025. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48028. import { Effect } from "babylonjs/Materials/effect";
  48029. import { Material } from "babylonjs/Materials/material";
  48030. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48031. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48032. /**
  48033. * Effect layer options. This helps customizing the behaviour
  48034. * of the effect layer.
  48035. */
  48036. export interface IEffectLayerOptions {
  48037. /**
  48038. * Multiplication factor apply to the canvas size to compute the render target size
  48039. * used to generated the objects (the smaller the faster).
  48040. */
  48041. mainTextureRatio: number;
  48042. /**
  48043. * Enforces a fixed size texture to ensure effect stability across devices.
  48044. */
  48045. mainTextureFixedSize?: number;
  48046. /**
  48047. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48048. */
  48049. alphaBlendingMode: number;
  48050. /**
  48051. * The camera attached to the layer.
  48052. */
  48053. camera: Nullable<Camera>;
  48054. /**
  48055. * The rendering group to draw the layer in.
  48056. */
  48057. renderingGroupId: number;
  48058. }
  48059. /**
  48060. * The effect layer Helps adding post process effect blended with the main pass.
  48061. *
  48062. * This can be for instance use to generate glow or higlight effects on the scene.
  48063. *
  48064. * The effect layer class can not be used directly and is intented to inherited from to be
  48065. * customized per effects.
  48066. */
  48067. export abstract class EffectLayer {
  48068. private _vertexBuffers;
  48069. private _indexBuffer;
  48070. private _cachedDefines;
  48071. private _effectLayerMapGenerationEffect;
  48072. private _effectLayerOptions;
  48073. private _mergeEffect;
  48074. protected _scene: Scene;
  48075. protected _engine: Engine;
  48076. protected _maxSize: number;
  48077. protected _mainTextureDesiredSize: ISize;
  48078. protected _mainTexture: RenderTargetTexture;
  48079. protected _shouldRender: boolean;
  48080. protected _postProcesses: PostProcess[];
  48081. protected _textures: BaseTexture[];
  48082. protected _emissiveTextureAndColor: {
  48083. texture: Nullable<BaseTexture>;
  48084. color: Color4;
  48085. };
  48086. /**
  48087. * The name of the layer
  48088. */
  48089. name: string;
  48090. /**
  48091. * The clear color of the texture used to generate the glow map.
  48092. */
  48093. neutralColor: Color4;
  48094. /**
  48095. * Specifies wether the highlight layer is enabled or not.
  48096. */
  48097. isEnabled: boolean;
  48098. /**
  48099. * Gets the camera attached to the layer.
  48100. */
  48101. readonly camera: Nullable<Camera>;
  48102. /**
  48103. * Gets the rendering group id the layer should render in.
  48104. */
  48105. readonly renderingGroupId: number;
  48106. /**
  48107. * An event triggered when the effect layer has been disposed.
  48108. */
  48109. onDisposeObservable: Observable<EffectLayer>;
  48110. /**
  48111. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48112. */
  48113. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48114. /**
  48115. * An event triggered when the generated texture is being merged in the scene.
  48116. */
  48117. onBeforeComposeObservable: Observable<EffectLayer>;
  48118. /**
  48119. * An event triggered when the generated texture has been merged in the scene.
  48120. */
  48121. onAfterComposeObservable: Observable<EffectLayer>;
  48122. /**
  48123. * An event triggered when the efffect layer changes its size.
  48124. */
  48125. onSizeChangedObservable: Observable<EffectLayer>;
  48126. /** @hidden */
  48127. static _SceneComponentInitialization: (scene: Scene) => void;
  48128. /**
  48129. * Instantiates a new effect Layer and references it in the scene.
  48130. * @param name The name of the layer
  48131. * @param scene The scene to use the layer in
  48132. */
  48133. constructor(
  48134. /** The Friendly of the effect in the scene */
  48135. name: string, scene: Scene);
  48136. /**
  48137. * Get the effect name of the layer.
  48138. * @return The effect name
  48139. */
  48140. abstract getEffectName(): string;
  48141. /**
  48142. * Checks for the readiness of the element composing the layer.
  48143. * @param subMesh the mesh to check for
  48144. * @param useInstances specify wether or not to use instances to render the mesh
  48145. * @return true if ready otherwise, false
  48146. */
  48147. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48148. /**
  48149. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48150. * @returns true if the effect requires stencil during the main canvas render pass.
  48151. */
  48152. abstract needStencil(): boolean;
  48153. /**
  48154. * Create the merge effect. This is the shader use to blit the information back
  48155. * to the main canvas at the end of the scene rendering.
  48156. * @returns The effect containing the shader used to merge the effect on the main canvas
  48157. */
  48158. protected abstract _createMergeEffect(): Effect;
  48159. /**
  48160. * Creates the render target textures and post processes used in the effect layer.
  48161. */
  48162. protected abstract _createTextureAndPostProcesses(): void;
  48163. /**
  48164. * Implementation specific of rendering the generating effect on the main canvas.
  48165. * @param effect The effect used to render through
  48166. */
  48167. protected abstract _internalRender(effect: Effect): void;
  48168. /**
  48169. * Sets the required values for both the emissive texture and and the main color.
  48170. */
  48171. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48172. /**
  48173. * Free any resources and references associated to a mesh.
  48174. * Internal use
  48175. * @param mesh The mesh to free.
  48176. */
  48177. abstract _disposeMesh(mesh: Mesh): void;
  48178. /**
  48179. * Serializes this layer (Glow or Highlight for example)
  48180. * @returns a serialized layer object
  48181. */
  48182. abstract serialize?(): any;
  48183. /**
  48184. * Initializes the effect layer with the required options.
  48185. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48186. */
  48187. protected _init(options: Partial<IEffectLayerOptions>): void;
  48188. /**
  48189. * Generates the index buffer of the full screen quad blending to the main canvas.
  48190. */
  48191. private _generateIndexBuffer;
  48192. /**
  48193. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48194. */
  48195. private _genrateVertexBuffer;
  48196. /**
  48197. * Sets the main texture desired size which is the closest power of two
  48198. * of the engine canvas size.
  48199. */
  48200. private _setMainTextureSize;
  48201. /**
  48202. * Creates the main texture for the effect layer.
  48203. */
  48204. protected _createMainTexture(): void;
  48205. /**
  48206. * Adds specific effects defines.
  48207. * @param defines The defines to add specifics to.
  48208. */
  48209. protected _addCustomEffectDefines(defines: string[]): void;
  48210. /**
  48211. * Checks for the readiness of the element composing the layer.
  48212. * @param subMesh the mesh to check for
  48213. * @param useInstances specify wether or not to use instances to render the mesh
  48214. * @param emissiveTexture the associated emissive texture used to generate the glow
  48215. * @return true if ready otherwise, false
  48216. */
  48217. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48218. /**
  48219. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48220. */
  48221. render(): void;
  48222. /**
  48223. * Determine if a given mesh will be used in the current effect.
  48224. * @param mesh mesh to test
  48225. * @returns true if the mesh will be used
  48226. */
  48227. hasMesh(mesh: AbstractMesh): boolean;
  48228. /**
  48229. * Returns true if the layer contains information to display, otherwise false.
  48230. * @returns true if the glow layer should be rendered
  48231. */
  48232. shouldRender(): boolean;
  48233. /**
  48234. * Returns true if the mesh should render, otherwise false.
  48235. * @param mesh The mesh to render
  48236. * @returns true if it should render otherwise false
  48237. */
  48238. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48239. /**
  48240. * Returns true if the mesh can be rendered, otherwise false.
  48241. * @param mesh The mesh to render
  48242. * @param material The material used on the mesh
  48243. * @returns true if it can be rendered otherwise false
  48244. */
  48245. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48246. /**
  48247. * Returns true if the mesh should render, otherwise false.
  48248. * @param mesh The mesh to render
  48249. * @returns true if it should render otherwise false
  48250. */
  48251. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48252. /**
  48253. * Renders the submesh passed in parameter to the generation map.
  48254. */
  48255. protected _renderSubMesh(subMesh: SubMesh): void;
  48256. /**
  48257. * Rebuild the required buffers.
  48258. * @hidden Internal use only.
  48259. */
  48260. _rebuild(): void;
  48261. /**
  48262. * Dispose only the render target textures and post process.
  48263. */
  48264. private _disposeTextureAndPostProcesses;
  48265. /**
  48266. * Dispose the highlight layer and free resources.
  48267. */
  48268. dispose(): void;
  48269. /**
  48270. * Gets the class name of the effect layer
  48271. * @returns the string with the class name of the effect layer
  48272. */
  48273. getClassName(): string;
  48274. /**
  48275. * Creates an effect layer from parsed effect layer data
  48276. * @param parsedEffectLayer defines effect layer data
  48277. * @param scene defines the current scene
  48278. * @param rootUrl defines the root URL containing the effect layer information
  48279. * @returns a parsed effect Layer
  48280. */
  48281. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48282. }
  48283. }
  48284. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48285. import { Scene } from "babylonjs/scene";
  48286. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48287. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48288. import { AbstractScene } from "babylonjs/abstractScene";
  48289. module "babylonjs/abstractScene" {
  48290. interface AbstractScene {
  48291. /**
  48292. * The list of effect layers (highlights/glow) added to the scene
  48293. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48294. * @see http://doc.babylonjs.com/how_to/glow_layer
  48295. */
  48296. effectLayers: Array<EffectLayer>;
  48297. /**
  48298. * Removes the given effect layer from this scene.
  48299. * @param toRemove defines the effect layer to remove
  48300. * @returns the index of the removed effect layer
  48301. */
  48302. removeEffectLayer(toRemove: EffectLayer): number;
  48303. /**
  48304. * Adds the given effect layer to this scene
  48305. * @param newEffectLayer defines the effect layer to add
  48306. */
  48307. addEffectLayer(newEffectLayer: EffectLayer): void;
  48308. }
  48309. }
  48310. /**
  48311. * Defines the layer scene component responsible to manage any effect layers
  48312. * in a given scene.
  48313. */
  48314. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48315. /**
  48316. * The component name helpfull to identify the component in the list of scene components.
  48317. */
  48318. readonly name: string;
  48319. /**
  48320. * The scene the component belongs to.
  48321. */
  48322. scene: Scene;
  48323. private _engine;
  48324. private _renderEffects;
  48325. private _needStencil;
  48326. private _previousStencilState;
  48327. /**
  48328. * Creates a new instance of the component for the given scene
  48329. * @param scene Defines the scene to register the component in
  48330. */
  48331. constructor(scene: Scene);
  48332. /**
  48333. * Registers the component in a given scene
  48334. */
  48335. register(): void;
  48336. /**
  48337. * Rebuilds the elements related to this component in case of
  48338. * context lost for instance.
  48339. */
  48340. rebuild(): void;
  48341. /**
  48342. * Serializes the component data to the specified json object
  48343. * @param serializationObject The object to serialize to
  48344. */
  48345. serialize(serializationObject: any): void;
  48346. /**
  48347. * Adds all the element from the container to the scene
  48348. * @param container the container holding the elements
  48349. */
  48350. addFromContainer(container: AbstractScene): void;
  48351. /**
  48352. * Removes all the elements in the container from the scene
  48353. * @param container contains the elements to remove
  48354. * @param dispose if the removed element should be disposed (default: false)
  48355. */
  48356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48357. /**
  48358. * Disposes the component and the associated ressources.
  48359. */
  48360. dispose(): void;
  48361. private _isReadyForMesh;
  48362. private _renderMainTexture;
  48363. private _setStencil;
  48364. private _setStencilBack;
  48365. private _draw;
  48366. private _drawCamera;
  48367. private _drawRenderingGroup;
  48368. }
  48369. }
  48370. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48371. /** @hidden */
  48372. export var glowMapMergePixelShader: {
  48373. name: string;
  48374. shader: string;
  48375. };
  48376. }
  48377. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48378. /** @hidden */
  48379. export var glowMapMergeVertexShader: {
  48380. name: string;
  48381. shader: string;
  48382. };
  48383. }
  48384. declare module "babylonjs/Layers/glowLayer" {
  48385. import { Nullable } from "babylonjs/types";
  48386. import { Camera } from "babylonjs/Cameras/camera";
  48387. import { Scene } from "babylonjs/scene";
  48388. import { Color4 } from "babylonjs/Maths/math";
  48389. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48391. import { Mesh } from "babylonjs/Meshes/mesh";
  48392. import { Texture } from "babylonjs/Materials/Textures/texture";
  48393. import { Effect } from "babylonjs/Materials/effect";
  48394. import { Material } from "babylonjs/Materials/material";
  48395. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48396. import "babylonjs/Shaders/glowMapMerge.fragment";
  48397. import "babylonjs/Shaders/glowMapMerge.vertex";
  48398. import "babylonjs/Layers/effectLayerSceneComponent";
  48399. module "babylonjs/abstractScene" {
  48400. interface AbstractScene {
  48401. /**
  48402. * Return a the first highlight layer of the scene with a given name.
  48403. * @param name The name of the highlight layer to look for.
  48404. * @return The highlight layer if found otherwise null.
  48405. */
  48406. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48407. }
  48408. }
  48409. /**
  48410. * Glow layer options. This helps customizing the behaviour
  48411. * of the glow layer.
  48412. */
  48413. export interface IGlowLayerOptions {
  48414. /**
  48415. * Multiplication factor apply to the canvas size to compute the render target size
  48416. * used to generated the glowing objects (the smaller the faster).
  48417. */
  48418. mainTextureRatio: number;
  48419. /**
  48420. * Enforces a fixed size texture to ensure resize independant blur.
  48421. */
  48422. mainTextureFixedSize?: number;
  48423. /**
  48424. * How big is the kernel of the blur texture.
  48425. */
  48426. blurKernelSize: number;
  48427. /**
  48428. * The camera attached to the layer.
  48429. */
  48430. camera: Nullable<Camera>;
  48431. /**
  48432. * Enable MSAA by chosing the number of samples.
  48433. */
  48434. mainTextureSamples?: number;
  48435. /**
  48436. * The rendering group to draw the layer in.
  48437. */
  48438. renderingGroupId: number;
  48439. }
  48440. /**
  48441. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48442. *
  48443. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48444. * glowy meshes to your scene.
  48445. *
  48446. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48447. */
  48448. export class GlowLayer extends EffectLayer {
  48449. /**
  48450. * Effect Name of the layer.
  48451. */
  48452. static readonly EffectName: string;
  48453. /**
  48454. * The default blur kernel size used for the glow.
  48455. */
  48456. static DefaultBlurKernelSize: number;
  48457. /**
  48458. * The default texture size ratio used for the glow.
  48459. */
  48460. static DefaultTextureRatio: number;
  48461. /**
  48462. * Sets the kernel size of the blur.
  48463. */
  48464. /**
  48465. * Gets the kernel size of the blur.
  48466. */
  48467. blurKernelSize: number;
  48468. /**
  48469. * Sets the glow intensity.
  48470. */
  48471. /**
  48472. * Gets the glow intensity.
  48473. */
  48474. intensity: number;
  48475. private _options;
  48476. private _intensity;
  48477. private _horizontalBlurPostprocess1;
  48478. private _verticalBlurPostprocess1;
  48479. private _horizontalBlurPostprocess2;
  48480. private _verticalBlurPostprocess2;
  48481. private _blurTexture1;
  48482. private _blurTexture2;
  48483. private _postProcesses1;
  48484. private _postProcesses2;
  48485. private _includedOnlyMeshes;
  48486. private _excludedMeshes;
  48487. /**
  48488. * Callback used to let the user override the color selection on a per mesh basis
  48489. */
  48490. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48491. /**
  48492. * Callback used to let the user override the texture selection on a per mesh basis
  48493. */
  48494. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48495. /**
  48496. * Instantiates a new glow Layer and references it to the scene.
  48497. * @param name The name of the layer
  48498. * @param scene The scene to use the layer in
  48499. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48500. */
  48501. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48502. /**
  48503. * Get the effect name of the layer.
  48504. * @return The effect name
  48505. */
  48506. getEffectName(): string;
  48507. /**
  48508. * Create the merge effect. This is the shader use to blit the information back
  48509. * to the main canvas at the end of the scene rendering.
  48510. */
  48511. protected _createMergeEffect(): Effect;
  48512. /**
  48513. * Creates the render target textures and post processes used in the glow layer.
  48514. */
  48515. protected _createTextureAndPostProcesses(): void;
  48516. /**
  48517. * Checks for the readiness of the element composing the layer.
  48518. * @param subMesh the mesh to check for
  48519. * @param useInstances specify wether or not to use instances to render the mesh
  48520. * @param emissiveTexture the associated emissive texture used to generate the glow
  48521. * @return true if ready otherwise, false
  48522. */
  48523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48524. /**
  48525. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48526. */
  48527. needStencil(): boolean;
  48528. /**
  48529. * Returns true if the mesh can be rendered, otherwise false.
  48530. * @param mesh The mesh to render
  48531. * @param material The material used on the mesh
  48532. * @returns true if it can be rendered otherwise false
  48533. */
  48534. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48535. /**
  48536. * Implementation specific of rendering the generating effect on the main canvas.
  48537. * @param effect The effect used to render through
  48538. */
  48539. protected _internalRender(effect: Effect): void;
  48540. /**
  48541. * Sets the required values for both the emissive texture and and the main color.
  48542. */
  48543. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48544. /**
  48545. * Returns true if the mesh should render, otherwise false.
  48546. * @param mesh The mesh to render
  48547. * @returns true if it should render otherwise false
  48548. */
  48549. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48550. /**
  48551. * Adds specific effects defines.
  48552. * @param defines The defines to add specifics to.
  48553. */
  48554. protected _addCustomEffectDefines(defines: string[]): void;
  48555. /**
  48556. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48557. * @param mesh The mesh to exclude from the glow layer
  48558. */
  48559. addExcludedMesh(mesh: Mesh): void;
  48560. /**
  48561. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48562. * @param mesh The mesh to remove
  48563. */
  48564. removeExcludedMesh(mesh: Mesh): void;
  48565. /**
  48566. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48567. * @param mesh The mesh to include in the glow layer
  48568. */
  48569. addIncludedOnlyMesh(mesh: Mesh): void;
  48570. /**
  48571. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48572. * @param mesh The mesh to remove
  48573. */
  48574. removeIncludedOnlyMesh(mesh: Mesh): void;
  48575. /**
  48576. * Determine if a given mesh will be used in the glow layer
  48577. * @param mesh The mesh to test
  48578. * @returns true if the mesh will be highlighted by the current glow layer
  48579. */
  48580. hasMesh(mesh: AbstractMesh): boolean;
  48581. /**
  48582. * Free any resources and references associated to a mesh.
  48583. * Internal use
  48584. * @param mesh The mesh to free.
  48585. * @hidden
  48586. */
  48587. _disposeMesh(mesh: Mesh): void;
  48588. /**
  48589. * Gets the class name of the effect layer
  48590. * @returns the string with the class name of the effect layer
  48591. */
  48592. getClassName(): string;
  48593. /**
  48594. * Serializes this glow layer
  48595. * @returns a serialized glow layer object
  48596. */
  48597. serialize(): any;
  48598. /**
  48599. * Creates a Glow Layer from parsed glow layer data
  48600. * @param parsedGlowLayer defines glow layer data
  48601. * @param scene defines the current scene
  48602. * @param rootUrl defines the root URL containing the glow layer information
  48603. * @returns a parsed Glow Layer
  48604. */
  48605. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48606. }
  48607. }
  48608. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48609. /** @hidden */
  48610. export var glowBlurPostProcessPixelShader: {
  48611. name: string;
  48612. shader: string;
  48613. };
  48614. }
  48615. declare module "babylonjs/Layers/highlightLayer" {
  48616. import { Observable } from "babylonjs/Misc/observable";
  48617. import { Nullable } from "babylonjs/types";
  48618. import { Camera } from "babylonjs/Cameras/camera";
  48619. import { Scene } from "babylonjs/scene";
  48620. import { Color3, Color4 } from "babylonjs/Maths/math";
  48621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48623. import { Mesh } from "babylonjs/Meshes/mesh";
  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/Shaders/glowBlurPostProcess.fragment";
  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. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48638. }
  48639. }
  48640. /**
  48641. * Highlight layer options. This helps customizing the behaviour
  48642. * of the highlight layer.
  48643. */
  48644. export interface IHighlightLayerOptions {
  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. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48656. * of the picture to blur (the smaller the faster).
  48657. */
  48658. blurTextureSizeRatio: number;
  48659. /**
  48660. * How big in texel of the blur texture is the vertical blur.
  48661. */
  48662. blurVerticalSize: number;
  48663. /**
  48664. * How big in texel of the blur texture is the horizontal blur.
  48665. */
  48666. blurHorizontalSize: number;
  48667. /**
  48668. * Alpha blending mode used to apply the blur. Default is combine.
  48669. */
  48670. alphaBlendingMode: number;
  48671. /**
  48672. * The camera attached to the layer.
  48673. */
  48674. camera: Nullable<Camera>;
  48675. /**
  48676. * Should we display highlight as a solid stroke?
  48677. */
  48678. isStroke?: boolean;
  48679. /**
  48680. * The rendering group to draw the layer in.
  48681. */
  48682. renderingGroupId: number;
  48683. }
  48684. /**
  48685. * The highlight layer Helps adding a glow effect around a mesh.
  48686. *
  48687. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48688. * glowy meshes to your scene.
  48689. *
  48690. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48691. */
  48692. export class HighlightLayer extends EffectLayer {
  48693. name: string;
  48694. /**
  48695. * Effect Name of the highlight layer.
  48696. */
  48697. static readonly EffectName: string;
  48698. /**
  48699. * The neutral color used during the preparation of the glow effect.
  48700. * This is black by default as the blend operation is a blend operation.
  48701. */
  48702. static NeutralColor: Color4;
  48703. /**
  48704. * Stencil value used for glowing meshes.
  48705. */
  48706. static GlowingMeshStencilReference: number;
  48707. /**
  48708. * Stencil value used for the other meshes in the scene.
  48709. */
  48710. static NormalMeshStencilReference: number;
  48711. /**
  48712. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48713. */
  48714. innerGlow: boolean;
  48715. /**
  48716. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48717. */
  48718. outerGlow: boolean;
  48719. /**
  48720. * Specifies the horizontal size of the blur.
  48721. */
  48722. /**
  48723. * Gets the horizontal size of the blur.
  48724. */
  48725. blurHorizontalSize: number;
  48726. /**
  48727. * Specifies the vertical size of the blur.
  48728. */
  48729. /**
  48730. * Gets the vertical size of the blur.
  48731. */
  48732. blurVerticalSize: number;
  48733. /**
  48734. * An event triggered when the highlight layer is being blurred.
  48735. */
  48736. onBeforeBlurObservable: Observable<HighlightLayer>;
  48737. /**
  48738. * An event triggered when the highlight layer has been blurred.
  48739. */
  48740. onAfterBlurObservable: Observable<HighlightLayer>;
  48741. private _instanceGlowingMeshStencilReference;
  48742. private _options;
  48743. private _downSamplePostprocess;
  48744. private _horizontalBlurPostprocess;
  48745. private _verticalBlurPostprocess;
  48746. private _blurTexture;
  48747. private _meshes;
  48748. private _excludedMeshes;
  48749. /**
  48750. * Instantiates a new highlight Layer and references it to the scene..
  48751. * @param name The name of the layer
  48752. * @param scene The scene to use the layer in
  48753. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48754. */
  48755. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48756. /**
  48757. * Get the effect name of the layer.
  48758. * @return The effect name
  48759. */
  48760. getEffectName(): string;
  48761. /**
  48762. * Create the merge effect. This is the shader use to blit the information back
  48763. * to the main canvas at the end of the scene rendering.
  48764. */
  48765. protected _createMergeEffect(): Effect;
  48766. /**
  48767. * Creates the render target textures and post processes used in the highlight layer.
  48768. */
  48769. protected _createTextureAndPostProcesses(): void;
  48770. /**
  48771. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48772. */
  48773. needStencil(): boolean;
  48774. /**
  48775. * Checks for the readiness of the element composing the layer.
  48776. * @param subMesh the mesh to check for
  48777. * @param useInstances specify wether or not to use instances to render the mesh
  48778. * @param emissiveTexture the associated emissive texture used to generate the glow
  48779. * @return true if ready otherwise, false
  48780. */
  48781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48782. /**
  48783. * Implementation specific of rendering the generating effect on the main canvas.
  48784. * @param effect The effect used to render through
  48785. */
  48786. protected _internalRender(effect: Effect): void;
  48787. /**
  48788. * Returns true if the layer contains information to display, otherwise false.
  48789. */
  48790. shouldRender(): boolean;
  48791. /**
  48792. * Returns true if the mesh should render, otherwise false.
  48793. * @param mesh The mesh to render
  48794. * @returns true if it should render otherwise false
  48795. */
  48796. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48797. /**
  48798. * Sets the required values for both the emissive texture and and the main color.
  48799. */
  48800. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48801. /**
  48802. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48803. * @param mesh The mesh to exclude from the highlight layer
  48804. */
  48805. addExcludedMesh(mesh: Mesh): void;
  48806. /**
  48807. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48808. * @param mesh The mesh to highlight
  48809. */
  48810. removeExcludedMesh(mesh: Mesh): void;
  48811. /**
  48812. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48813. * @param mesh mesh to test
  48814. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48815. */
  48816. hasMesh(mesh: AbstractMesh): boolean;
  48817. /**
  48818. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48819. * @param mesh The mesh to highlight
  48820. * @param color The color of the highlight
  48821. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48822. */
  48823. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48824. /**
  48825. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48826. * @param mesh The mesh to highlight
  48827. */
  48828. removeMesh(mesh: Mesh): void;
  48829. /**
  48830. * Force the stencil to the normal expected value for none glowing parts
  48831. */
  48832. private _defaultStencilReference;
  48833. /**
  48834. * Free any resources and references associated to a mesh.
  48835. * Internal use
  48836. * @param mesh The mesh to free.
  48837. * @hidden
  48838. */
  48839. _disposeMesh(mesh: Mesh): void;
  48840. /**
  48841. * Dispose the highlight layer and free resources.
  48842. */
  48843. dispose(): void;
  48844. /**
  48845. * Gets the class name of the effect layer
  48846. * @returns the string with the class name of the effect layer
  48847. */
  48848. getClassName(): string;
  48849. /**
  48850. * Serializes this Highlight layer
  48851. * @returns a serialized Highlight layer object
  48852. */
  48853. serialize(): any;
  48854. /**
  48855. * Creates a Highlight layer from parsed Highlight layer data
  48856. * @param parsedHightlightLayer defines the Highlight layer data
  48857. * @param scene defines the current scene
  48858. * @param rootUrl defines the root URL containing the Highlight layer information
  48859. * @returns a parsed Highlight layer
  48860. */
  48861. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48862. }
  48863. }
  48864. declare module "babylonjs/Layers/index" {
  48865. export * from "babylonjs/Layers/effectLayer";
  48866. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48867. export * from "babylonjs/Layers/glowLayer";
  48868. export * from "babylonjs/Layers/highlightLayer";
  48869. export * from "babylonjs/Layers/layer";
  48870. export * from "babylonjs/Layers/layerSceneComponent";
  48871. }
  48872. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48873. /** @hidden */
  48874. export var lensFlarePixelShader: {
  48875. name: string;
  48876. shader: string;
  48877. };
  48878. }
  48879. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48880. /** @hidden */
  48881. export var lensFlareVertexShader: {
  48882. name: string;
  48883. shader: string;
  48884. };
  48885. }
  48886. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48887. import { Scene } from "babylonjs/scene";
  48888. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48890. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48891. import "babylonjs/Shaders/lensFlare.fragment";
  48892. import "babylonjs/Shaders/lensFlare.vertex";
  48893. /**
  48894. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48895. * It is usually composed of several `lensFlare`.
  48896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48897. */
  48898. export class LensFlareSystem {
  48899. /**
  48900. * Define the name of the lens flare system
  48901. */
  48902. name: string;
  48903. /**
  48904. * List of lens flares used in this system.
  48905. */
  48906. lensFlares: LensFlare[];
  48907. /**
  48908. * Define a limit from the border the lens flare can be visible.
  48909. */
  48910. borderLimit: number;
  48911. /**
  48912. * Define a viewport border we do not want to see the lens flare in.
  48913. */
  48914. viewportBorder: number;
  48915. /**
  48916. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48917. */
  48918. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48919. /**
  48920. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48921. */
  48922. layerMask: number;
  48923. /**
  48924. * Define the id of the lens flare system in the scene.
  48925. * (equal to name by default)
  48926. */
  48927. id: string;
  48928. private _scene;
  48929. private _emitter;
  48930. private _vertexBuffers;
  48931. private _indexBuffer;
  48932. private _effect;
  48933. private _positionX;
  48934. private _positionY;
  48935. private _isEnabled;
  48936. /** @hidden */
  48937. static _SceneComponentInitialization: (scene: Scene) => void;
  48938. /**
  48939. * Instantiates a lens flare system.
  48940. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48941. * It is usually composed of several `lensFlare`.
  48942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48943. * @param name Define the name of the lens flare system in the scene
  48944. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48945. * @param scene Define the scene the lens flare system belongs to
  48946. */
  48947. constructor(
  48948. /**
  48949. * Define the name of the lens flare system
  48950. */
  48951. name: string, emitter: any, scene: Scene);
  48952. /**
  48953. * Define if the lens flare system is enabled.
  48954. */
  48955. isEnabled: boolean;
  48956. /**
  48957. * Get the scene the effects belongs to.
  48958. * @returns the scene holding the lens flare system
  48959. */
  48960. getScene(): Scene;
  48961. /**
  48962. * Get the emitter of the lens flare system.
  48963. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48964. * @returns the emitter of the lens flare system
  48965. */
  48966. getEmitter(): any;
  48967. /**
  48968. * Set the emitter of the lens flare system.
  48969. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48970. * @param newEmitter Define the new emitter of the system
  48971. */
  48972. setEmitter(newEmitter: any): void;
  48973. /**
  48974. * Get the lens flare system emitter position.
  48975. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48976. * @returns the position
  48977. */
  48978. getEmitterPosition(): Vector3;
  48979. /**
  48980. * @hidden
  48981. */
  48982. computeEffectivePosition(globalViewport: Viewport): boolean;
  48983. /** @hidden */
  48984. _isVisible(): boolean;
  48985. /**
  48986. * @hidden
  48987. */
  48988. render(): boolean;
  48989. /**
  48990. * Dispose and release the lens flare with its associated resources.
  48991. */
  48992. dispose(): void;
  48993. /**
  48994. * Parse a lens flare system from a JSON repressentation
  48995. * @param parsedLensFlareSystem Define the JSON to parse
  48996. * @param scene Define the scene the parsed system should be instantiated in
  48997. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48998. * @returns the parsed system
  48999. */
  49000. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49001. /**
  49002. * Serialize the current Lens Flare System into a JSON representation.
  49003. * @returns the serialized JSON
  49004. */
  49005. serialize(): any;
  49006. }
  49007. }
  49008. declare module "babylonjs/LensFlares/lensFlare" {
  49009. import { Nullable } from "babylonjs/types";
  49010. import { Color3 } from "babylonjs/Maths/math";
  49011. import { Texture } from "babylonjs/Materials/Textures/texture";
  49012. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49013. /**
  49014. * This represents one of the lens effect in a `lensFlareSystem`.
  49015. * It controls one of the indiviual texture used in the effect.
  49016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49017. */
  49018. export class LensFlare {
  49019. /**
  49020. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49021. */
  49022. size: number;
  49023. /**
  49024. * 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.
  49025. */
  49026. position: number;
  49027. /**
  49028. * Define the lens color.
  49029. */
  49030. color: Color3;
  49031. /**
  49032. * Define the lens texture.
  49033. */
  49034. texture: Nullable<Texture>;
  49035. /**
  49036. * Define the alpha mode to render this particular lens.
  49037. */
  49038. alphaMode: number;
  49039. private _system;
  49040. /**
  49041. * Creates a new Lens Flare.
  49042. * This represents one of the lens effect in a `lensFlareSystem`.
  49043. * It controls one of the indiviual texture used in the effect.
  49044. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49045. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49046. * @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.
  49047. * @param color Define the lens color
  49048. * @param imgUrl Define the lens texture url
  49049. * @param system Define the `lensFlareSystem` this flare is part of
  49050. * @returns The newly created Lens Flare
  49051. */
  49052. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49053. /**
  49054. * Instantiates a new Lens Flare.
  49055. * This represents one of the lens effect in a `lensFlareSystem`.
  49056. * It controls one of the indiviual texture used in the effect.
  49057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49058. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49059. * @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.
  49060. * @param color Define the lens color
  49061. * @param imgUrl Define the lens texture url
  49062. * @param system Define the `lensFlareSystem` this flare is part of
  49063. */
  49064. constructor(
  49065. /**
  49066. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49067. */
  49068. size: number,
  49069. /**
  49070. * 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.
  49071. */
  49072. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49073. /**
  49074. * Dispose and release the lens flare with its associated resources.
  49075. */
  49076. dispose(): void;
  49077. }
  49078. }
  49079. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49080. import { Nullable } from "babylonjs/types";
  49081. import { Scene } from "babylonjs/scene";
  49082. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49083. import { AbstractScene } from "babylonjs/abstractScene";
  49084. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49085. module "babylonjs/abstractScene" {
  49086. interface AbstractScene {
  49087. /**
  49088. * The list of lens flare system added to the scene
  49089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49090. */
  49091. lensFlareSystems: Array<LensFlareSystem>;
  49092. /**
  49093. * Removes the given lens flare system from this scene.
  49094. * @param toRemove The lens flare system to remove
  49095. * @returns The index of the removed lens flare system
  49096. */
  49097. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49098. /**
  49099. * Adds the given lens flare system to this scene
  49100. * @param newLensFlareSystem The lens flare system to add
  49101. */
  49102. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49103. /**
  49104. * Gets a lens flare system using its name
  49105. * @param name defines the name to look for
  49106. * @returns the lens flare system or null if not found
  49107. */
  49108. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49109. /**
  49110. * Gets a lens flare system using its id
  49111. * @param id defines the id to look for
  49112. * @returns the lens flare system or null if not found
  49113. */
  49114. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49115. }
  49116. }
  49117. /**
  49118. * Defines the lens flare scene component responsible to manage any lens flares
  49119. * in a given scene.
  49120. */
  49121. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49122. /**
  49123. * The component name helpfull to identify the component in the list of scene components.
  49124. */
  49125. readonly name: string;
  49126. /**
  49127. * The scene the component belongs to.
  49128. */
  49129. scene: Scene;
  49130. /**
  49131. * Creates a new instance of the component for the given scene
  49132. * @param scene Defines the scene to register the component in
  49133. */
  49134. constructor(scene: Scene);
  49135. /**
  49136. * Registers the component in a given scene
  49137. */
  49138. register(): void;
  49139. /**
  49140. * Rebuilds the elements related to this component in case of
  49141. * context lost for instance.
  49142. */
  49143. rebuild(): void;
  49144. /**
  49145. * Adds all the element from the container to the scene
  49146. * @param container the container holding the elements
  49147. */
  49148. addFromContainer(container: AbstractScene): void;
  49149. /**
  49150. * Removes all the elements in the container from the scene
  49151. * @param container contains the elements to remove
  49152. * @param dispose if the removed element should be disposed (default: false)
  49153. */
  49154. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49155. /**
  49156. * Serializes the component data to the specified json object
  49157. * @param serializationObject The object to serialize to
  49158. */
  49159. serialize(serializationObject: any): void;
  49160. /**
  49161. * Disposes the component and the associated ressources.
  49162. */
  49163. dispose(): void;
  49164. private _draw;
  49165. }
  49166. }
  49167. declare module "babylonjs/LensFlares/index" {
  49168. export * from "babylonjs/LensFlares/lensFlare";
  49169. export * from "babylonjs/LensFlares/lensFlareSystem";
  49170. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49171. }
  49172. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49173. import { Scene } from "babylonjs/scene";
  49174. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49175. import { AbstractScene } from "babylonjs/abstractScene";
  49176. /**
  49177. * Defines the shadow generator component responsible to manage any shadow generators
  49178. * in a given scene.
  49179. */
  49180. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49181. /**
  49182. * The component name helpfull to identify the component in the list of scene components.
  49183. */
  49184. readonly name: string;
  49185. /**
  49186. * The scene the component belongs to.
  49187. */
  49188. scene: Scene;
  49189. /**
  49190. * Creates a new instance of the component for the given scene
  49191. * @param scene Defines the scene to register the component in
  49192. */
  49193. constructor(scene: Scene);
  49194. /**
  49195. * Registers the component in a given scene
  49196. */
  49197. register(): void;
  49198. /**
  49199. * Rebuilds the elements related to this component in case of
  49200. * context lost for instance.
  49201. */
  49202. rebuild(): void;
  49203. /**
  49204. * Serializes the component data to the specified json object
  49205. * @param serializationObject The object to serialize to
  49206. */
  49207. serialize(serializationObject: any): void;
  49208. /**
  49209. * Adds all the element from the container to the scene
  49210. * @param container the container holding the elements
  49211. */
  49212. addFromContainer(container: AbstractScene): void;
  49213. /**
  49214. * Removes all the elements in the container from the scene
  49215. * @param container contains the elements to remove
  49216. * @param dispose if the removed element should be disposed (default: false)
  49217. */
  49218. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49219. /**
  49220. * Rebuilds the elements related to this component in case of
  49221. * context lost for instance.
  49222. */
  49223. dispose(): void;
  49224. private _gatherRenderTargets;
  49225. }
  49226. }
  49227. declare module "babylonjs/Lights/Shadows/index" {
  49228. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49229. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49230. }
  49231. declare module "babylonjs/Lights/pointLight" {
  49232. import { Scene } from "babylonjs/scene";
  49233. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49235. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49236. import { Effect } from "babylonjs/Materials/effect";
  49237. /**
  49238. * A point light is a light defined by an unique point in world space.
  49239. * The light is emitted in every direction from this point.
  49240. * A good example of a point light is a standard light bulb.
  49241. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49242. */
  49243. export class PointLight extends ShadowLight {
  49244. private _shadowAngle;
  49245. /**
  49246. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49247. * This specifies what angle the shadow will use to be created.
  49248. *
  49249. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49250. */
  49251. /**
  49252. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49253. * This specifies what angle the shadow will use to be created.
  49254. *
  49255. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49256. */
  49257. shadowAngle: number;
  49258. /**
  49259. * Gets the direction if it has been set.
  49260. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49261. */
  49262. /**
  49263. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49264. */
  49265. direction: Vector3;
  49266. /**
  49267. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49268. * A PointLight emits the light in every direction.
  49269. * It can cast shadows.
  49270. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49271. * ```javascript
  49272. * var pointLight = new PointLight("pl", camera.position, scene);
  49273. * ```
  49274. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49275. * @param name The light friendly name
  49276. * @param position The position of the point light in the scene
  49277. * @param scene The scene the lights belongs to
  49278. */
  49279. constructor(name: string, position: Vector3, scene: Scene);
  49280. /**
  49281. * Returns the string "PointLight"
  49282. * @returns the class name
  49283. */
  49284. getClassName(): string;
  49285. /**
  49286. * Returns the integer 0.
  49287. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49288. */
  49289. getTypeID(): number;
  49290. /**
  49291. * Specifies wether or not the shadowmap should be a cube texture.
  49292. * @returns true if the shadowmap needs to be a cube texture.
  49293. */
  49294. needCube(): boolean;
  49295. /**
  49296. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49297. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49298. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49299. */
  49300. getShadowDirection(faceIndex?: number): Vector3;
  49301. /**
  49302. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49303. * - fov = PI / 2
  49304. * - aspect ratio : 1.0
  49305. * - z-near and far equal to the active camera minZ and maxZ.
  49306. * Returns the PointLight.
  49307. */
  49308. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49309. protected _buildUniformLayout(): void;
  49310. /**
  49311. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49312. * @param effect The effect to update
  49313. * @param lightIndex The index of the light in the effect to update
  49314. * @returns The point light
  49315. */
  49316. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49317. /**
  49318. * Prepares the list of defines specific to the light type.
  49319. * @param defines the list of defines
  49320. * @param lightIndex defines the index of the light for the effect
  49321. */
  49322. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49323. }
  49324. }
  49325. declare module "babylonjs/Lights/index" {
  49326. export * from "babylonjs/Lights/light";
  49327. export * from "babylonjs/Lights/shadowLight";
  49328. export * from "babylonjs/Lights/Shadows/index";
  49329. export * from "babylonjs/Lights/directionalLight";
  49330. export * from "babylonjs/Lights/hemisphericLight";
  49331. export * from "babylonjs/Lights/pointLight";
  49332. export * from "babylonjs/Lights/spotLight";
  49333. }
  49334. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49335. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49336. /**
  49337. * Header information of HDR texture files.
  49338. */
  49339. export interface HDRInfo {
  49340. /**
  49341. * The height of the texture in pixels.
  49342. */
  49343. height: number;
  49344. /**
  49345. * The width of the texture in pixels.
  49346. */
  49347. width: number;
  49348. /**
  49349. * The index of the beginning of the data in the binary file.
  49350. */
  49351. dataPosition: number;
  49352. }
  49353. /**
  49354. * This groups tools to convert HDR texture to native colors array.
  49355. */
  49356. export class HDRTools {
  49357. private static Ldexp;
  49358. private static Rgbe2float;
  49359. private static readStringLine;
  49360. /**
  49361. * Reads header information from an RGBE texture stored in a native array.
  49362. * More information on this format are available here:
  49363. * https://en.wikipedia.org/wiki/RGBE_image_format
  49364. *
  49365. * @param uint8array The binary file stored in native array.
  49366. * @return The header information.
  49367. */
  49368. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49369. /**
  49370. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49371. * This RGBE texture needs to store the information as a panorama.
  49372. *
  49373. * More information on this format are available here:
  49374. * https://en.wikipedia.org/wiki/RGBE_image_format
  49375. *
  49376. * @param buffer The binary file stored in an array buffer.
  49377. * @param size The expected size of the extracted cubemap.
  49378. * @return The Cube Map information.
  49379. */
  49380. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49381. /**
  49382. * Returns the pixels data extracted from an RGBE texture.
  49383. * This pixels will be stored left to right up to down in the R G B order in one array.
  49384. *
  49385. * More information on this format are available here:
  49386. * https://en.wikipedia.org/wiki/RGBE_image_format
  49387. *
  49388. * @param uint8array The binary file stored in an array buffer.
  49389. * @param hdrInfo The header information of the file.
  49390. * @return The pixels data in RGB right to left up to down order.
  49391. */
  49392. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49393. private static RGBE_ReadPixels_RLE;
  49394. }
  49395. }
  49396. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49397. import { Nullable } from "babylonjs/types";
  49398. import { Scene } from "babylonjs/scene";
  49399. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49401. /**
  49402. * This represents a texture coming from an HDR input.
  49403. *
  49404. * The only supported format is currently panorama picture stored in RGBE format.
  49405. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49406. */
  49407. export class HDRCubeTexture extends BaseTexture {
  49408. private static _facesMapping;
  49409. private _generateHarmonics;
  49410. private _noMipmap;
  49411. private _textureMatrix;
  49412. private _size;
  49413. private _onLoad;
  49414. private _onError;
  49415. /**
  49416. * The texture URL.
  49417. */
  49418. url: string;
  49419. /**
  49420. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49421. */
  49422. coordinatesMode: number;
  49423. protected _isBlocking: boolean;
  49424. /**
  49425. * Sets wether or not the texture is blocking during loading.
  49426. */
  49427. /**
  49428. * Gets wether or not the texture is blocking during loading.
  49429. */
  49430. isBlocking: boolean;
  49431. protected _rotationY: number;
  49432. /**
  49433. * Sets texture matrix rotation angle around Y axis in radians.
  49434. */
  49435. /**
  49436. * Gets texture matrix rotation angle around Y axis radians.
  49437. */
  49438. rotationY: number;
  49439. /**
  49440. * Gets or sets the center of the bounding box associated with the cube texture
  49441. * It must define where the camera used to render the texture was set
  49442. */
  49443. boundingBoxPosition: Vector3;
  49444. private _boundingBoxSize;
  49445. /**
  49446. * Gets or sets the size of the bounding box associated with the cube texture
  49447. * When defined, the cubemap will switch to local mode
  49448. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49449. * @example https://www.babylonjs-playground.com/#RNASML
  49450. */
  49451. boundingBoxSize: Vector3;
  49452. /**
  49453. * Instantiates an HDRTexture from the following parameters.
  49454. *
  49455. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49456. * @param scene The scene the texture will be used in
  49457. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49458. * @param noMipmap Forces to not generate the mipmap if true
  49459. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49460. * @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)
  49461. * @param reserved Reserved flag for internal use.
  49462. */
  49463. 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>);
  49464. /**
  49465. * Get the current class name of the texture useful for serialization or dynamic coding.
  49466. * @returns "HDRCubeTexture"
  49467. */
  49468. getClassName(): string;
  49469. /**
  49470. * Occurs when the file is raw .hdr file.
  49471. */
  49472. private loadTexture;
  49473. clone(): HDRCubeTexture;
  49474. delayLoad(): void;
  49475. /**
  49476. * Get the texture reflection matrix used to rotate/transform the reflection.
  49477. * @returns the reflection matrix
  49478. */
  49479. getReflectionTextureMatrix(): Matrix;
  49480. /**
  49481. * Set the texture reflection matrix used to rotate/transform the reflection.
  49482. * @param value Define the reflection matrix to set
  49483. */
  49484. setReflectionTextureMatrix(value: Matrix): void;
  49485. /**
  49486. * Parses a JSON representation of an HDR Texture in order to create the texture
  49487. * @param parsedTexture Define the JSON representation
  49488. * @param scene Define the scene the texture should be created in
  49489. * @param rootUrl Define the root url in case we need to load relative dependencies
  49490. * @returns the newly created texture after parsing
  49491. */
  49492. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49493. serialize(): any;
  49494. }
  49495. }
  49496. declare module "babylonjs/Physics/physicsEngine" {
  49497. import { Nullable } from "babylonjs/types";
  49498. import { Vector3 } from "babylonjs/Maths/math";
  49499. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49500. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49501. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49502. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49503. /**
  49504. * Class used to control physics engine
  49505. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49506. */
  49507. export class PhysicsEngine implements IPhysicsEngine {
  49508. private _physicsPlugin;
  49509. /**
  49510. * Global value used to control the smallest number supported by the simulation
  49511. */
  49512. static Epsilon: number;
  49513. private _impostors;
  49514. private _joints;
  49515. /**
  49516. * Gets the gravity vector used by the simulation
  49517. */
  49518. gravity: Vector3;
  49519. /**
  49520. * Factory used to create the default physics plugin.
  49521. * @returns The default physics plugin
  49522. */
  49523. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49524. /**
  49525. * Creates a new Physics Engine
  49526. * @param gravity defines the gravity vector used by the simulation
  49527. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49528. */
  49529. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49530. /**
  49531. * Sets the gravity vector used by the simulation
  49532. * @param gravity defines the gravity vector to use
  49533. */
  49534. setGravity(gravity: Vector3): void;
  49535. /**
  49536. * Set the time step of the physics engine.
  49537. * Default is 1/60.
  49538. * To slow it down, enter 1/600 for example.
  49539. * To speed it up, 1/30
  49540. * @param newTimeStep defines the new timestep to apply to this world.
  49541. */
  49542. setTimeStep(newTimeStep?: number): void;
  49543. /**
  49544. * Get the time step of the physics engine.
  49545. * @returns the current time step
  49546. */
  49547. getTimeStep(): number;
  49548. /**
  49549. * Release all resources
  49550. */
  49551. dispose(): void;
  49552. /**
  49553. * Gets the name of the current physics plugin
  49554. * @returns the name of the plugin
  49555. */
  49556. getPhysicsPluginName(): string;
  49557. /**
  49558. * Adding a new impostor for the impostor tracking.
  49559. * This will be done by the impostor itself.
  49560. * @param impostor the impostor to add
  49561. */
  49562. addImpostor(impostor: PhysicsImpostor): void;
  49563. /**
  49564. * Remove an impostor from the engine.
  49565. * This impostor and its mesh will not longer be updated by the physics engine.
  49566. * @param impostor the impostor to remove
  49567. */
  49568. removeImpostor(impostor: PhysicsImpostor): void;
  49569. /**
  49570. * Add a joint to the physics engine
  49571. * @param mainImpostor defines the main impostor to which the joint is added.
  49572. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49573. * @param joint defines the joint that will connect both impostors.
  49574. */
  49575. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49576. /**
  49577. * Removes a joint from the simulation
  49578. * @param mainImpostor defines the impostor used with the joint
  49579. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49580. * @param joint defines the joint to remove
  49581. */
  49582. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49583. /**
  49584. * Called by the scene. No need to call it.
  49585. * @param delta defines the timespam between frames
  49586. */
  49587. _step(delta: number): void;
  49588. /**
  49589. * Gets the current plugin used to run the simulation
  49590. * @returns current plugin
  49591. */
  49592. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49593. /**
  49594. * Gets the list of physic impostors
  49595. * @returns an array of PhysicsImpostor
  49596. */
  49597. getImpostors(): Array<PhysicsImpostor>;
  49598. /**
  49599. * Gets the impostor for a physics enabled object
  49600. * @param object defines the object impersonated by the impostor
  49601. * @returns the PhysicsImpostor or null if not found
  49602. */
  49603. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49604. /**
  49605. * Gets the impostor for a physics body object
  49606. * @param body defines physics body used by the impostor
  49607. * @returns the PhysicsImpostor or null if not found
  49608. */
  49609. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49610. /**
  49611. * Does a raycast in the physics world
  49612. * @param from when should the ray start?
  49613. * @param to when should the ray end?
  49614. * @returns PhysicsRaycastResult
  49615. */
  49616. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49617. }
  49618. }
  49619. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49620. import { Nullable } from "babylonjs/types";
  49621. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49623. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49624. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49625. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49626. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49627. /** @hidden */
  49628. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49629. private _useDeltaForWorldStep;
  49630. world: any;
  49631. name: string;
  49632. private _physicsMaterials;
  49633. private _fixedTimeStep;
  49634. private _cannonRaycastResult;
  49635. private _raycastResult;
  49636. private _removeAfterStep;
  49637. BJSCANNON: any;
  49638. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49639. setGravity(gravity: Vector3): void;
  49640. setTimeStep(timeStep: number): void;
  49641. getTimeStep(): number;
  49642. executeStep(delta: number): void;
  49643. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49644. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49645. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49646. private _processChildMeshes;
  49647. removePhysicsBody(impostor: PhysicsImpostor): void;
  49648. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49649. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49650. private _addMaterial;
  49651. private _checkWithEpsilon;
  49652. private _createShape;
  49653. private _createHeightmap;
  49654. private _minus90X;
  49655. private _plus90X;
  49656. private _tmpPosition;
  49657. private _tmpDeltaPosition;
  49658. private _tmpUnityRotation;
  49659. private _updatePhysicsBodyTransformation;
  49660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49662. isSupported(): boolean;
  49663. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49664. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49665. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49666. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49668. getBodyMass(impostor: PhysicsImpostor): number;
  49669. getBodyFriction(impostor: PhysicsImpostor): number;
  49670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49671. getBodyRestitution(impostor: PhysicsImpostor): number;
  49672. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49673. sleepBody(impostor: PhysicsImpostor): void;
  49674. wakeUpBody(impostor: PhysicsImpostor): void;
  49675. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49676. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49677. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49678. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49679. getRadius(impostor: PhysicsImpostor): number;
  49680. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49681. dispose(): void;
  49682. private _extendNamespace;
  49683. /**
  49684. * Does a raycast in the physics world
  49685. * @param from when should the ray start?
  49686. * @param to when should the ray end?
  49687. * @returns PhysicsRaycastResult
  49688. */
  49689. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49690. }
  49691. }
  49692. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49693. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49694. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49695. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49697. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49698. import { Nullable } from "babylonjs/types";
  49699. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49700. /** @hidden */
  49701. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49702. world: any;
  49703. name: string;
  49704. BJSOIMO: any;
  49705. private _raycastResult;
  49706. constructor(iterations?: number, oimoInjection?: any);
  49707. setGravity(gravity: Vector3): void;
  49708. setTimeStep(timeStep: number): void;
  49709. getTimeStep(): number;
  49710. private _tmpImpostorsArray;
  49711. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49712. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49715. private _tmpPositionVector;
  49716. removePhysicsBody(impostor: PhysicsImpostor): void;
  49717. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49718. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49719. isSupported(): boolean;
  49720. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49721. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49722. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49723. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49724. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49725. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49726. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49727. getBodyMass(impostor: PhysicsImpostor): number;
  49728. getBodyFriction(impostor: PhysicsImpostor): number;
  49729. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49730. getBodyRestitution(impostor: PhysicsImpostor): number;
  49731. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49732. sleepBody(impostor: PhysicsImpostor): void;
  49733. wakeUpBody(impostor: PhysicsImpostor): void;
  49734. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49735. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49736. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49738. getRadius(impostor: PhysicsImpostor): number;
  49739. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49740. dispose(): void;
  49741. /**
  49742. * Does a raycast in the physics world
  49743. * @param from when should the ray start?
  49744. * @param to when should the ray end?
  49745. * @returns PhysicsRaycastResult
  49746. */
  49747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49748. }
  49749. }
  49750. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49751. import { Nullable } from "babylonjs/types";
  49752. import { Scene } from "babylonjs/scene";
  49753. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49754. import { Mesh } from "babylonjs/Meshes/mesh";
  49755. /**
  49756. * Class containing static functions to help procedurally build meshes
  49757. */
  49758. export class RibbonBuilder {
  49759. /**
  49760. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49761. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49762. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49763. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49764. * * 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
  49765. * * 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
  49766. * * 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
  49767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49770. * * 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
  49771. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49772. * * 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
  49773. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49775. * @param name defines the name of the mesh
  49776. * @param options defines the options used to create the mesh
  49777. * @param scene defines the hosting scene
  49778. * @returns the ribbon mesh
  49779. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49781. */
  49782. static CreateRibbon(name: string, options: {
  49783. pathArray: Vector3[][];
  49784. closeArray?: boolean;
  49785. closePath?: boolean;
  49786. offset?: number;
  49787. updatable?: boolean;
  49788. sideOrientation?: number;
  49789. frontUVs?: Vector4;
  49790. backUVs?: Vector4;
  49791. instance?: Mesh;
  49792. invertUV?: boolean;
  49793. uvs?: Vector2[];
  49794. colors?: Color4[];
  49795. }, scene?: Nullable<Scene>): Mesh;
  49796. }
  49797. }
  49798. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49799. import { Nullable } from "babylonjs/types";
  49800. import { Scene } from "babylonjs/scene";
  49801. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49802. import { Mesh } from "babylonjs/Meshes/mesh";
  49803. /**
  49804. * Class containing static functions to help procedurally build meshes
  49805. */
  49806. export class ShapeBuilder {
  49807. /**
  49808. * 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.
  49809. * * 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.
  49810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49811. * * 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.
  49812. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49813. * * 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
  49814. * * 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
  49815. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49820. * @param name defines the name of the mesh
  49821. * @param options defines the options used to create the mesh
  49822. * @param scene defines the hosting scene
  49823. * @returns the extruded shape mesh
  49824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49826. */
  49827. static ExtrudeShape(name: string, options: {
  49828. shape: Vector3[];
  49829. path: Vector3[];
  49830. scale?: number;
  49831. rotation?: number;
  49832. cap?: number;
  49833. updatable?: boolean;
  49834. sideOrientation?: number;
  49835. frontUVs?: Vector4;
  49836. backUVs?: Vector4;
  49837. instance?: Mesh;
  49838. invertUV?: boolean;
  49839. }, scene?: Nullable<Scene>): Mesh;
  49840. /**
  49841. * Creates an custom extruded shape mesh.
  49842. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49843. * * 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.
  49844. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49845. * * 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
  49846. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49847. * * 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
  49848. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49849. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49850. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49851. * * 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
  49852. * * 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
  49853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49858. * @param name defines the name of the mesh
  49859. * @param options defines the options used to create the mesh
  49860. * @param scene defines the hosting scene
  49861. * @returns the custom extruded shape mesh
  49862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49865. */
  49866. static ExtrudeShapeCustom(name: string, options: {
  49867. shape: Vector3[];
  49868. path: Vector3[];
  49869. scaleFunction?: any;
  49870. rotationFunction?: any;
  49871. ribbonCloseArray?: boolean;
  49872. ribbonClosePath?: boolean;
  49873. cap?: number;
  49874. updatable?: boolean;
  49875. sideOrientation?: number;
  49876. frontUVs?: Vector4;
  49877. backUVs?: Vector4;
  49878. instance?: Mesh;
  49879. invertUV?: boolean;
  49880. }, scene: Scene): Mesh;
  49881. private static _ExtrudeShapeGeneric;
  49882. }
  49883. }
  49884. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  49885. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  49886. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49887. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49888. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49889. import { Nullable } from "babylonjs/types";
  49890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49891. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49892. /**
  49893. * AmmoJS Physics plugin
  49894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49895. * @see https://github.com/kripken/ammo.js/
  49896. */
  49897. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49898. private _useDeltaForWorldStep;
  49899. /**
  49900. * Reference to the Ammo library
  49901. */
  49902. bjsAMMO: any;
  49903. /**
  49904. * Created ammoJS world which physics bodies are added to
  49905. */
  49906. world: any;
  49907. /**
  49908. * Name of the plugin
  49909. */
  49910. name: string;
  49911. private _timeStep;
  49912. private _fixedTimeStep;
  49913. private _maxSteps;
  49914. private _tmpQuaternion;
  49915. private _tmpAmmoTransform;
  49916. private _tmpAmmoQuaternion;
  49917. private _tmpAmmoConcreteContactResultCallback;
  49918. private _collisionConfiguration;
  49919. private _dispatcher;
  49920. private _overlappingPairCache;
  49921. private _solver;
  49922. private _softBodySolver;
  49923. private _tmpAmmoVectorA;
  49924. private _tmpAmmoVectorB;
  49925. private _tmpAmmoVectorC;
  49926. private _tmpAmmoVectorD;
  49927. private _tmpContactCallbackResult;
  49928. private _tmpAmmoVectorRCA;
  49929. private _tmpAmmoVectorRCB;
  49930. private _raycastResult;
  49931. private static readonly DISABLE_COLLISION_FLAG;
  49932. private static readonly KINEMATIC_FLAG;
  49933. private static readonly DISABLE_DEACTIVATION_FLAG;
  49934. /**
  49935. * Initializes the ammoJS plugin
  49936. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49937. * @param ammoInjection can be used to inject your own ammo reference
  49938. */
  49939. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49940. /**
  49941. * Sets the gravity of the physics world (m/(s^2))
  49942. * @param gravity Gravity to set
  49943. */
  49944. setGravity(gravity: Vector3): void;
  49945. /**
  49946. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49947. * @param timeStep timestep to use in seconds
  49948. */
  49949. setTimeStep(timeStep: number): void;
  49950. /**
  49951. * 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)
  49952. * @param fixedTimeStep fixedTimeStep to use in seconds
  49953. */
  49954. setFixedTimeStep(fixedTimeStep: number): void;
  49955. /**
  49956. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49957. * @param maxSteps the maximum number of steps by the physics engine per frame
  49958. */
  49959. setMaxSteps(maxSteps: number): void;
  49960. /**
  49961. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49962. * @returns the current timestep in seconds
  49963. */
  49964. getTimeStep(): number;
  49965. private _isImpostorInContact;
  49966. private _isImpostorPairInContact;
  49967. private _stepSimulation;
  49968. /**
  49969. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49970. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49971. * After the step the babylon meshes are set to the position of the physics imposters
  49972. * @param delta amount of time to step forward
  49973. * @param impostors array of imposters to update before/after the step
  49974. */
  49975. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49976. /**
  49977. * Update babylon mesh to match physics world object
  49978. * @param impostor imposter to match
  49979. */
  49980. private _afterSoftStep;
  49981. /**
  49982. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49983. * @param impostor imposter to match
  49984. */
  49985. private _ropeStep;
  49986. /**
  49987. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49988. * @param impostor imposter to match
  49989. */
  49990. private _softbodyOrClothStep;
  49991. private _tmpVector;
  49992. private _tmpMatrix;
  49993. /**
  49994. * Applies an impulse on the imposter
  49995. * @param impostor imposter to apply impulse to
  49996. * @param force amount of force to be applied to the imposter
  49997. * @param contactPoint the location to apply the impulse on the imposter
  49998. */
  49999. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50000. /**
  50001. * Applies a force on the imposter
  50002. * @param impostor imposter to apply force
  50003. * @param force amount of force to be applied to the imposter
  50004. * @param contactPoint the location to apply the force on the imposter
  50005. */
  50006. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50007. /**
  50008. * Creates a physics body using the plugin
  50009. * @param impostor the imposter to create the physics body on
  50010. */
  50011. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50012. /**
  50013. * Removes the physics body from the imposter and disposes of the body's memory
  50014. * @param impostor imposter to remove the physics body from
  50015. */
  50016. removePhysicsBody(impostor: PhysicsImpostor): void;
  50017. /**
  50018. * Generates a joint
  50019. * @param impostorJoint the imposter joint to create the joint with
  50020. */
  50021. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50022. /**
  50023. * Removes a joint
  50024. * @param impostorJoint the imposter joint to remove the joint from
  50025. */
  50026. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50027. private _addMeshVerts;
  50028. /**
  50029. * Initialise the soft body vertices to match its object's (mesh) vertices
  50030. * Softbody vertices (nodes) are in world space and to match this
  50031. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50032. * @param impostor to create the softbody for
  50033. */
  50034. private _softVertexData;
  50035. /**
  50036. * Create an impostor's soft body
  50037. * @param impostor to create the softbody for
  50038. */
  50039. private _createSoftbody;
  50040. /**
  50041. * Create cloth for an impostor
  50042. * @param impostor to create the softbody for
  50043. */
  50044. private _createCloth;
  50045. /**
  50046. * Create rope for an impostor
  50047. * @param impostor to create the softbody for
  50048. */
  50049. private _createRope;
  50050. private _addHullVerts;
  50051. private _createShape;
  50052. /**
  50053. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50054. * @param impostor imposter containing the physics body and babylon object
  50055. */
  50056. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50057. /**
  50058. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50059. * @param impostor imposter containing the physics body and babylon object
  50060. * @param newPosition new position
  50061. * @param newRotation new rotation
  50062. */
  50063. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50064. /**
  50065. * If this plugin is supported
  50066. * @returns true if its supported
  50067. */
  50068. isSupported(): boolean;
  50069. /**
  50070. * Sets the linear velocity of the physics body
  50071. * @param impostor imposter to set the velocity on
  50072. * @param velocity velocity to set
  50073. */
  50074. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50075. /**
  50076. * Sets the angular velocity of the physics body
  50077. * @param impostor imposter to set the velocity on
  50078. * @param velocity velocity to set
  50079. */
  50080. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50081. /**
  50082. * gets the linear velocity
  50083. * @param impostor imposter to get linear velocity from
  50084. * @returns linear velocity
  50085. */
  50086. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50087. /**
  50088. * gets the angular velocity
  50089. * @param impostor imposter to get angular velocity from
  50090. * @returns angular velocity
  50091. */
  50092. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50093. /**
  50094. * Sets the mass of physics body
  50095. * @param impostor imposter to set the mass on
  50096. * @param mass mass to set
  50097. */
  50098. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50099. /**
  50100. * Gets the mass of the physics body
  50101. * @param impostor imposter to get the mass from
  50102. * @returns mass
  50103. */
  50104. getBodyMass(impostor: PhysicsImpostor): number;
  50105. /**
  50106. * Gets friction of the impostor
  50107. * @param impostor impostor to get friction from
  50108. * @returns friction value
  50109. */
  50110. getBodyFriction(impostor: PhysicsImpostor): number;
  50111. /**
  50112. * Sets friction of the impostor
  50113. * @param impostor impostor to set friction on
  50114. * @param friction friction value
  50115. */
  50116. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50117. /**
  50118. * Gets restitution of the impostor
  50119. * @param impostor impostor to get restitution from
  50120. * @returns restitution value
  50121. */
  50122. getBodyRestitution(impostor: PhysicsImpostor): number;
  50123. /**
  50124. * Sets resitution of the impostor
  50125. * @param impostor impostor to set resitution on
  50126. * @param restitution resitution value
  50127. */
  50128. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50129. /**
  50130. * Gets pressure inside the impostor
  50131. * @param impostor impostor to get pressure from
  50132. * @returns pressure value
  50133. */
  50134. getBodyPressure(impostor: PhysicsImpostor): number;
  50135. /**
  50136. * Sets pressure inside a soft body impostor
  50137. * Cloth and rope must remain 0 pressure
  50138. * @param impostor impostor to set pressure on
  50139. * @param pressure pressure value
  50140. */
  50141. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50142. /**
  50143. * Gets stiffness of the impostor
  50144. * @param impostor impostor to get stiffness from
  50145. * @returns pressure value
  50146. */
  50147. getBodyStiffness(impostor: PhysicsImpostor): number;
  50148. /**
  50149. * Sets stiffness of the impostor
  50150. * @param impostor impostor to set stiffness on
  50151. * @param stiffness stiffness value from 0 to 1
  50152. */
  50153. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50154. /**
  50155. * Gets velocityIterations of the impostor
  50156. * @param impostor impostor to get velocity iterations from
  50157. * @returns velocityIterations value
  50158. */
  50159. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50160. /**
  50161. * Sets velocityIterations of the impostor
  50162. * @param impostor impostor to set velocity iterations on
  50163. * @param velocityIterations velocityIterations value
  50164. */
  50165. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50166. /**
  50167. * Gets positionIterations of the impostor
  50168. * @param impostor impostor to get position iterations from
  50169. * @returns positionIterations value
  50170. */
  50171. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50172. /**
  50173. * Sets positionIterations of the impostor
  50174. * @param impostor impostor to set position on
  50175. * @param positionIterations positionIterations value
  50176. */
  50177. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50178. /**
  50179. * Append an anchor to a cloth object
  50180. * @param impostor is the cloth impostor to add anchor to
  50181. * @param otherImpostor is the rigid impostor to anchor to
  50182. * @param width ratio across width from 0 to 1
  50183. * @param height ratio up height from 0 to 1
  50184. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50185. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50186. */
  50187. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50188. /**
  50189. * Append an hook to a rope object
  50190. * @param impostor is the rope impostor to add hook to
  50191. * @param otherImpostor is the rigid impostor to hook to
  50192. * @param length ratio along the rope from 0 to 1
  50193. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50194. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50195. */
  50196. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50197. /**
  50198. * Sleeps the physics body and stops it from being active
  50199. * @param impostor impostor to sleep
  50200. */
  50201. sleepBody(impostor: PhysicsImpostor): void;
  50202. /**
  50203. * Activates the physics body
  50204. * @param impostor impostor to activate
  50205. */
  50206. wakeUpBody(impostor: PhysicsImpostor): void;
  50207. /**
  50208. * Updates the distance parameters of the joint
  50209. * @param joint joint to update
  50210. * @param maxDistance maximum distance of the joint
  50211. * @param minDistance minimum distance of the joint
  50212. */
  50213. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50214. /**
  50215. * Sets a motor on the joint
  50216. * @param joint joint to set motor on
  50217. * @param speed speed of the motor
  50218. * @param maxForce maximum force of the motor
  50219. * @param motorIndex index of the motor
  50220. */
  50221. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50222. /**
  50223. * Sets the motors limit
  50224. * @param joint joint to set limit on
  50225. * @param upperLimit upper limit
  50226. * @param lowerLimit lower limit
  50227. */
  50228. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50229. /**
  50230. * Syncs the position and rotation of a mesh with the impostor
  50231. * @param mesh mesh to sync
  50232. * @param impostor impostor to update the mesh with
  50233. */
  50234. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50235. /**
  50236. * Gets the radius of the impostor
  50237. * @param impostor impostor to get radius from
  50238. * @returns the radius
  50239. */
  50240. getRadius(impostor: PhysicsImpostor): number;
  50241. /**
  50242. * Gets the box size of the impostor
  50243. * @param impostor impostor to get box size from
  50244. * @param result the resulting box size
  50245. */
  50246. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50247. /**
  50248. * Disposes of the impostor
  50249. */
  50250. dispose(): void;
  50251. /**
  50252. * Does a raycast in the physics world
  50253. * @param from when should the ray start?
  50254. * @param to when should the ray end?
  50255. * @returns PhysicsRaycastResult
  50256. */
  50257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50258. }
  50259. }
  50260. declare module "babylonjs/Probes/reflectionProbe" {
  50261. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50262. import { Vector3 } from "babylonjs/Maths/math";
  50263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50264. import { Nullable } from "babylonjs/types";
  50265. import { Scene } from "babylonjs/scene";
  50266. module "babylonjs/abstractScene" {
  50267. interface AbstractScene {
  50268. /**
  50269. * The list of reflection probes added to the scene
  50270. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50271. */
  50272. reflectionProbes: Array<ReflectionProbe>;
  50273. /**
  50274. * Removes the given reflection probe from this scene.
  50275. * @param toRemove The reflection probe to remove
  50276. * @returns The index of the removed reflection probe
  50277. */
  50278. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50279. /**
  50280. * Adds the given reflection probe to this scene.
  50281. * @param newReflectionProbe The reflection probe to add
  50282. */
  50283. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50284. }
  50285. }
  50286. /**
  50287. * Class used to generate realtime reflection / refraction cube textures
  50288. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50289. */
  50290. export class ReflectionProbe {
  50291. /** defines the name of the probe */
  50292. name: string;
  50293. private _scene;
  50294. private _renderTargetTexture;
  50295. private _projectionMatrix;
  50296. private _viewMatrix;
  50297. private _target;
  50298. private _add;
  50299. private _attachedMesh;
  50300. private _invertYAxis;
  50301. /** Gets or sets probe position (center of the cube map) */
  50302. position: Vector3;
  50303. /**
  50304. * Creates a new reflection probe
  50305. * @param name defines the name of the probe
  50306. * @param size defines the texture resolution (for each face)
  50307. * @param scene defines the hosting scene
  50308. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50309. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50310. */
  50311. constructor(
  50312. /** defines the name of the probe */
  50313. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50314. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50315. samples: number;
  50316. /** Gets or sets the refresh rate to use (on every frame by default) */
  50317. refreshRate: number;
  50318. /**
  50319. * Gets the hosting scene
  50320. * @returns a Scene
  50321. */
  50322. getScene(): Scene;
  50323. /** Gets the internal CubeTexture used to render to */
  50324. readonly cubeTexture: RenderTargetTexture;
  50325. /** Gets the list of meshes to render */
  50326. readonly renderList: Nullable<AbstractMesh[]>;
  50327. /**
  50328. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50329. * @param mesh defines the mesh to attach to
  50330. */
  50331. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50332. /**
  50333. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50334. * @param renderingGroupId The rendering group id corresponding to its index
  50335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50336. */
  50337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50338. /**
  50339. * Clean all associated resources
  50340. */
  50341. dispose(): void;
  50342. /**
  50343. * Converts the reflection probe information to a readable string for debug purpose.
  50344. * @param fullDetails Supports for multiple levels of logging within scene loading
  50345. * @returns the human readable reflection probe info
  50346. */
  50347. toString(fullDetails?: boolean): string;
  50348. /**
  50349. * Get the class name of the relfection probe.
  50350. * @returns "ReflectionProbe"
  50351. */
  50352. getClassName(): string;
  50353. /**
  50354. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50355. * @returns The JSON representation of the texture
  50356. */
  50357. serialize(): any;
  50358. /**
  50359. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50360. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50361. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50362. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50363. * @returns The parsed reflection probe if successful
  50364. */
  50365. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50366. }
  50367. }
  50368. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50369. /** @hidden */
  50370. export var _BabylonLoaderRegistered: boolean;
  50371. }
  50372. declare module "babylonjs/Loading/Plugins/index" {
  50373. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50374. }
  50375. declare module "babylonjs/Loading/index" {
  50376. export * from "babylonjs/Loading/loadingScreen";
  50377. export * from "babylonjs/Loading/Plugins/index";
  50378. export * from "babylonjs/Loading/sceneLoader";
  50379. export * from "babylonjs/Loading/sceneLoaderFlags";
  50380. }
  50381. declare module "babylonjs/Materials/Background/index" {
  50382. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50383. }
  50384. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50385. import { Scene } from "babylonjs/scene";
  50386. import { Color3 } from "babylonjs/Maths/math";
  50387. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50389. /**
  50390. * The Physically based simple base material of BJS.
  50391. *
  50392. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50393. * It is used as the base class for both the specGloss and metalRough conventions.
  50394. */
  50395. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50396. /**
  50397. * Number of Simultaneous lights allowed on the material.
  50398. */
  50399. maxSimultaneousLights: number;
  50400. /**
  50401. * If sets to true, disables all the lights affecting the material.
  50402. */
  50403. disableLighting: boolean;
  50404. /**
  50405. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50406. */
  50407. environmentTexture: BaseTexture;
  50408. /**
  50409. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50410. */
  50411. invertNormalMapX: boolean;
  50412. /**
  50413. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50414. */
  50415. invertNormalMapY: boolean;
  50416. /**
  50417. * Normal map used in the model.
  50418. */
  50419. normalTexture: BaseTexture;
  50420. /**
  50421. * Emissivie color used to self-illuminate the model.
  50422. */
  50423. emissiveColor: Color3;
  50424. /**
  50425. * Emissivie texture used to self-illuminate the model.
  50426. */
  50427. emissiveTexture: BaseTexture;
  50428. /**
  50429. * Occlusion Channel Strenght.
  50430. */
  50431. occlusionStrength: number;
  50432. /**
  50433. * Occlusion Texture of the material (adding extra occlusion effects).
  50434. */
  50435. occlusionTexture: BaseTexture;
  50436. /**
  50437. * Defines the alpha limits in alpha test mode.
  50438. */
  50439. alphaCutOff: number;
  50440. /**
  50441. * Gets the current double sided mode.
  50442. */
  50443. /**
  50444. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50445. */
  50446. doubleSided: boolean;
  50447. /**
  50448. * Stores the pre-calculated light information of a mesh in a texture.
  50449. */
  50450. lightmapTexture: BaseTexture;
  50451. /**
  50452. * If true, the light map contains occlusion information instead of lighting info.
  50453. */
  50454. useLightmapAsShadowmap: boolean;
  50455. /**
  50456. * Instantiates a new PBRMaterial instance.
  50457. *
  50458. * @param name The material name
  50459. * @param scene The scene the material will be use in.
  50460. */
  50461. constructor(name: string, scene: Scene);
  50462. getClassName(): string;
  50463. }
  50464. }
  50465. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50466. import { Scene } from "babylonjs/scene";
  50467. import { Color3 } from "babylonjs/Maths/math";
  50468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50469. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50470. /**
  50471. * The PBR material of BJS following the metal roughness convention.
  50472. *
  50473. * This fits to the PBR convention in the GLTF definition:
  50474. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50475. */
  50476. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50477. /**
  50478. * The base color has two different interpretations depending on the value of metalness.
  50479. * When the material is a metal, the base color is the specific measured reflectance value
  50480. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50481. * of the material.
  50482. */
  50483. baseColor: Color3;
  50484. /**
  50485. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50486. * well as opacity information in the alpha channel.
  50487. */
  50488. baseTexture: BaseTexture;
  50489. /**
  50490. * Specifies the metallic scalar value of the material.
  50491. * Can also be used to scale the metalness values of the metallic texture.
  50492. */
  50493. metallic: number;
  50494. /**
  50495. * Specifies the roughness scalar value of the material.
  50496. * Can also be used to scale the roughness values of the metallic texture.
  50497. */
  50498. roughness: number;
  50499. /**
  50500. * Texture containing both the metallic value in the B channel and the
  50501. * roughness value in the G channel to keep better precision.
  50502. */
  50503. metallicRoughnessTexture: BaseTexture;
  50504. /**
  50505. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50506. *
  50507. * @param name The material name
  50508. * @param scene The scene the material will be use in.
  50509. */
  50510. constructor(name: string, scene: Scene);
  50511. /**
  50512. * Return the currrent class name of the material.
  50513. */
  50514. getClassName(): string;
  50515. /**
  50516. * Makes a duplicate of the current material.
  50517. * @param name - name to use for the new material.
  50518. */
  50519. clone(name: string): PBRMetallicRoughnessMaterial;
  50520. /**
  50521. * Serialize the material to a parsable JSON object.
  50522. */
  50523. serialize(): any;
  50524. /**
  50525. * Parses a JSON object correponding to the serialize function.
  50526. */
  50527. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50528. }
  50529. }
  50530. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50531. import { Scene } from "babylonjs/scene";
  50532. import { Color3 } from "babylonjs/Maths/math";
  50533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50534. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50535. /**
  50536. * The PBR material of BJS following the specular glossiness convention.
  50537. *
  50538. * This fits to the PBR convention in the GLTF definition:
  50539. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50540. */
  50541. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50542. /**
  50543. * Specifies the diffuse color of the material.
  50544. */
  50545. diffuseColor: Color3;
  50546. /**
  50547. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50548. * channel.
  50549. */
  50550. diffuseTexture: BaseTexture;
  50551. /**
  50552. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50553. */
  50554. specularColor: Color3;
  50555. /**
  50556. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50557. */
  50558. glossiness: number;
  50559. /**
  50560. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50561. */
  50562. specularGlossinessTexture: BaseTexture;
  50563. /**
  50564. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50565. *
  50566. * @param name The material name
  50567. * @param scene The scene the material will be use in.
  50568. */
  50569. constructor(name: string, scene: Scene);
  50570. /**
  50571. * Return the currrent class name of the material.
  50572. */
  50573. getClassName(): string;
  50574. /**
  50575. * Makes a duplicate of the current material.
  50576. * @param name - name to use for the new material.
  50577. */
  50578. clone(name: string): PBRSpecularGlossinessMaterial;
  50579. /**
  50580. * Serialize the material to a parsable JSON object.
  50581. */
  50582. serialize(): any;
  50583. /**
  50584. * Parses a JSON object correponding to the serialize function.
  50585. */
  50586. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50587. }
  50588. }
  50589. declare module "babylonjs/Materials/PBR/index" {
  50590. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50591. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50592. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50593. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50594. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50595. }
  50596. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50597. import { Nullable } from "babylonjs/types";
  50598. import { Scene } from "babylonjs/scene";
  50599. import { Matrix } from "babylonjs/Maths/math";
  50600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50601. /**
  50602. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50603. * It can help converting any input color in a desired output one. This can then be used to create effects
  50604. * from sepia, black and white to sixties or futuristic rendering...
  50605. *
  50606. * The only supported format is currently 3dl.
  50607. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50608. */
  50609. export class ColorGradingTexture extends BaseTexture {
  50610. /**
  50611. * The current texture matrix. (will always be identity in color grading texture)
  50612. */
  50613. private _textureMatrix;
  50614. /**
  50615. * The texture URL.
  50616. */
  50617. url: string;
  50618. /**
  50619. * Empty line regex stored for GC.
  50620. */
  50621. private static _noneEmptyLineRegex;
  50622. private _engine;
  50623. /**
  50624. * Instantiates a ColorGradingTexture from the following parameters.
  50625. *
  50626. * @param url The location of the color gradind data (currently only supporting 3dl)
  50627. * @param scene The scene the texture will be used in
  50628. */
  50629. constructor(url: string, scene: Scene);
  50630. /**
  50631. * Returns the texture matrix used in most of the material.
  50632. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50633. */
  50634. getTextureMatrix(): Matrix;
  50635. /**
  50636. * Occurs when the file being loaded is a .3dl LUT file.
  50637. */
  50638. private load3dlTexture;
  50639. /**
  50640. * Starts the loading process of the texture.
  50641. */
  50642. private loadTexture;
  50643. /**
  50644. * Clones the color gradind texture.
  50645. */
  50646. clone(): ColorGradingTexture;
  50647. /**
  50648. * Called during delayed load for textures.
  50649. */
  50650. delayLoad(): void;
  50651. /**
  50652. * Parses a color grading texture serialized by Babylon.
  50653. * @param parsedTexture The texture information being parsedTexture
  50654. * @param scene The scene to load the texture in
  50655. * @param rootUrl The root url of the data assets to load
  50656. * @return A color gradind texture
  50657. */
  50658. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50659. /**
  50660. * Serializes the LUT texture to json format.
  50661. */
  50662. serialize(): any;
  50663. }
  50664. }
  50665. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50667. import { Scene } from "babylonjs/scene";
  50668. import { Nullable } from "babylonjs/types";
  50669. /**
  50670. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50671. */
  50672. export class EquiRectangularCubeTexture extends BaseTexture {
  50673. /** The six faces of the cube. */
  50674. private static _FacesMapping;
  50675. private _noMipmap;
  50676. private _onLoad;
  50677. private _onError;
  50678. /** The size of the cubemap. */
  50679. private _size;
  50680. /** The buffer of the image. */
  50681. private _buffer;
  50682. /** The width of the input image. */
  50683. private _width;
  50684. /** The height of the input image. */
  50685. private _height;
  50686. /** The URL to the image. */
  50687. url: string;
  50688. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50689. coordinatesMode: number;
  50690. /**
  50691. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50692. * @param url The location of the image
  50693. * @param scene The scene the texture will be used in
  50694. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50695. * @param noMipmap Forces to not generate the mipmap if true
  50696. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50697. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50698. * @param onLoad — defines a callback called when texture is loaded
  50699. * @param onError — defines a callback called if there is an error
  50700. */
  50701. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50702. /**
  50703. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50704. */
  50705. private loadImage;
  50706. /**
  50707. * Convert the image buffer into a cubemap and create a CubeTexture.
  50708. */
  50709. private loadTexture;
  50710. /**
  50711. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50712. * @param buffer The ArrayBuffer that should be converted.
  50713. * @returns The buffer as Float32Array.
  50714. */
  50715. private getFloat32ArrayFromArrayBuffer;
  50716. /**
  50717. * Get the current class name of the texture useful for serialization or dynamic coding.
  50718. * @returns "EquiRectangularCubeTexture"
  50719. */
  50720. getClassName(): string;
  50721. /**
  50722. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50723. * @returns A clone of the current EquiRectangularCubeTexture.
  50724. */
  50725. clone(): EquiRectangularCubeTexture;
  50726. }
  50727. }
  50728. declare module "babylonjs/Misc/tga" {
  50729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50730. /**
  50731. * Based on jsTGALoader - Javascript loader for TGA file
  50732. * By Vincent Thibault
  50733. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50734. */
  50735. export class TGATools {
  50736. private static _TYPE_INDEXED;
  50737. private static _TYPE_RGB;
  50738. private static _TYPE_GREY;
  50739. private static _TYPE_RLE_INDEXED;
  50740. private static _TYPE_RLE_RGB;
  50741. private static _TYPE_RLE_GREY;
  50742. private static _ORIGIN_MASK;
  50743. private static _ORIGIN_SHIFT;
  50744. private static _ORIGIN_BL;
  50745. private static _ORIGIN_BR;
  50746. private static _ORIGIN_UL;
  50747. private static _ORIGIN_UR;
  50748. /**
  50749. * Gets the header of a TGA file
  50750. * @param data defines the TGA data
  50751. * @returns the header
  50752. */
  50753. static GetTGAHeader(data: Uint8Array): any;
  50754. /**
  50755. * Uploads TGA content to a Babylon Texture
  50756. * @hidden
  50757. */
  50758. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50759. /** @hidden */
  50760. 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;
  50761. /** @hidden */
  50762. 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;
  50763. /** @hidden */
  50764. 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;
  50765. /** @hidden */
  50766. 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;
  50767. /** @hidden */
  50768. 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;
  50769. /** @hidden */
  50770. 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;
  50771. }
  50772. }
  50773. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  50774. import { Nullable } from "babylonjs/types";
  50775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50776. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50777. /**
  50778. * Implementation of the TGA Texture Loader.
  50779. * @hidden
  50780. */
  50781. export class _TGATextureLoader implements IInternalTextureLoader {
  50782. /**
  50783. * Defines wether the loader supports cascade loading the different faces.
  50784. */
  50785. readonly supportCascades: boolean;
  50786. /**
  50787. * This returns if the loader support the current file information.
  50788. * @param extension defines the file extension of the file being loaded
  50789. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50790. * @param fallback defines the fallback internal texture if any
  50791. * @param isBase64 defines whether the texture is encoded as a base64
  50792. * @param isBuffer defines whether the texture data are stored as a buffer
  50793. * @returns true if the loader can load the specified file
  50794. */
  50795. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50796. /**
  50797. * Transform the url before loading if required.
  50798. * @param rootUrl the url of the texture
  50799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50800. * @returns the transformed texture
  50801. */
  50802. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50803. /**
  50804. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50805. * @param rootUrl the url of the texture
  50806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50807. * @returns the fallback texture
  50808. */
  50809. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50810. /**
  50811. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50812. * @param data contains the texture data
  50813. * @param texture defines the BabylonJS internal texture
  50814. * @param createPolynomials will be true if polynomials have been requested
  50815. * @param onLoad defines the callback to trigger once the texture is ready
  50816. * @param onError defines the callback to trigger in case of error
  50817. */
  50818. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50819. /**
  50820. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50821. * @param data contains the texture data
  50822. * @param texture defines the BabylonJS internal texture
  50823. * @param callback defines the method to call once ready to upload
  50824. */
  50825. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50826. }
  50827. }
  50828. declare module "babylonjs/Materials/Textures/Loaders/index" {
  50829. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50830. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50831. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50832. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  50833. }
  50834. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  50835. import { Scene } from "babylonjs/scene";
  50836. import { Texture } from "babylonjs/Materials/Textures/texture";
  50837. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50838. /**
  50839. * 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.
  50840. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50841. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50842. */
  50843. export class CustomProceduralTexture extends ProceduralTexture {
  50844. private _animate;
  50845. private _time;
  50846. private _config;
  50847. private _texturePath;
  50848. /**
  50849. * Instantiates a new Custom Procedural Texture.
  50850. * 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.
  50851. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50853. * @param name Define the name of the texture
  50854. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50855. * @param size Define the size of the texture to create
  50856. * @param scene Define the scene the texture belongs to
  50857. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50858. * @param generateMipMaps Define if the texture should creates mip maps or not
  50859. */
  50860. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50861. private _loadJson;
  50862. /**
  50863. * Is the texture ready to be used ? (rendered at least once)
  50864. * @returns true if ready, otherwise, false.
  50865. */
  50866. isReady(): boolean;
  50867. /**
  50868. * Render the texture to its associated render target.
  50869. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50870. */
  50871. render(useCameraPostProcess?: boolean): void;
  50872. /**
  50873. * Update the list of dependant textures samplers in the shader.
  50874. */
  50875. updateTextures(): void;
  50876. /**
  50877. * Update the uniform values of the procedural texture in the shader.
  50878. */
  50879. updateShaderUniforms(): void;
  50880. /**
  50881. * Define if the texture animates or not.
  50882. */
  50883. animate: boolean;
  50884. }
  50885. }
  50886. declare module "babylonjs/Shaders/noise.fragment" {
  50887. /** @hidden */
  50888. export var noisePixelShader: {
  50889. name: string;
  50890. shader: string;
  50891. };
  50892. }
  50893. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  50894. import { Nullable } from "babylonjs/types";
  50895. import { Scene } from "babylonjs/scene";
  50896. import { Texture } from "babylonjs/Materials/Textures/texture";
  50897. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50898. import "babylonjs/Shaders/noise.fragment";
  50899. /**
  50900. * Class used to generate noise procedural textures
  50901. */
  50902. export class NoiseProceduralTexture extends ProceduralTexture {
  50903. private _time;
  50904. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50905. brightness: number;
  50906. /** Defines the number of octaves to process */
  50907. octaves: number;
  50908. /** Defines the level of persistence (0.8 by default) */
  50909. persistence: number;
  50910. /** Gets or sets animation speed factor (default is 1) */
  50911. animationSpeedFactor: number;
  50912. /**
  50913. * Creates a new NoiseProceduralTexture
  50914. * @param name defines the name fo the texture
  50915. * @param size defines the size of the texture (default is 256)
  50916. * @param scene defines the hosting scene
  50917. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50918. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50919. */
  50920. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50921. private _updateShaderUniforms;
  50922. protected _getDefines(): string;
  50923. /** Generate the current state of the procedural texture */
  50924. render(useCameraPostProcess?: boolean): void;
  50925. /**
  50926. * Serializes this noise procedural texture
  50927. * @returns a serialized noise procedural texture object
  50928. */
  50929. serialize(): any;
  50930. /**
  50931. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50932. * @param parsedTexture defines parsed texture data
  50933. * @param scene defines the current scene
  50934. * @param rootUrl defines the root URL containing noise procedural texture information
  50935. * @returns a parsed NoiseProceduralTexture
  50936. */
  50937. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50938. }
  50939. }
  50940. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  50941. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  50942. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  50943. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50944. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  50945. }
  50946. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  50947. import { Nullable } from "babylonjs/types";
  50948. import { Scene } from "babylonjs/scene";
  50949. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50951. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  50952. /**
  50953. * Raw cube texture where the raw buffers are passed in
  50954. */
  50955. export class RawCubeTexture extends CubeTexture {
  50956. /**
  50957. * Creates a cube texture where the raw buffers are passed in.
  50958. * @param scene defines the scene the texture is attached to
  50959. * @param data defines the array of data to use to create each face
  50960. * @param size defines the size of the textures
  50961. * @param format defines the format of the data
  50962. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50963. * @param generateMipMaps defines if the engine should generate the mip levels
  50964. * @param invertY defines if data must be stored with Y axis inverted
  50965. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50966. * @param compression defines the compression used (null by default)
  50967. */
  50968. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50969. /**
  50970. * Updates the raw cube texture.
  50971. * @param data defines the data to store
  50972. * @param format defines the data format
  50973. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50974. * @param invertY defines if data must be stored with Y axis inverted
  50975. * @param compression defines the compression used (null by default)
  50976. * @param level defines which level of the texture to update
  50977. */
  50978. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50979. /**
  50980. * Updates a raw cube texture with RGBD encoded data.
  50981. * @param data defines the array of data [mipmap][face] to use to create each face
  50982. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50983. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50984. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50985. * @returns a promsie that resolves when the operation is complete
  50986. */
  50987. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50988. /**
  50989. * Clones the raw cube texture.
  50990. * @return a new cube texture
  50991. */
  50992. clone(): CubeTexture;
  50993. /** @hidden */
  50994. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50995. }
  50996. }
  50997. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50998. import { Scene } from "babylonjs/scene";
  50999. import { Texture } from "babylonjs/Materials/Textures/texture";
  51000. /**
  51001. * Class used to store 3D textures containing user data
  51002. */
  51003. export class RawTexture3D extends Texture {
  51004. /** Gets or sets the texture format to use */
  51005. format: number;
  51006. private _engine;
  51007. /**
  51008. * Create a new RawTexture3D
  51009. * @param data defines the data of the texture
  51010. * @param width defines the width of the texture
  51011. * @param height defines the height of the texture
  51012. * @param depth defines the depth of the texture
  51013. * @param format defines the texture format to use
  51014. * @param scene defines the hosting scene
  51015. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51016. * @param invertY defines if texture must be stored with Y axis inverted
  51017. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51018. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51019. */
  51020. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51021. /** Gets or sets the texture format to use */
  51022. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51023. /**
  51024. * Update the texture with new data
  51025. * @param data defines the data to store in the texture
  51026. */
  51027. update(data: ArrayBufferView): void;
  51028. }
  51029. }
  51030. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51031. import { Scene } from "babylonjs/scene";
  51032. import { Plane } from "babylonjs/Maths/math";
  51033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51034. /**
  51035. * Creates a refraction texture used by refraction channel of the standard material.
  51036. * It is like a mirror but to see through a material.
  51037. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51038. */
  51039. export class RefractionTexture extends RenderTargetTexture {
  51040. /**
  51041. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51042. * 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.
  51043. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51044. */
  51045. refractionPlane: Plane;
  51046. /**
  51047. * Define how deep under the surface we should see.
  51048. */
  51049. depth: number;
  51050. /**
  51051. * Creates a refraction texture used by refraction channel of the standard material.
  51052. * It is like a mirror but to see through a material.
  51053. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51054. * @param name Define the texture name
  51055. * @param size Define the size of the underlying texture
  51056. * @param scene Define the scene the refraction belongs to
  51057. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51058. */
  51059. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51060. /**
  51061. * Clone the refraction texture.
  51062. * @returns the cloned texture
  51063. */
  51064. clone(): RefractionTexture;
  51065. /**
  51066. * Serialize the texture to a JSON representation you could use in Parse later on
  51067. * @returns the serialized JSON representation
  51068. */
  51069. serialize(): any;
  51070. }
  51071. }
  51072. declare module "babylonjs/Materials/Textures/index" {
  51073. export * from "babylonjs/Materials/Textures/baseTexture";
  51074. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51075. export * from "babylonjs/Materials/Textures/cubeTexture";
  51076. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51077. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51078. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51079. export * from "babylonjs/Materials/Textures/internalTexture";
  51080. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51081. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  51082. export * from "babylonjs/Materials/Textures/Loaders/index";
  51083. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51084. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51085. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51086. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51087. export * from "babylonjs/Materials/Textures/rawTexture";
  51088. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51089. export * from "babylonjs/Materials/Textures/refractionTexture";
  51090. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51091. export * from "babylonjs/Materials/Textures/texture";
  51092. export * from "babylonjs/Materials/Textures/videoTexture";
  51093. }
  51094. declare module "babylonjs/Materials/index" {
  51095. export * from "babylonjs/Materials/Background/index";
  51096. export * from "babylonjs/Materials/colorCurves";
  51097. export * from "babylonjs/Materials/effect";
  51098. export * from "babylonjs/Materials/fresnelParameters";
  51099. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51100. export * from "babylonjs/Materials/material";
  51101. export * from "babylonjs/Materials/materialDefines";
  51102. export * from "babylonjs/Materials/materialHelper";
  51103. export * from "babylonjs/Materials/multiMaterial";
  51104. export * from "babylonjs/Materials/PBR/index";
  51105. export * from "babylonjs/Materials/pushMaterial";
  51106. export * from "babylonjs/Materials/shaderMaterial";
  51107. export * from "babylonjs/Materials/standardMaterial";
  51108. export * from "babylonjs/Materials/Textures/index";
  51109. export * from "babylonjs/Materials/uniformBuffer";
  51110. export * from "babylonjs/Materials/materialFlags";
  51111. }
  51112. declare module "babylonjs/Maths/index" {
  51113. export * from "babylonjs/Maths/math.scalar";
  51114. export * from "babylonjs/Maths/math";
  51115. export * from "babylonjs/Maths/sphericalPolynomial";
  51116. }
  51117. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51118. import { IDisposable } from "babylonjs/scene";
  51119. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51120. /**
  51121. * Configuration for Draco compression
  51122. */
  51123. export interface IDracoCompressionConfiguration {
  51124. /**
  51125. * Configuration for the decoder.
  51126. */
  51127. decoder?: {
  51128. /**
  51129. * The url to the WebAssembly module.
  51130. */
  51131. wasmUrl?: string;
  51132. /**
  51133. * The url to the WebAssembly binary.
  51134. */
  51135. wasmBinaryUrl?: string;
  51136. /**
  51137. * The url to the fallback JavaScript module.
  51138. */
  51139. fallbackUrl?: string;
  51140. };
  51141. }
  51142. /**
  51143. * Draco compression (https://google.github.io/draco/)
  51144. *
  51145. * This class wraps the Draco module.
  51146. *
  51147. * **Encoder**
  51148. *
  51149. * The encoder is not currently implemented.
  51150. *
  51151. * **Decoder**
  51152. *
  51153. * 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.
  51154. *
  51155. * To update the configuration, use the following code:
  51156. * ```javascript
  51157. * DracoCompression.Configuration = {
  51158. * decoder: {
  51159. * wasmUrl: "<url to the WebAssembly library>",
  51160. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51161. * fallbackUrl: "<url to the fallback JavaScript library>",
  51162. * }
  51163. * };
  51164. * ```
  51165. *
  51166. * 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.
  51167. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51168. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51169. *
  51170. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51171. * ```javascript
  51172. * var dracoCompression = new DracoCompression();
  51173. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51174. * [VertexBuffer.PositionKind]: 0
  51175. * });
  51176. * ```
  51177. *
  51178. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51179. */
  51180. export class DracoCompression implements IDisposable {
  51181. private static _DecoderModulePromise;
  51182. /**
  51183. * The configuration. Defaults to the following urls:
  51184. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51185. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51186. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51187. */
  51188. static Configuration: IDracoCompressionConfiguration;
  51189. /**
  51190. * Returns true if the decoder is available.
  51191. */
  51192. static readonly DecoderAvailable: boolean;
  51193. /**
  51194. * Constructor
  51195. */
  51196. constructor();
  51197. /**
  51198. * Stop all async operations and release resources.
  51199. */
  51200. dispose(): void;
  51201. /**
  51202. * Decode Draco compressed mesh data to vertex data.
  51203. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51204. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51205. * @returns A promise that resolves with the decoded vertex data
  51206. */
  51207. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51208. [kind: string]: number;
  51209. }): Promise<VertexData>;
  51210. private static _GetDecoderModule;
  51211. private static _LoadScriptAsync;
  51212. private static _LoadFileAsync;
  51213. }
  51214. }
  51215. declare module "babylonjs/Meshes/Compression/index" {
  51216. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51217. }
  51218. declare module "babylonjs/Meshes/csg" {
  51219. import { Nullable } from "babylonjs/types";
  51220. import { Scene } from "babylonjs/scene";
  51221. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51222. import { Mesh } from "babylonjs/Meshes/mesh";
  51223. import { Material } from "babylonjs/Materials/material";
  51224. /**
  51225. * Class for building Constructive Solid Geometry
  51226. */
  51227. export class CSG {
  51228. private polygons;
  51229. /**
  51230. * The world matrix
  51231. */
  51232. matrix: Matrix;
  51233. /**
  51234. * Stores the position
  51235. */
  51236. position: Vector3;
  51237. /**
  51238. * Stores the rotation
  51239. */
  51240. rotation: Vector3;
  51241. /**
  51242. * Stores the rotation quaternion
  51243. */
  51244. rotationQuaternion: Nullable<Quaternion>;
  51245. /**
  51246. * Stores the scaling vector
  51247. */
  51248. scaling: Vector3;
  51249. /**
  51250. * Convert the Mesh to CSG
  51251. * @param mesh The Mesh to convert to CSG
  51252. * @returns A new CSG from the Mesh
  51253. */
  51254. static FromMesh(mesh: Mesh): CSG;
  51255. /**
  51256. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51257. * @param polygons Polygons used to construct a CSG solid
  51258. */
  51259. private static FromPolygons;
  51260. /**
  51261. * Clones, or makes a deep copy, of the CSG
  51262. * @returns A new CSG
  51263. */
  51264. clone(): CSG;
  51265. /**
  51266. * Unions this CSG with another CSG
  51267. * @param csg The CSG to union against this CSG
  51268. * @returns The unioned CSG
  51269. */
  51270. union(csg: CSG): CSG;
  51271. /**
  51272. * Unions this CSG with another CSG in place
  51273. * @param csg The CSG to union against this CSG
  51274. */
  51275. unionInPlace(csg: CSG): void;
  51276. /**
  51277. * Subtracts this CSG with another CSG
  51278. * @param csg The CSG to subtract against this CSG
  51279. * @returns A new CSG
  51280. */
  51281. subtract(csg: CSG): CSG;
  51282. /**
  51283. * Subtracts this CSG with another CSG in place
  51284. * @param csg The CSG to subtact against this CSG
  51285. */
  51286. subtractInPlace(csg: CSG): void;
  51287. /**
  51288. * Intersect this CSG with another CSG
  51289. * @param csg The CSG to intersect against this CSG
  51290. * @returns A new CSG
  51291. */
  51292. intersect(csg: CSG): CSG;
  51293. /**
  51294. * Intersects this CSG with another CSG in place
  51295. * @param csg The CSG to intersect against this CSG
  51296. */
  51297. intersectInPlace(csg: CSG): void;
  51298. /**
  51299. * Return a new CSG solid with solid and empty space switched. This solid is
  51300. * not modified.
  51301. * @returns A new CSG solid with solid and empty space switched
  51302. */
  51303. inverse(): CSG;
  51304. /**
  51305. * Inverses the CSG in place
  51306. */
  51307. inverseInPlace(): void;
  51308. /**
  51309. * This is used to keep meshes transformations so they can be restored
  51310. * when we build back a Babylon Mesh
  51311. * NB : All CSG operations are performed in world coordinates
  51312. * @param csg The CSG to copy the transform attributes from
  51313. * @returns This CSG
  51314. */
  51315. copyTransformAttributes(csg: CSG): CSG;
  51316. /**
  51317. * Build Raw mesh from CSG
  51318. * Coordinates here are in world space
  51319. * @param name The name of the mesh geometry
  51320. * @param scene The Scene
  51321. * @param keepSubMeshes Specifies if the submeshes should be kept
  51322. * @returns A new Mesh
  51323. */
  51324. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51325. /**
  51326. * Build Mesh from CSG taking material and transforms into account
  51327. * @param name The name of the Mesh
  51328. * @param material The material of the Mesh
  51329. * @param scene The Scene
  51330. * @param keepSubMeshes Specifies if submeshes should be kept
  51331. * @returns The new Mesh
  51332. */
  51333. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51334. }
  51335. }
  51336. declare module "babylonjs/Meshes/trailMesh" {
  51337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51338. import { Mesh } from "babylonjs/Meshes/mesh";
  51339. import { Scene } from "babylonjs/scene";
  51340. /**
  51341. * Class used to create a trail following a mesh
  51342. */
  51343. export class TrailMesh extends Mesh {
  51344. private _generator;
  51345. private _autoStart;
  51346. private _running;
  51347. private _diameter;
  51348. private _length;
  51349. private _sectionPolygonPointsCount;
  51350. private _sectionVectors;
  51351. private _sectionNormalVectors;
  51352. private _beforeRenderObserver;
  51353. /**
  51354. * @constructor
  51355. * @param name The value used by scene.getMeshByName() to do a lookup.
  51356. * @param generator The mesh to generate a trail.
  51357. * @param scene The scene to add this mesh to.
  51358. * @param diameter Diameter of trailing mesh. Default is 1.
  51359. * @param length Length of trailing mesh. Default is 60.
  51360. * @param autoStart Automatically start trailing mesh. Default true.
  51361. */
  51362. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51363. /**
  51364. * "TrailMesh"
  51365. * @returns "TrailMesh"
  51366. */
  51367. getClassName(): string;
  51368. private _createMesh;
  51369. /**
  51370. * Start trailing mesh.
  51371. */
  51372. start(): void;
  51373. /**
  51374. * Stop trailing mesh.
  51375. */
  51376. stop(): void;
  51377. /**
  51378. * Update trailing mesh geometry.
  51379. */
  51380. update(): void;
  51381. /**
  51382. * Returns a new TrailMesh object.
  51383. * @param name is a string, the name given to the new mesh
  51384. * @param newGenerator use new generator object for cloned trail mesh
  51385. * @returns a new mesh
  51386. */
  51387. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51388. /**
  51389. * Serializes this trail mesh
  51390. * @param serializationObject object to write serialization to
  51391. */
  51392. serialize(serializationObject: any): void;
  51393. /**
  51394. * Parses a serialized trail mesh
  51395. * @param parsedMesh the serialized mesh
  51396. * @param scene the scene to create the trail mesh in
  51397. * @returns the created trail mesh
  51398. */
  51399. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51400. }
  51401. }
  51402. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51403. import { Vector4 } from "babylonjs/Maths/math";
  51404. import { Mesh } from "babylonjs/Meshes/mesh";
  51405. /**
  51406. * Class containing static functions to help procedurally build meshes
  51407. */
  51408. export class TorusKnotBuilder {
  51409. /**
  51410. * Creates a torus knot mesh
  51411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51418. * @param name defines the name of the mesh
  51419. * @param options defines the options used to create the mesh
  51420. * @param scene defines the hosting scene
  51421. * @returns the torus knot mesh
  51422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51423. */
  51424. static CreateTorusKnot(name: string, options: {
  51425. radius?: number;
  51426. tube?: number;
  51427. radialSegments?: number;
  51428. tubularSegments?: number;
  51429. p?: number;
  51430. q?: number;
  51431. updatable?: boolean;
  51432. sideOrientation?: number;
  51433. frontUVs?: Vector4;
  51434. backUVs?: Vector4;
  51435. }, scene: any): Mesh;
  51436. }
  51437. }
  51438. declare module "babylonjs/Meshes/polygonMesh" {
  51439. import { Scene } from "babylonjs/scene";
  51440. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51441. import { Mesh } from "babylonjs/Meshes/mesh";
  51442. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51443. /**
  51444. * Polygon
  51445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51446. */
  51447. export class Polygon {
  51448. /**
  51449. * Creates a rectangle
  51450. * @param xmin bottom X coord
  51451. * @param ymin bottom Y coord
  51452. * @param xmax top X coord
  51453. * @param ymax top Y coord
  51454. * @returns points that make the resulting rectation
  51455. */
  51456. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51457. /**
  51458. * Creates a circle
  51459. * @param radius radius of circle
  51460. * @param cx scale in x
  51461. * @param cy scale in y
  51462. * @param numberOfSides number of sides that make up the circle
  51463. * @returns points that make the resulting circle
  51464. */
  51465. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51466. /**
  51467. * Creates a polygon from input string
  51468. * @param input Input polygon data
  51469. * @returns the parsed points
  51470. */
  51471. static Parse(input: string): Vector2[];
  51472. /**
  51473. * Starts building a polygon from x and y coordinates
  51474. * @param x x coordinate
  51475. * @param y y coordinate
  51476. * @returns the started path2
  51477. */
  51478. static StartingAt(x: number, y: number): Path2;
  51479. }
  51480. /**
  51481. * Builds a polygon
  51482. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51483. */
  51484. export class PolygonMeshBuilder {
  51485. private _points;
  51486. private _outlinepoints;
  51487. private _holes;
  51488. private _name;
  51489. private _scene;
  51490. private _epoints;
  51491. private _eholes;
  51492. private _addToepoint;
  51493. /**
  51494. * Babylon reference to the earcut plugin.
  51495. */
  51496. bjsEarcut: any;
  51497. /**
  51498. * Creates a PolygonMeshBuilder
  51499. * @param name name of the builder
  51500. * @param contours Path of the polygon
  51501. * @param scene scene to add to when creating the mesh
  51502. * @param earcutInjection can be used to inject your own earcut reference
  51503. */
  51504. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51505. /**
  51506. * Adds a whole within the polygon
  51507. * @param hole Array of points defining the hole
  51508. * @returns this
  51509. */
  51510. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51511. /**
  51512. * Creates the polygon
  51513. * @param updatable If the mesh should be updatable
  51514. * @param depth The depth of the mesh created
  51515. * @returns the created mesh
  51516. */
  51517. build(updatable?: boolean, depth?: number): Mesh;
  51518. /**
  51519. * Creates the polygon
  51520. * @param depth The depth of the mesh created
  51521. * @returns the created VertexData
  51522. */
  51523. buildVertexData(depth?: number): VertexData;
  51524. /**
  51525. * Adds a side to the polygon
  51526. * @param positions points that make the polygon
  51527. * @param normals normals of the polygon
  51528. * @param uvs uvs of the polygon
  51529. * @param indices indices of the polygon
  51530. * @param bounds bounds of the polygon
  51531. * @param points points of the polygon
  51532. * @param depth depth of the polygon
  51533. * @param flip flip of the polygon
  51534. */
  51535. private addSide;
  51536. }
  51537. }
  51538. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51539. import { Scene } from "babylonjs/scene";
  51540. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51541. import { Mesh } from "babylonjs/Meshes/mesh";
  51542. /**
  51543. * Class containing static functions to help procedurally build meshes
  51544. */
  51545. export class PolygonBuilder {
  51546. /**
  51547. * Creates a polygon mesh
  51548. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51549. * * 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
  51550. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51553. * * Remember you can only change the shape positions, not their number when updating a polygon
  51554. * @param name defines the name of the mesh
  51555. * @param options defines the options used to create the mesh
  51556. * @param scene defines the hosting scene
  51557. * @param earcutInjection can be used to inject your own earcut reference
  51558. * @returns the polygon mesh
  51559. */
  51560. static CreatePolygon(name: string, options: {
  51561. shape: Vector3[];
  51562. holes?: Vector3[][];
  51563. depth?: number;
  51564. faceUV?: Vector4[];
  51565. faceColors?: Color4[];
  51566. updatable?: boolean;
  51567. sideOrientation?: number;
  51568. frontUVs?: Vector4;
  51569. backUVs?: Vector4;
  51570. }, scene: Scene, earcutInjection?: any): Mesh;
  51571. /**
  51572. * Creates an extruded polygon mesh, with depth in the Y direction.
  51573. * * 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)
  51574. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51575. * @param name defines the name of the mesh
  51576. * @param options defines the options used to create the mesh
  51577. * @param scene defines the hosting scene
  51578. * @param earcutInjection can be used to inject your own earcut reference
  51579. * @returns the polygon mesh
  51580. */
  51581. static ExtrudePolygon(name: string, options: {
  51582. shape: Vector3[];
  51583. holes?: Vector3[][];
  51584. depth?: number;
  51585. faceUV?: Vector4[];
  51586. faceColors?: Color4[];
  51587. updatable?: boolean;
  51588. sideOrientation?: number;
  51589. frontUVs?: Vector4;
  51590. backUVs?: Vector4;
  51591. }, scene: Scene, earcutInjection?: any): Mesh;
  51592. }
  51593. }
  51594. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51595. import { Scene } from "babylonjs/scene";
  51596. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51597. import { Mesh } from "babylonjs/Meshes/mesh";
  51598. /**
  51599. * Class containing static functions to help procedurally build meshes
  51600. */
  51601. export class LatheBuilder {
  51602. /**
  51603. * Creates lathe mesh.
  51604. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51605. * * 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
  51606. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51607. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51608. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51609. * * 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
  51610. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51611. * * 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
  51612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51616. * @param name defines the name of the mesh
  51617. * @param options defines the options used to create the mesh
  51618. * @param scene defines the hosting scene
  51619. * @returns the lathe mesh
  51620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51621. */
  51622. static CreateLathe(name: string, options: {
  51623. shape: Vector3[];
  51624. radius?: number;
  51625. tessellation?: number;
  51626. clip?: number;
  51627. arc?: number;
  51628. closed?: boolean;
  51629. updatable?: boolean;
  51630. sideOrientation?: number;
  51631. frontUVs?: Vector4;
  51632. backUVs?: Vector4;
  51633. cap?: number;
  51634. invertUV?: boolean;
  51635. }, scene: Scene): Mesh;
  51636. }
  51637. }
  51638. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51639. import { Scene } from "babylonjs/scene";
  51640. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51641. import { Mesh } from "babylonjs/Meshes/mesh";
  51642. /**
  51643. * Class containing static functions to help procedurally build meshes
  51644. */
  51645. export class TubeBuilder {
  51646. /**
  51647. * Creates a tube mesh.
  51648. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51649. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51650. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51651. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51652. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51653. * * 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)
  51654. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51655. * * 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
  51656. * * 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
  51657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51661. * @param name defines the name of the mesh
  51662. * @param options defines the options used to create the mesh
  51663. * @param scene defines the hosting scene
  51664. * @returns the tube mesh
  51665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51666. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51667. */
  51668. static CreateTube(name: string, options: {
  51669. path: Vector3[];
  51670. radius?: number;
  51671. tessellation?: number;
  51672. radiusFunction?: {
  51673. (i: number, distance: number): number;
  51674. };
  51675. cap?: number;
  51676. arc?: number;
  51677. updatable?: boolean;
  51678. sideOrientation?: number;
  51679. frontUVs?: Vector4;
  51680. backUVs?: Vector4;
  51681. instance?: Mesh;
  51682. invertUV?: boolean;
  51683. }, scene: Scene): Mesh;
  51684. }
  51685. }
  51686. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51687. import { Scene } from "babylonjs/scene";
  51688. import { Vector4 } from "babylonjs/Maths/math";
  51689. import { Mesh } from "babylonjs/Meshes/mesh";
  51690. /**
  51691. * Class containing static functions to help procedurally build meshes
  51692. */
  51693. export class IcoSphereBuilder {
  51694. /**
  51695. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51696. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51697. * * 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`)
  51698. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51699. * * 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
  51700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51703. * @param name defines the name of the mesh
  51704. * @param options defines the options used to create the mesh
  51705. * @param scene defines the hosting scene
  51706. * @returns the icosahedron mesh
  51707. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51708. */
  51709. static CreateIcoSphere(name: string, options: {
  51710. radius?: number;
  51711. radiusX?: number;
  51712. radiusY?: number;
  51713. radiusZ?: number;
  51714. flat?: boolean;
  51715. subdivisions?: number;
  51716. sideOrientation?: number;
  51717. frontUVs?: Vector4;
  51718. backUVs?: Vector4;
  51719. updatable?: boolean;
  51720. }, scene: Scene): Mesh;
  51721. }
  51722. }
  51723. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51724. import { Vector3 } from "babylonjs/Maths/math";
  51725. import { Mesh } from "babylonjs/Meshes/mesh";
  51726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51727. /**
  51728. * Class containing static functions to help procedurally build meshes
  51729. */
  51730. export class DecalBuilder {
  51731. /**
  51732. * Creates a decal mesh.
  51733. * 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
  51734. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51735. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51736. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51737. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51738. * @param name defines the name of the mesh
  51739. * @param sourceMesh defines the mesh where the decal must be applied
  51740. * @param options defines the options used to create the mesh
  51741. * @param scene defines the hosting scene
  51742. * @returns the decal mesh
  51743. * @see https://doc.babylonjs.com/how_to/decals
  51744. */
  51745. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51746. position?: Vector3;
  51747. normal?: Vector3;
  51748. size?: Vector3;
  51749. angle?: number;
  51750. }): Mesh;
  51751. }
  51752. }
  51753. declare module "babylonjs/Meshes/meshBuilder" {
  51754. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  51755. import { Nullable } from "babylonjs/types";
  51756. import { Scene } from "babylonjs/scene";
  51757. import { Mesh } from "babylonjs/Meshes/mesh";
  51758. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51759. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51761. /**
  51762. * Class containing static functions to help procedurally build meshes
  51763. */
  51764. export class MeshBuilder {
  51765. /**
  51766. * Creates a box mesh
  51767. * * The parameter `size` sets the size (float) of each box side (default 1)
  51768. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51769. * * 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)
  51770. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51774. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51775. * @param name defines the name of the mesh
  51776. * @param options defines the options used to create the mesh
  51777. * @param scene defines the hosting scene
  51778. * @returns the box mesh
  51779. */
  51780. static CreateBox(name: string, options: {
  51781. size?: number;
  51782. width?: number;
  51783. height?: number;
  51784. depth?: number;
  51785. faceUV?: Vector4[];
  51786. faceColors?: Color4[];
  51787. sideOrientation?: number;
  51788. frontUVs?: Vector4;
  51789. backUVs?: Vector4;
  51790. updatable?: boolean;
  51791. }, scene?: Nullable<Scene>): Mesh;
  51792. /**
  51793. * Creates a sphere mesh
  51794. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51795. * * 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`)
  51796. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51797. * * 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
  51798. * * 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)
  51799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51802. * @param name defines the name of the mesh
  51803. * @param options defines the options used to create the mesh
  51804. * @param scene defines the hosting scene
  51805. * @returns the sphere mesh
  51806. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51807. */
  51808. static CreateSphere(name: string, options: {
  51809. segments?: number;
  51810. diameter?: number;
  51811. diameterX?: number;
  51812. diameterY?: number;
  51813. diameterZ?: number;
  51814. arc?: number;
  51815. slice?: number;
  51816. sideOrientation?: number;
  51817. frontUVs?: Vector4;
  51818. backUVs?: Vector4;
  51819. updatable?: boolean;
  51820. }, scene: any): Mesh;
  51821. /**
  51822. * Creates a plane polygonal mesh. By default, this is a disc
  51823. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51824. * * 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
  51825. * * 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
  51826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51829. * @param name defines the name of the mesh
  51830. * @param options defines the options used to create the mesh
  51831. * @param scene defines the hosting scene
  51832. * @returns the plane polygonal mesh
  51833. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51834. */
  51835. static CreateDisc(name: string, options: {
  51836. radius?: number;
  51837. tessellation?: number;
  51838. arc?: number;
  51839. updatable?: boolean;
  51840. sideOrientation?: number;
  51841. frontUVs?: Vector4;
  51842. backUVs?: Vector4;
  51843. }, scene?: Nullable<Scene>): Mesh;
  51844. /**
  51845. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51846. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51847. * * 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`)
  51848. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51849. * * 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
  51850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51853. * @param name defines the name of the mesh
  51854. * @param options defines the options used to create the mesh
  51855. * @param scene defines the hosting scene
  51856. * @returns the icosahedron mesh
  51857. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51858. */
  51859. static CreateIcoSphere(name: string, options: {
  51860. radius?: number;
  51861. radiusX?: number;
  51862. radiusY?: number;
  51863. radiusZ?: number;
  51864. flat?: boolean;
  51865. subdivisions?: number;
  51866. sideOrientation?: number;
  51867. frontUVs?: Vector4;
  51868. backUVs?: Vector4;
  51869. updatable?: boolean;
  51870. }, scene: Scene): Mesh;
  51871. /**
  51872. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51873. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51874. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51875. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51876. * * 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
  51877. * * 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
  51878. * * 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
  51879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51882. * * 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
  51883. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51884. * * 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
  51885. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  51891. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51893. */
  51894. static CreateRibbon(name: string, options: {
  51895. pathArray: Vector3[][];
  51896. closeArray?: boolean;
  51897. closePath?: boolean;
  51898. offset?: number;
  51899. updatable?: boolean;
  51900. sideOrientation?: number;
  51901. frontUVs?: Vector4;
  51902. backUVs?: Vector4;
  51903. instance?: Mesh;
  51904. invertUV?: boolean;
  51905. uvs?: Vector2[];
  51906. colors?: Color4[];
  51907. }, scene?: Nullable<Scene>): Mesh;
  51908. /**
  51909. * Creates a cylinder or a cone mesh
  51910. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51911. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51912. * * 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.
  51913. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51914. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51915. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51916. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51917. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51918. * * 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).
  51919. * * 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
  51920. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51921. * * 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
  51922. * * 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.
  51923. * * If `enclose` is false, a ring surface is one element.
  51924. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51925. * * 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
  51926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51929. * @param name defines the name of the mesh
  51930. * @param options defines the options used to create the mesh
  51931. * @param scene defines the hosting scene
  51932. * @returns the cylinder mesh
  51933. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51934. */
  51935. static CreateCylinder(name: string, options: {
  51936. height?: number;
  51937. diameterTop?: number;
  51938. diameterBottom?: number;
  51939. diameter?: number;
  51940. tessellation?: number;
  51941. subdivisions?: number;
  51942. arc?: number;
  51943. faceColors?: Color4[];
  51944. faceUV?: Vector4[];
  51945. updatable?: boolean;
  51946. hasRings?: boolean;
  51947. enclose?: boolean;
  51948. sideOrientation?: number;
  51949. frontUVs?: Vector4;
  51950. backUVs?: Vector4;
  51951. }, scene: any): Mesh;
  51952. /**
  51953. * Creates a torus mesh
  51954. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51955. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51956. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51960. * @param name defines the name of the mesh
  51961. * @param options defines the options used to create the mesh
  51962. * @param scene defines the hosting scene
  51963. * @returns the torus mesh
  51964. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51965. */
  51966. static CreateTorus(name: string, options: {
  51967. diameter?: number;
  51968. thickness?: number;
  51969. tessellation?: number;
  51970. updatable?: boolean;
  51971. sideOrientation?: number;
  51972. frontUVs?: Vector4;
  51973. backUVs?: Vector4;
  51974. }, scene: any): Mesh;
  51975. /**
  51976. * Creates a torus knot mesh
  51977. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51978. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51979. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51980. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51984. * @param name defines the name of the mesh
  51985. * @param options defines the options used to create the mesh
  51986. * @param scene defines the hosting scene
  51987. * @returns the torus knot mesh
  51988. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51989. */
  51990. static CreateTorusKnot(name: string, options: {
  51991. radius?: number;
  51992. tube?: number;
  51993. radialSegments?: number;
  51994. tubularSegments?: number;
  51995. p?: number;
  51996. q?: number;
  51997. updatable?: boolean;
  51998. sideOrientation?: number;
  51999. frontUVs?: Vector4;
  52000. backUVs?: Vector4;
  52001. }, scene: any): Mesh;
  52002. /**
  52003. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52004. * * 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
  52005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52006. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52007. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52008. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52009. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52010. * * 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
  52011. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52014. * @param name defines the name of the new line system
  52015. * @param options defines the options used to create the line system
  52016. * @param scene defines the hosting scene
  52017. * @returns a new line system mesh
  52018. */
  52019. static CreateLineSystem(name: string, options: {
  52020. lines: Vector3[][];
  52021. updatable?: boolean;
  52022. instance?: Nullable<LinesMesh>;
  52023. colors?: Nullable<Color4[][]>;
  52024. useVertexAlpha?: boolean;
  52025. }, scene: Nullable<Scene>): LinesMesh;
  52026. /**
  52027. * Creates a line mesh
  52028. * 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
  52029. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52030. * * The parameter `points` is an array successive Vector3
  52031. * * 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
  52032. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52033. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52034. * * When updating an instance, remember that only point positions can change, not the number of points
  52035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52037. * @param name defines the name of the new line system
  52038. * @param options defines the options used to create the line system
  52039. * @param scene defines the hosting scene
  52040. * @returns a new line mesh
  52041. */
  52042. static CreateLines(name: string, options: {
  52043. points: Vector3[];
  52044. updatable?: boolean;
  52045. instance?: Nullable<LinesMesh>;
  52046. colors?: Color4[];
  52047. useVertexAlpha?: boolean;
  52048. }, scene?: Nullable<Scene>): LinesMesh;
  52049. /**
  52050. * Creates a dashed line mesh
  52051. * * 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
  52052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52053. * * The parameter `points` is an array successive Vector3
  52054. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52055. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52056. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52057. * * 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
  52058. * * When updating an instance, remember that only point positions can change, not the number of points
  52059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52060. * @param name defines the name of the mesh
  52061. * @param options defines the options used to create the mesh
  52062. * @param scene defines the hosting scene
  52063. * @returns the dashed line mesh
  52064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52065. */
  52066. static CreateDashedLines(name: string, options: {
  52067. points: Vector3[];
  52068. dashSize?: number;
  52069. gapSize?: number;
  52070. dashNb?: number;
  52071. updatable?: boolean;
  52072. instance?: LinesMesh;
  52073. }, scene?: Nullable<Scene>): LinesMesh;
  52074. /**
  52075. * 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.
  52076. * * 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.
  52077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52078. * * 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.
  52079. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52080. * * 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
  52081. * * 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
  52082. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52087. * @param name defines the name of the mesh
  52088. * @param options defines the options used to create the mesh
  52089. * @param scene defines the hosting scene
  52090. * @returns the extruded shape mesh
  52091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52093. */
  52094. static ExtrudeShape(name: string, options: {
  52095. shape: Vector3[];
  52096. path: Vector3[];
  52097. scale?: number;
  52098. rotation?: number;
  52099. cap?: number;
  52100. updatable?: boolean;
  52101. sideOrientation?: number;
  52102. frontUVs?: Vector4;
  52103. backUVs?: Vector4;
  52104. instance?: Mesh;
  52105. invertUV?: boolean;
  52106. }, scene?: Nullable<Scene>): Mesh;
  52107. /**
  52108. * Creates an custom extruded shape mesh.
  52109. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52110. * * 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.
  52111. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52112. * * 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
  52113. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52114. * * 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
  52115. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52116. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52117. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52118. * * 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
  52119. * * 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
  52120. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52123. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52125. * @param name defines the name of the mesh
  52126. * @param options defines the options used to create the mesh
  52127. * @param scene defines the hosting scene
  52128. * @returns the custom extruded shape mesh
  52129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52132. */
  52133. static ExtrudeShapeCustom(name: string, options: {
  52134. shape: Vector3[];
  52135. path: Vector3[];
  52136. scaleFunction?: any;
  52137. rotationFunction?: any;
  52138. ribbonCloseArray?: boolean;
  52139. ribbonClosePath?: boolean;
  52140. cap?: number;
  52141. updatable?: boolean;
  52142. sideOrientation?: number;
  52143. frontUVs?: Vector4;
  52144. backUVs?: Vector4;
  52145. instance?: Mesh;
  52146. invertUV?: boolean;
  52147. }, scene: Scene): Mesh;
  52148. /**
  52149. * Creates lathe mesh.
  52150. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52151. * * 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
  52152. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52153. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52154. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52155. * * 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
  52156. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52157. * * 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
  52158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52162. * @param name defines the name of the mesh
  52163. * @param options defines the options used to create the mesh
  52164. * @param scene defines the hosting scene
  52165. * @returns the lathe mesh
  52166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52167. */
  52168. static CreateLathe(name: string, options: {
  52169. shape: Vector3[];
  52170. radius?: number;
  52171. tessellation?: number;
  52172. clip?: number;
  52173. arc?: number;
  52174. closed?: boolean;
  52175. updatable?: boolean;
  52176. sideOrientation?: number;
  52177. frontUVs?: Vector4;
  52178. backUVs?: Vector4;
  52179. cap?: number;
  52180. invertUV?: boolean;
  52181. }, scene: Scene): Mesh;
  52182. /**
  52183. * Creates a plane mesh
  52184. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52185. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52186. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52190. * @param name defines the name of the mesh
  52191. * @param options defines the options used to create the mesh
  52192. * @param scene defines the hosting scene
  52193. * @returns the plane mesh
  52194. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52195. */
  52196. static CreatePlane(name: string, options: {
  52197. size?: number;
  52198. width?: number;
  52199. height?: number;
  52200. sideOrientation?: number;
  52201. frontUVs?: Vector4;
  52202. backUVs?: Vector4;
  52203. updatable?: boolean;
  52204. sourcePlane?: Plane;
  52205. }, scene: Scene): Mesh;
  52206. /**
  52207. * Creates a ground mesh
  52208. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52209. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52211. * @param name defines the name of the mesh
  52212. * @param options defines the options used to create the mesh
  52213. * @param scene defines the hosting scene
  52214. * @returns the ground mesh
  52215. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52216. */
  52217. static CreateGround(name: string, options: {
  52218. width?: number;
  52219. height?: number;
  52220. subdivisions?: number;
  52221. subdivisionsX?: number;
  52222. subdivisionsY?: number;
  52223. updatable?: boolean;
  52224. }, scene: any): Mesh;
  52225. /**
  52226. * Creates a tiled ground mesh
  52227. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52228. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52229. * * 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
  52230. * * 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
  52231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52232. * @param name defines the name of the mesh
  52233. * @param options defines the options used to create the mesh
  52234. * @param scene defines the hosting scene
  52235. * @returns the tiled ground mesh
  52236. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52237. */
  52238. static CreateTiledGround(name: string, options: {
  52239. xmin: number;
  52240. zmin: number;
  52241. xmax: number;
  52242. zmax: number;
  52243. subdivisions?: {
  52244. w: number;
  52245. h: number;
  52246. };
  52247. precision?: {
  52248. w: number;
  52249. h: number;
  52250. };
  52251. updatable?: boolean;
  52252. }, scene: Scene): Mesh;
  52253. /**
  52254. * Creates a ground mesh from a height map
  52255. * * The parameter `url` sets the URL of the height map image resource.
  52256. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52257. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52258. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52259. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52260. * * 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.
  52261. * * 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).
  52262. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52264. * @param name defines the name of the mesh
  52265. * @param url defines the url to the height map
  52266. * @param options defines the options used to create the mesh
  52267. * @param scene defines the hosting scene
  52268. * @returns the ground mesh
  52269. * @see https://doc.babylonjs.com/babylon101/height_map
  52270. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52271. */
  52272. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52273. width?: number;
  52274. height?: number;
  52275. subdivisions?: number;
  52276. minHeight?: number;
  52277. maxHeight?: number;
  52278. colorFilter?: Color3;
  52279. alphaFilter?: number;
  52280. updatable?: boolean;
  52281. onReady?: (mesh: GroundMesh) => void;
  52282. }, scene: Scene): GroundMesh;
  52283. /**
  52284. * Creates a polygon mesh
  52285. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52286. * * 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
  52287. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52290. * * Remember you can only change the shape positions, not their number when updating a polygon
  52291. * @param name defines the name of the mesh
  52292. * @param options defines the options used to create the mesh
  52293. * @param scene defines the hosting scene
  52294. * @param earcutInjection can be used to inject your own earcut reference
  52295. * @returns the polygon mesh
  52296. */
  52297. static CreatePolygon(name: string, options: {
  52298. shape: Vector3[];
  52299. holes?: Vector3[][];
  52300. depth?: number;
  52301. faceUV?: Vector4[];
  52302. faceColors?: Color4[];
  52303. updatable?: boolean;
  52304. sideOrientation?: number;
  52305. frontUVs?: Vector4;
  52306. backUVs?: Vector4;
  52307. }, scene: Scene, earcutInjection?: any): Mesh;
  52308. /**
  52309. * Creates an extruded polygon mesh, with depth in the Y direction.
  52310. * * 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)
  52311. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52312. * @param name defines the name of the mesh
  52313. * @param options defines the options used to create the mesh
  52314. * @param scene defines the hosting scene
  52315. * @param earcutInjection can be used to inject your own earcut reference
  52316. * @returns the polygon mesh
  52317. */
  52318. static ExtrudePolygon(name: string, options: {
  52319. shape: Vector3[];
  52320. holes?: Vector3[][];
  52321. depth?: number;
  52322. faceUV?: Vector4[];
  52323. faceColors?: Color4[];
  52324. updatable?: boolean;
  52325. sideOrientation?: number;
  52326. frontUVs?: Vector4;
  52327. backUVs?: Vector4;
  52328. }, scene: Scene, earcutInjection?: any): Mesh;
  52329. /**
  52330. * Creates a tube mesh.
  52331. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52332. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52333. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52334. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52335. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52336. * * 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)
  52337. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52338. * * 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
  52339. * * 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
  52340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52344. * @param name defines the name of the mesh
  52345. * @param options defines the options used to create the mesh
  52346. * @param scene defines the hosting scene
  52347. * @returns the tube mesh
  52348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52349. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52350. */
  52351. static CreateTube(name: string, options: {
  52352. path: Vector3[];
  52353. radius?: number;
  52354. tessellation?: number;
  52355. radiusFunction?: {
  52356. (i: number, distance: number): number;
  52357. };
  52358. cap?: number;
  52359. arc?: number;
  52360. updatable?: boolean;
  52361. sideOrientation?: number;
  52362. frontUVs?: Vector4;
  52363. backUVs?: Vector4;
  52364. instance?: Mesh;
  52365. invertUV?: boolean;
  52366. }, scene: Scene): Mesh;
  52367. /**
  52368. * Creates a polyhedron mesh
  52369. * * 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
  52370. * * The parameter `size` (positive float, default 1) sets the polygon size
  52371. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52372. * * 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`
  52373. * * 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
  52374. * * 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)`)
  52375. * * 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
  52376. * * 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
  52377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52380. * @param name defines the name of the mesh
  52381. * @param options defines the options used to create the mesh
  52382. * @param scene defines the hosting scene
  52383. * @returns the polyhedron mesh
  52384. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52385. */
  52386. static CreatePolyhedron(name: string, options: {
  52387. type?: number;
  52388. size?: number;
  52389. sizeX?: number;
  52390. sizeY?: number;
  52391. sizeZ?: number;
  52392. custom?: any;
  52393. faceUV?: Vector4[];
  52394. faceColors?: Color4[];
  52395. flat?: boolean;
  52396. updatable?: boolean;
  52397. sideOrientation?: number;
  52398. frontUVs?: Vector4;
  52399. backUVs?: Vector4;
  52400. }, scene: Scene): Mesh;
  52401. /**
  52402. * Creates a decal mesh.
  52403. * 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
  52404. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52405. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52406. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52407. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52408. * @param name defines the name of the mesh
  52409. * @param sourceMesh defines the mesh where the decal must be applied
  52410. * @param options defines the options used to create the mesh
  52411. * @param scene defines the hosting scene
  52412. * @returns the decal mesh
  52413. * @see https://doc.babylonjs.com/how_to/decals
  52414. */
  52415. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52416. position?: Vector3;
  52417. normal?: Vector3;
  52418. size?: Vector3;
  52419. angle?: number;
  52420. }): Mesh;
  52421. }
  52422. }
  52423. declare module "babylonjs/Meshes/meshSimplification" {
  52424. import { Mesh } from "babylonjs/Meshes/mesh";
  52425. /**
  52426. * A simplifier interface for future simplification implementations
  52427. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52428. */
  52429. export interface ISimplifier {
  52430. /**
  52431. * Simplification of a given mesh according to the given settings.
  52432. * Since this requires computation, it is assumed that the function runs async.
  52433. * @param settings The settings of the simplification, including quality and distance
  52434. * @param successCallback A callback that will be called after the mesh was simplified.
  52435. * @param errorCallback in case of an error, this callback will be called. optional.
  52436. */
  52437. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52438. }
  52439. /**
  52440. * Expected simplification settings.
  52441. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52442. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52443. */
  52444. export interface ISimplificationSettings {
  52445. /**
  52446. * Gets or sets the expected quality
  52447. */
  52448. quality: number;
  52449. /**
  52450. * Gets or sets the distance when this optimized version should be used
  52451. */
  52452. distance: number;
  52453. /**
  52454. * Gets an already optimized mesh
  52455. */
  52456. optimizeMesh?: boolean;
  52457. }
  52458. /**
  52459. * Class used to specify simplification options
  52460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52461. */
  52462. export class SimplificationSettings implements ISimplificationSettings {
  52463. /** expected quality */
  52464. quality: number;
  52465. /** distance when this optimized version should be used */
  52466. distance: number;
  52467. /** already optimized mesh */
  52468. optimizeMesh?: boolean | undefined;
  52469. /**
  52470. * Creates a SimplificationSettings
  52471. * @param quality expected quality
  52472. * @param distance distance when this optimized version should be used
  52473. * @param optimizeMesh already optimized mesh
  52474. */
  52475. constructor(
  52476. /** expected quality */
  52477. quality: number,
  52478. /** distance when this optimized version should be used */
  52479. distance: number,
  52480. /** already optimized mesh */
  52481. optimizeMesh?: boolean | undefined);
  52482. }
  52483. /**
  52484. * Interface used to define a simplification task
  52485. */
  52486. export interface ISimplificationTask {
  52487. /**
  52488. * Array of settings
  52489. */
  52490. settings: Array<ISimplificationSettings>;
  52491. /**
  52492. * Simplification type
  52493. */
  52494. simplificationType: SimplificationType;
  52495. /**
  52496. * Mesh to simplify
  52497. */
  52498. mesh: Mesh;
  52499. /**
  52500. * Callback called on success
  52501. */
  52502. successCallback?: () => void;
  52503. /**
  52504. * Defines if parallel processing can be used
  52505. */
  52506. parallelProcessing: boolean;
  52507. }
  52508. /**
  52509. * Queue used to order the simplification tasks
  52510. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52511. */
  52512. export class SimplificationQueue {
  52513. private _simplificationArray;
  52514. /**
  52515. * Gets a boolean indicating that the process is still running
  52516. */
  52517. running: boolean;
  52518. /**
  52519. * Creates a new queue
  52520. */
  52521. constructor();
  52522. /**
  52523. * Adds a new simplification task
  52524. * @param task defines a task to add
  52525. */
  52526. addTask(task: ISimplificationTask): void;
  52527. /**
  52528. * Execute next task
  52529. */
  52530. executeNext(): void;
  52531. /**
  52532. * Execute a simplification task
  52533. * @param task defines the task to run
  52534. */
  52535. runSimplification(task: ISimplificationTask): void;
  52536. private getSimplifier;
  52537. }
  52538. /**
  52539. * The implemented types of simplification
  52540. * At the moment only Quadratic Error Decimation is implemented
  52541. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52542. */
  52543. export enum SimplificationType {
  52544. /** Quadratic error decimation */
  52545. QUADRATIC = 0
  52546. }
  52547. }
  52548. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52549. import { Scene } from "babylonjs/scene";
  52550. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52551. import { ISceneComponent } from "babylonjs/sceneComponent";
  52552. module "babylonjs/scene" {
  52553. interface Scene {
  52554. /** @hidden (Backing field) */
  52555. _simplificationQueue: SimplificationQueue;
  52556. /**
  52557. * Gets or sets the simplification queue attached to the scene
  52558. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52559. */
  52560. simplificationQueue: SimplificationQueue;
  52561. }
  52562. }
  52563. module "babylonjs/Meshes/mesh" {
  52564. interface Mesh {
  52565. /**
  52566. * Simplify the mesh according to the given array of settings.
  52567. * Function will return immediately and will simplify async
  52568. * @param settings a collection of simplification settings
  52569. * @param parallelProcessing should all levels calculate parallel or one after the other
  52570. * @param simplificationType the type of simplification to run
  52571. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52572. * @returns the current mesh
  52573. */
  52574. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52575. }
  52576. }
  52577. /**
  52578. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52579. * created in a scene
  52580. */
  52581. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52582. /**
  52583. * The component name helpfull to identify the component in the list of scene components.
  52584. */
  52585. readonly name: string;
  52586. /**
  52587. * The scene the component belongs to.
  52588. */
  52589. scene: Scene;
  52590. /**
  52591. * Creates a new instance of the component for the given scene
  52592. * @param scene Defines the scene to register the component in
  52593. */
  52594. constructor(scene: Scene);
  52595. /**
  52596. * Registers the component in a given scene
  52597. */
  52598. register(): void;
  52599. /**
  52600. * Rebuilds the elements related to this component in case of
  52601. * context lost for instance.
  52602. */
  52603. rebuild(): void;
  52604. /**
  52605. * Disposes the component and the associated ressources
  52606. */
  52607. dispose(): void;
  52608. private _beforeCameraUpdate;
  52609. }
  52610. }
  52611. declare module "babylonjs/Meshes/Builders/index" {
  52612. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52613. export * from "babylonjs/Meshes/Builders/discBuilder";
  52614. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52615. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52616. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52617. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52618. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52619. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52620. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52621. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52622. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52623. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52624. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52625. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52626. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52627. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52628. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52629. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52630. }
  52631. declare module "babylonjs/Meshes/index" {
  52632. export * from "babylonjs/Meshes/abstractMesh";
  52633. export * from "babylonjs/Meshes/buffer";
  52634. export * from "babylonjs/Meshes/Compression/index";
  52635. export * from "babylonjs/Meshes/csg";
  52636. export * from "babylonjs/Meshes/geometry";
  52637. export * from "babylonjs/Meshes/groundMesh";
  52638. export * from "babylonjs/Meshes/trailMesh";
  52639. export * from "babylonjs/Meshes/instancedMesh";
  52640. export * from "babylonjs/Meshes/linesMesh";
  52641. export * from "babylonjs/Meshes/mesh";
  52642. export * from "babylonjs/Meshes/mesh.vertexData";
  52643. export * from "babylonjs/Meshes/meshBuilder";
  52644. export * from "babylonjs/Meshes/meshSimplification";
  52645. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52646. export * from "babylonjs/Meshes/polygonMesh";
  52647. export * from "babylonjs/Meshes/subMesh";
  52648. export * from "babylonjs/Meshes/transformNode";
  52649. export * from "babylonjs/Meshes/Builders/index";
  52650. }
  52651. declare module "babylonjs/Morph/index" {
  52652. export * from "babylonjs/Morph/morphTarget";
  52653. export * from "babylonjs/Morph/morphTargetManager";
  52654. }
  52655. declare module "babylonjs/Offline/database" {
  52656. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52657. /**
  52658. * Class used to enable access to IndexedDB
  52659. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52660. */
  52661. export class Database implements IOfflineProvider {
  52662. private _callbackManifestChecked;
  52663. private _currentSceneUrl;
  52664. private _db;
  52665. private _enableSceneOffline;
  52666. private _enableTexturesOffline;
  52667. private _manifestVersionFound;
  52668. private _mustUpdateRessources;
  52669. private _hasReachedQuota;
  52670. private _isSupported;
  52671. private _idbFactory;
  52672. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52673. private static IsUASupportingBlobStorage;
  52674. /**
  52675. * Gets a boolean indicating if Database storate is enabled (off by default)
  52676. */
  52677. static IDBStorageEnabled: boolean;
  52678. /**
  52679. * Gets a boolean indicating if scene must be saved in the database
  52680. */
  52681. readonly enableSceneOffline: boolean;
  52682. /**
  52683. * Gets a boolean indicating if textures must be saved in the database
  52684. */
  52685. readonly enableTexturesOffline: boolean;
  52686. /**
  52687. * Creates a new Database
  52688. * @param urlToScene defines the url to load the scene
  52689. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52690. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52691. */
  52692. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52693. private static _ParseURL;
  52694. private static _ReturnFullUrlLocation;
  52695. private _checkManifestFile;
  52696. /**
  52697. * Open the database and make it available
  52698. * @param successCallback defines the callback to call on success
  52699. * @param errorCallback defines the callback to call on error
  52700. */
  52701. open(successCallback: () => void, errorCallback: () => void): void;
  52702. /**
  52703. * Loads an image from the database
  52704. * @param url defines the url to load from
  52705. * @param image defines the target DOM image
  52706. */
  52707. loadImage(url: string, image: HTMLImageElement): void;
  52708. private _loadImageFromDBAsync;
  52709. private _saveImageIntoDBAsync;
  52710. private _checkVersionFromDB;
  52711. private _loadVersionFromDBAsync;
  52712. private _saveVersionIntoDBAsync;
  52713. /**
  52714. * Loads a file from database
  52715. * @param url defines the URL to load from
  52716. * @param sceneLoaded defines a callback to call on success
  52717. * @param progressCallBack defines a callback to call when progress changed
  52718. * @param errorCallback defines a callback to call on error
  52719. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52720. */
  52721. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52722. private _loadFileAsync;
  52723. private _saveFileAsync;
  52724. /**
  52725. * Validates if xhr data is correct
  52726. * @param xhr defines the request to validate
  52727. * @param dataType defines the expected data type
  52728. * @returns true if data is correct
  52729. */
  52730. private static _ValidateXHRData;
  52731. }
  52732. }
  52733. declare module "babylonjs/Offline/index" {
  52734. export * from "babylonjs/Offline/database";
  52735. export * from "babylonjs/Offline/IOfflineProvider";
  52736. }
  52737. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52738. /** @hidden */
  52739. export var gpuUpdateParticlesPixelShader: {
  52740. name: string;
  52741. shader: string;
  52742. };
  52743. }
  52744. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  52745. /** @hidden */
  52746. export var gpuUpdateParticlesVertexShader: {
  52747. name: string;
  52748. shader: string;
  52749. };
  52750. }
  52751. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  52752. /** @hidden */
  52753. export var clipPlaneFragmentDeclaration2: {
  52754. name: string;
  52755. shader: string;
  52756. };
  52757. }
  52758. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  52759. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  52760. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52762. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52763. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52764. /** @hidden */
  52765. export var gpuRenderParticlesPixelShader: {
  52766. name: string;
  52767. shader: string;
  52768. };
  52769. }
  52770. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  52771. /** @hidden */
  52772. export var clipPlaneVertexDeclaration2: {
  52773. name: string;
  52774. shader: string;
  52775. };
  52776. }
  52777. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  52778. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  52779. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52780. /** @hidden */
  52781. export var gpuRenderParticlesVertexShader: {
  52782. name: string;
  52783. shader: string;
  52784. };
  52785. }
  52786. declare module "babylonjs/Particles/gpuParticleSystem" {
  52787. import { Nullable } from "babylonjs/types";
  52788. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  52789. import { Observable } from "babylonjs/Misc/observable";
  52790. import { Color4, Color3 } from "babylonjs/Maths/math";
  52791. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52792. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  52793. import { Scene, IDisposable } from "babylonjs/scene";
  52794. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  52795. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  52796. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  52797. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  52798. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  52799. /**
  52800. * This represents a GPU particle system in Babylon
  52801. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52802. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52803. */
  52804. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52805. /**
  52806. * The layer mask we are rendering the particles through.
  52807. */
  52808. layerMask: number;
  52809. private _capacity;
  52810. private _activeCount;
  52811. private _currentActiveCount;
  52812. private _accumulatedCount;
  52813. private _renderEffect;
  52814. private _updateEffect;
  52815. private _buffer0;
  52816. private _buffer1;
  52817. private _spriteBuffer;
  52818. private _updateVAO;
  52819. private _renderVAO;
  52820. private _targetIndex;
  52821. private _sourceBuffer;
  52822. private _targetBuffer;
  52823. private _engine;
  52824. private _currentRenderId;
  52825. private _started;
  52826. private _stopped;
  52827. private _timeDelta;
  52828. private _randomTexture;
  52829. private _randomTexture2;
  52830. private _attributesStrideSize;
  52831. private _updateEffectOptions;
  52832. private _randomTextureSize;
  52833. private _actualFrame;
  52834. private readonly _rawTextureWidth;
  52835. /**
  52836. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52837. */
  52838. static readonly IsSupported: boolean;
  52839. /**
  52840. * An event triggered when the system is disposed.
  52841. */
  52842. onDisposeObservable: Observable<GPUParticleSystem>;
  52843. /**
  52844. * Gets the maximum number of particles active at the same time.
  52845. * @returns The max number of active particles.
  52846. */
  52847. getCapacity(): number;
  52848. /**
  52849. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52850. * to override the particles.
  52851. */
  52852. forceDepthWrite: boolean;
  52853. /**
  52854. * Gets or set the number of active particles
  52855. */
  52856. activeParticleCount: number;
  52857. private _preWarmDone;
  52858. /**
  52859. * Is this system ready to be used/rendered
  52860. * @return true if the system is ready
  52861. */
  52862. isReady(): boolean;
  52863. /**
  52864. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52865. * @returns True if it has been started, otherwise false.
  52866. */
  52867. isStarted(): boolean;
  52868. /**
  52869. * Starts the particle system and begins to emit
  52870. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52871. */
  52872. start(delay?: number): void;
  52873. /**
  52874. * Stops the particle system.
  52875. */
  52876. stop(): void;
  52877. /**
  52878. * Remove all active particles
  52879. */
  52880. reset(): void;
  52881. /**
  52882. * Returns the string "GPUParticleSystem"
  52883. * @returns a string containing the class name
  52884. */
  52885. getClassName(): string;
  52886. private _colorGradientsTexture;
  52887. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52888. /**
  52889. * Adds a new color gradient
  52890. * @param gradient defines the gradient to use (between 0 and 1)
  52891. * @param color1 defines the color to affect to the specified gradient
  52892. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52893. * @returns the current particle system
  52894. */
  52895. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52896. /**
  52897. * Remove a specific color gradient
  52898. * @param gradient defines the gradient to remove
  52899. * @returns the current particle system
  52900. */
  52901. removeColorGradient(gradient: number): GPUParticleSystem;
  52902. private _angularSpeedGradientsTexture;
  52903. private _sizeGradientsTexture;
  52904. private _velocityGradientsTexture;
  52905. private _limitVelocityGradientsTexture;
  52906. private _dragGradientsTexture;
  52907. private _addFactorGradient;
  52908. /**
  52909. * Adds a new size gradient
  52910. * @param gradient defines the gradient to use (between 0 and 1)
  52911. * @param factor defines the size factor to affect to the specified gradient
  52912. * @returns the current particle system
  52913. */
  52914. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52915. /**
  52916. * Remove a specific size gradient
  52917. * @param gradient defines the gradient to remove
  52918. * @returns the current particle system
  52919. */
  52920. removeSizeGradient(gradient: number): GPUParticleSystem;
  52921. /**
  52922. * Adds a new angular speed gradient
  52923. * @param gradient defines the gradient to use (between 0 and 1)
  52924. * @param factor defines the angular speed to affect to the specified gradient
  52925. * @returns the current particle system
  52926. */
  52927. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52928. /**
  52929. * Remove a specific angular speed gradient
  52930. * @param gradient defines the gradient to remove
  52931. * @returns the current particle system
  52932. */
  52933. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52934. /**
  52935. * Adds a new velocity gradient
  52936. * @param gradient defines the gradient to use (between 0 and 1)
  52937. * @param factor defines the velocity to affect to the specified gradient
  52938. * @returns the current particle system
  52939. */
  52940. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52941. /**
  52942. * Remove a specific velocity gradient
  52943. * @param gradient defines the gradient to remove
  52944. * @returns the current particle system
  52945. */
  52946. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52947. /**
  52948. * Adds a new limit velocity gradient
  52949. * @param gradient defines the gradient to use (between 0 and 1)
  52950. * @param factor defines the limit velocity value to affect to the specified gradient
  52951. * @returns the current particle system
  52952. */
  52953. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52954. /**
  52955. * Remove a specific limit velocity gradient
  52956. * @param gradient defines the gradient to remove
  52957. * @returns the current particle system
  52958. */
  52959. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52960. /**
  52961. * Adds a new drag gradient
  52962. * @param gradient defines the gradient to use (between 0 and 1)
  52963. * @param factor defines the drag value to affect to the specified gradient
  52964. * @returns the current particle system
  52965. */
  52966. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52967. /**
  52968. * Remove a specific drag gradient
  52969. * @param gradient defines the gradient to remove
  52970. * @returns the current particle system
  52971. */
  52972. removeDragGradient(gradient: number): GPUParticleSystem;
  52973. /**
  52974. * Not supported by GPUParticleSystem
  52975. * @param gradient defines the gradient to use (between 0 and 1)
  52976. * @param factor defines the emit rate value to affect to the specified gradient
  52977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52978. * @returns the current particle system
  52979. */
  52980. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52981. /**
  52982. * Not supported by GPUParticleSystem
  52983. * @param gradient defines the gradient to remove
  52984. * @returns the current particle system
  52985. */
  52986. removeEmitRateGradient(gradient: number): IParticleSystem;
  52987. /**
  52988. * Not supported by GPUParticleSystem
  52989. * @param gradient defines the gradient to use (between 0 and 1)
  52990. * @param factor defines the start size value to affect to the specified gradient
  52991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52992. * @returns the current particle system
  52993. */
  52994. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52995. /**
  52996. * Not supported by GPUParticleSystem
  52997. * @param gradient defines the gradient to remove
  52998. * @returns the current particle system
  52999. */
  53000. removeStartSizeGradient(gradient: number): IParticleSystem;
  53001. /**
  53002. * Not supported by GPUParticleSystem
  53003. * @param gradient defines the gradient to use (between 0 and 1)
  53004. * @param min defines the color remap minimal range
  53005. * @param max defines the color remap maximal range
  53006. * @returns the current particle system
  53007. */
  53008. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53009. /**
  53010. * Not supported by GPUParticleSystem
  53011. * @param gradient defines the gradient to remove
  53012. * @returns the current particle system
  53013. */
  53014. removeColorRemapGradient(): IParticleSystem;
  53015. /**
  53016. * Not supported by GPUParticleSystem
  53017. * @param gradient defines the gradient to use (between 0 and 1)
  53018. * @param min defines the alpha remap minimal range
  53019. * @param max defines the alpha remap maximal range
  53020. * @returns the current particle system
  53021. */
  53022. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53023. /**
  53024. * Not supported by GPUParticleSystem
  53025. * @param gradient defines the gradient to remove
  53026. * @returns the current particle system
  53027. */
  53028. removeAlphaRemapGradient(): IParticleSystem;
  53029. /**
  53030. * Not supported by GPUParticleSystem
  53031. * @param gradient defines the gradient to use (between 0 and 1)
  53032. * @param color defines the color to affect to the specified gradient
  53033. * @returns the current particle system
  53034. */
  53035. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53036. /**
  53037. * Not supported by GPUParticleSystem
  53038. * @param gradient defines the gradient to remove
  53039. * @returns the current particle system
  53040. */
  53041. removeRampGradient(): IParticleSystem;
  53042. /**
  53043. * Not supported by GPUParticleSystem
  53044. * @returns the list of ramp gradients
  53045. */
  53046. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53047. /**
  53048. * Not supported by GPUParticleSystem
  53049. * Gets or sets a boolean indicating that ramp gradients must be used
  53050. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53051. */
  53052. useRampGradients: boolean;
  53053. /**
  53054. * Not supported by GPUParticleSystem
  53055. * @param gradient defines the gradient to use (between 0 and 1)
  53056. * @param factor defines the life time factor to affect to the specified gradient
  53057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53058. * @returns the current particle system
  53059. */
  53060. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53061. /**
  53062. * Not supported by GPUParticleSystem
  53063. * @param gradient defines the gradient to remove
  53064. * @returns the current particle system
  53065. */
  53066. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53067. /**
  53068. * Instantiates a GPU particle system.
  53069. * 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.
  53070. * @param name The name of the particle system
  53071. * @param options The options used to create the system
  53072. * @param scene The scene the particle system belongs to
  53073. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53074. */
  53075. constructor(name: string, options: Partial<{
  53076. capacity: number;
  53077. randomTextureSize: number;
  53078. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53079. protected _reset(): void;
  53080. private _createUpdateVAO;
  53081. private _createRenderVAO;
  53082. private _initialize;
  53083. /** @hidden */
  53084. _recreateUpdateEffect(): void;
  53085. /** @hidden */
  53086. _recreateRenderEffect(): void;
  53087. /**
  53088. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53089. * @param preWarm defines if we are in the pre-warmimg phase
  53090. */
  53091. animate(preWarm?: boolean): void;
  53092. private _createFactorGradientTexture;
  53093. private _createSizeGradientTexture;
  53094. private _createAngularSpeedGradientTexture;
  53095. private _createVelocityGradientTexture;
  53096. private _createLimitVelocityGradientTexture;
  53097. private _createDragGradientTexture;
  53098. private _createColorGradientTexture;
  53099. /**
  53100. * Renders the particle system in its current state
  53101. * @param preWarm defines if the system should only update the particles but not render them
  53102. * @returns the current number of particles
  53103. */
  53104. render(preWarm?: boolean): number;
  53105. /**
  53106. * Rebuilds the particle system
  53107. */
  53108. rebuild(): void;
  53109. private _releaseBuffers;
  53110. private _releaseVAOs;
  53111. /**
  53112. * Disposes the particle system and free the associated resources
  53113. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53114. */
  53115. dispose(disposeTexture?: boolean): void;
  53116. /**
  53117. * Clones the particle system.
  53118. * @param name The name of the cloned object
  53119. * @param newEmitter The new emitter to use
  53120. * @returns the cloned particle system
  53121. */
  53122. clone(name: string, newEmitter: any): GPUParticleSystem;
  53123. /**
  53124. * Serializes the particle system to a JSON object.
  53125. * @returns the JSON object
  53126. */
  53127. serialize(): any;
  53128. /**
  53129. * Parses a JSON object to create a GPU particle system.
  53130. * @param parsedParticleSystem The JSON object to parse
  53131. * @param scene The scene to create the particle system in
  53132. * @param rootUrl The root url to use to load external dependencies like texture
  53133. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53134. * @returns the parsed GPU particle system
  53135. */
  53136. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53137. }
  53138. }
  53139. declare module "babylonjs/Particles/particleSystemSet" {
  53140. import { Nullable } from "babylonjs/types";
  53141. import { Color3 } from "babylonjs/Maths/math";
  53142. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53144. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53145. import { Scene, IDisposable } from "babylonjs/scene";
  53146. /**
  53147. * Represents a set of particle systems working together to create a specific effect
  53148. */
  53149. export class ParticleSystemSet implements IDisposable {
  53150. private _emitterCreationOptions;
  53151. private _emitterNode;
  53152. /**
  53153. * Gets the particle system list
  53154. */
  53155. systems: IParticleSystem[];
  53156. /**
  53157. * Gets the emitter node used with this set
  53158. */
  53159. readonly emitterNode: Nullable<TransformNode>;
  53160. /**
  53161. * Creates a new emitter mesh as a sphere
  53162. * @param options defines the options used to create the sphere
  53163. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53164. * @param scene defines the hosting scene
  53165. */
  53166. setEmitterAsSphere(options: {
  53167. diameter: number;
  53168. segments: number;
  53169. color: Color3;
  53170. }, renderingGroupId: number, scene: Scene): void;
  53171. /**
  53172. * Starts all particle systems of the set
  53173. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53174. */
  53175. start(emitter?: AbstractMesh): void;
  53176. /**
  53177. * Release all associated resources
  53178. */
  53179. dispose(): void;
  53180. /**
  53181. * Serialize the set into a JSON compatible object
  53182. * @returns a JSON compatible representation of the set
  53183. */
  53184. serialize(): any;
  53185. /**
  53186. * Parse a new ParticleSystemSet from a serialized source
  53187. * @param data defines a JSON compatible representation of the set
  53188. * @param scene defines the hosting scene
  53189. * @param gpu defines if we want GPU particles or CPU particles
  53190. * @returns a new ParticleSystemSet
  53191. */
  53192. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53193. }
  53194. }
  53195. declare module "babylonjs/Particles/particleHelper" {
  53196. import { Nullable } from "babylonjs/types";
  53197. import { Scene } from "babylonjs/scene";
  53198. import { Vector3 } from "babylonjs/Maths/math";
  53199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53200. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53201. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53202. /**
  53203. * This class is made for on one-liner static method to help creating particle system set.
  53204. */
  53205. export class ParticleHelper {
  53206. /**
  53207. * Gets or sets base Assets URL
  53208. */
  53209. static BaseAssetsUrl: string;
  53210. /**
  53211. * Create a default particle system that you can tweak
  53212. * @param emitter defines the emitter to use
  53213. * @param capacity defines the system capacity (default is 500 particles)
  53214. * @param scene defines the hosting scene
  53215. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53216. * @returns the new Particle system
  53217. */
  53218. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53219. /**
  53220. * This is the main static method (one-liner) of this helper to create different particle systems
  53221. * @param type This string represents the type to the particle system to create
  53222. * @param scene The scene where the particle system should live
  53223. * @param gpu If the system will use gpu
  53224. * @returns the ParticleSystemSet created
  53225. */
  53226. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53227. /**
  53228. * Static function used to export a particle system to a ParticleSystemSet variable.
  53229. * Please note that the emitter shape is not exported
  53230. * @param systems defines the particle systems to export
  53231. * @returns the created particle system set
  53232. */
  53233. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53234. }
  53235. }
  53236. declare module "babylonjs/Particles/particleSystemComponent" {
  53237. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53238. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53239. import "babylonjs/Shaders/particles.vertex";
  53240. module "babylonjs/Engines/engine" {
  53241. interface Engine {
  53242. /**
  53243. * Create an effect to use with particle systems.
  53244. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53245. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53246. * @param uniformsNames defines a list of attribute names
  53247. * @param samplers defines an array of string used to represent textures
  53248. * @param defines defines the string containing the defines to use to compile the shaders
  53249. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53250. * @param onCompiled defines a function to call when the effect creation is successful
  53251. * @param onError defines a function to call when the effect creation has failed
  53252. * @returns the new Effect
  53253. */
  53254. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53255. }
  53256. }
  53257. module "babylonjs/Meshes/mesh" {
  53258. interface Mesh {
  53259. /**
  53260. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53261. * @returns an array of IParticleSystem
  53262. */
  53263. getEmittedParticleSystems(): IParticleSystem[];
  53264. /**
  53265. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53266. * @returns an array of IParticleSystem
  53267. */
  53268. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53269. }
  53270. }
  53271. /**
  53272. * @hidden
  53273. */
  53274. export var _IDoNeedToBeInTheBuild: number;
  53275. }
  53276. declare module "babylonjs/Particles/index" {
  53277. export * from "babylonjs/Particles/baseParticleSystem";
  53278. export * from "babylonjs/Particles/EmitterTypes/index";
  53279. export * from "babylonjs/Particles/gpuParticleSystem";
  53280. export * from "babylonjs/Particles/IParticleSystem";
  53281. export * from "babylonjs/Particles/particle";
  53282. export * from "babylonjs/Particles/particleHelper";
  53283. export * from "babylonjs/Particles/particleSystem";
  53284. export * from "babylonjs/Particles/particleSystemComponent";
  53285. export * from "babylonjs/Particles/particleSystemSet";
  53286. export * from "babylonjs/Particles/solidParticle";
  53287. export * from "babylonjs/Particles/solidParticleSystem";
  53288. export * from "babylonjs/Particles/subEmitter";
  53289. }
  53290. declare module "babylonjs/Physics/physicsEngineComponent" {
  53291. import { Nullable } from "babylonjs/types";
  53292. import { Observable, Observer } from "babylonjs/Misc/observable";
  53293. import { Vector3 } from "babylonjs/Maths/math";
  53294. import { Mesh } from "babylonjs/Meshes/mesh";
  53295. import { ISceneComponent } from "babylonjs/sceneComponent";
  53296. import { Scene } from "babylonjs/scene";
  53297. import { Node } from "babylonjs/node";
  53298. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53299. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53300. module "babylonjs/scene" {
  53301. interface Scene {
  53302. /** @hidden (Backing field) */
  53303. _physicsEngine: Nullable<IPhysicsEngine>;
  53304. /**
  53305. * Gets the current physics engine
  53306. * @returns a IPhysicsEngine or null if none attached
  53307. */
  53308. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53309. /**
  53310. * Enables physics to the current scene
  53311. * @param gravity defines the scene's gravity for the physics engine
  53312. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53313. * @return a boolean indicating if the physics engine was initialized
  53314. */
  53315. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53316. /**
  53317. * Disables and disposes the physics engine associated with the scene
  53318. */
  53319. disablePhysicsEngine(): void;
  53320. /**
  53321. * Gets a boolean indicating if there is an active physics engine
  53322. * @returns a boolean indicating if there is an active physics engine
  53323. */
  53324. isPhysicsEnabled(): boolean;
  53325. /**
  53326. * Deletes a physics compound impostor
  53327. * @param compound defines the compound to delete
  53328. */
  53329. deleteCompoundImpostor(compound: any): void;
  53330. /**
  53331. * An event triggered when physic simulation is about to be run
  53332. */
  53333. onBeforePhysicsObservable: Observable<Scene>;
  53334. /**
  53335. * An event triggered when physic simulation has been done
  53336. */
  53337. onAfterPhysicsObservable: Observable<Scene>;
  53338. }
  53339. }
  53340. module "babylonjs/Meshes/abstractMesh" {
  53341. interface AbstractMesh {
  53342. /** @hidden */
  53343. _physicsImpostor: Nullable<PhysicsImpostor>;
  53344. /**
  53345. * Gets or sets impostor used for physic simulation
  53346. * @see http://doc.babylonjs.com/features/physics_engine
  53347. */
  53348. physicsImpostor: Nullable<PhysicsImpostor>;
  53349. /**
  53350. * Gets the current physics impostor
  53351. * @see http://doc.babylonjs.com/features/physics_engine
  53352. * @returns a physics impostor or null
  53353. */
  53354. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53355. /** Apply a physic impulse to the mesh
  53356. * @param force defines the force to apply
  53357. * @param contactPoint defines where to apply the force
  53358. * @returns the current mesh
  53359. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53360. */
  53361. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53362. /**
  53363. * Creates a physic joint between two meshes
  53364. * @param otherMesh defines the other mesh to use
  53365. * @param pivot1 defines the pivot to use on this mesh
  53366. * @param pivot2 defines the pivot to use on the other mesh
  53367. * @param options defines additional options (can be plugin dependent)
  53368. * @returns the current mesh
  53369. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53370. */
  53371. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53372. /** @hidden */
  53373. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53374. }
  53375. }
  53376. /**
  53377. * Defines the physics engine scene component responsible to manage a physics engine
  53378. */
  53379. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53380. /**
  53381. * The component name helpful to identify the component in the list of scene components.
  53382. */
  53383. readonly name: string;
  53384. /**
  53385. * The scene the component belongs to.
  53386. */
  53387. scene: Scene;
  53388. /**
  53389. * Creates a new instance of the component for the given scene
  53390. * @param scene Defines the scene to register the component in
  53391. */
  53392. constructor(scene: Scene);
  53393. /**
  53394. * Registers the component in a given scene
  53395. */
  53396. register(): void;
  53397. /**
  53398. * Rebuilds the elements related to this component in case of
  53399. * context lost for instance.
  53400. */
  53401. rebuild(): void;
  53402. /**
  53403. * Disposes the component and the associated ressources
  53404. */
  53405. dispose(): void;
  53406. }
  53407. }
  53408. declare module "babylonjs/Physics/physicsHelper" {
  53409. import { Nullable } from "babylonjs/types";
  53410. import { Vector3 } from "babylonjs/Maths/math";
  53411. import { Mesh } from "babylonjs/Meshes/mesh";
  53412. import { Scene } from "babylonjs/scene";
  53413. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53414. /**
  53415. * A helper for physics simulations
  53416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53417. */
  53418. export class PhysicsHelper {
  53419. private _scene;
  53420. private _physicsEngine;
  53421. /**
  53422. * Initializes the Physics helper
  53423. * @param scene Babylon.js scene
  53424. */
  53425. constructor(scene: Scene);
  53426. /**
  53427. * Applies a radial explosion impulse
  53428. * @param origin the origin of the explosion
  53429. * @param radiusOrEventOptions the radius or the options of radial explosion
  53430. * @param strength the explosion strength
  53431. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53432. * @returns A physics radial explosion event, or null
  53433. */
  53434. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53435. /**
  53436. * Applies a radial explosion force
  53437. * @param origin the origin of the explosion
  53438. * @param radiusOrEventOptions the radius or the options of radial explosion
  53439. * @param strength the explosion strength
  53440. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53441. * @returns A physics radial explosion event, or null
  53442. */
  53443. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53444. /**
  53445. * Creates a gravitational field
  53446. * @param origin the origin of the explosion
  53447. * @param radiusOrEventOptions the radius or the options of radial explosion
  53448. * @param strength the explosion strength
  53449. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53450. * @returns A physics gravitational field event, or null
  53451. */
  53452. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53453. /**
  53454. * Creates a physics updraft event
  53455. * @param origin the origin of the updraft
  53456. * @param radiusOrEventOptions the radius or the options of the updraft
  53457. * @param strength the strength of the updraft
  53458. * @param height the height of the updraft
  53459. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53460. * @returns A physics updraft event, or null
  53461. */
  53462. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53463. /**
  53464. * Creates a physics vortex event
  53465. * @param origin the of the vortex
  53466. * @param radiusOrEventOptions the radius or the options of the vortex
  53467. * @param strength the strength of the vortex
  53468. * @param height the height of the vortex
  53469. * @returns a Physics vortex event, or null
  53470. * A physics vortex event or null
  53471. */
  53472. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53473. }
  53474. /**
  53475. * Represents a physics radial explosion event
  53476. */
  53477. class PhysicsRadialExplosionEvent {
  53478. private _scene;
  53479. private _options;
  53480. private _sphere;
  53481. private _dataFetched;
  53482. /**
  53483. * Initializes a radial explosioin event
  53484. * @param _scene BabylonJS scene
  53485. * @param _options The options for the vortex event
  53486. */
  53487. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53488. /**
  53489. * Returns the data related to the radial explosion event (sphere).
  53490. * @returns The radial explosion event data
  53491. */
  53492. getData(): PhysicsRadialExplosionEventData;
  53493. /**
  53494. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53495. * @param impostor A physics imposter
  53496. * @param origin the origin of the explosion
  53497. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53498. */
  53499. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53500. /**
  53501. * Triggers affecterd impostors callbacks
  53502. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53503. */
  53504. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53505. /**
  53506. * Disposes the sphere.
  53507. * @param force Specifies if the sphere should be disposed by force
  53508. */
  53509. dispose(force?: boolean): void;
  53510. /*** Helpers ***/
  53511. private _prepareSphere;
  53512. private _intersectsWithSphere;
  53513. }
  53514. /**
  53515. * Represents a gravitational field event
  53516. */
  53517. class PhysicsGravitationalFieldEvent {
  53518. private _physicsHelper;
  53519. private _scene;
  53520. private _origin;
  53521. private _options;
  53522. private _tickCallback;
  53523. private _sphere;
  53524. private _dataFetched;
  53525. /**
  53526. * Initializes the physics gravitational field event
  53527. * @param _physicsHelper A physics helper
  53528. * @param _scene BabylonJS scene
  53529. * @param _origin The origin position of the gravitational field event
  53530. * @param _options The options for the vortex event
  53531. */
  53532. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53533. /**
  53534. * Returns the data related to the gravitational field event (sphere).
  53535. * @returns A gravitational field event
  53536. */
  53537. getData(): PhysicsGravitationalFieldEventData;
  53538. /**
  53539. * Enables the gravitational field.
  53540. */
  53541. enable(): void;
  53542. /**
  53543. * Disables the gravitational field.
  53544. */
  53545. disable(): void;
  53546. /**
  53547. * Disposes the sphere.
  53548. * @param force The force to dispose from the gravitational field event
  53549. */
  53550. dispose(force?: boolean): void;
  53551. private _tick;
  53552. }
  53553. /**
  53554. * Represents a physics updraft event
  53555. */
  53556. class PhysicsUpdraftEvent {
  53557. private _scene;
  53558. private _origin;
  53559. private _options;
  53560. private _physicsEngine;
  53561. private _originTop;
  53562. private _originDirection;
  53563. private _tickCallback;
  53564. private _cylinder;
  53565. private _cylinderPosition;
  53566. private _dataFetched;
  53567. /**
  53568. * Initializes the physics updraft event
  53569. * @param _scene BabylonJS scene
  53570. * @param _origin The origin position of the updraft
  53571. * @param _options The options for the updraft event
  53572. */
  53573. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53574. /**
  53575. * Returns the data related to the updraft event (cylinder).
  53576. * @returns A physics updraft event
  53577. */
  53578. getData(): PhysicsUpdraftEventData;
  53579. /**
  53580. * Enables the updraft.
  53581. */
  53582. enable(): void;
  53583. /**
  53584. * Disables the updraft.
  53585. */
  53586. disable(): void;
  53587. /**
  53588. * Disposes the cylinder.
  53589. * @param force Specifies if the updraft should be disposed by force
  53590. */
  53591. dispose(force?: boolean): void;
  53592. private getImpostorHitData;
  53593. private _tick;
  53594. /*** Helpers ***/
  53595. private _prepareCylinder;
  53596. private _intersectsWithCylinder;
  53597. }
  53598. /**
  53599. * Represents a physics vortex event
  53600. */
  53601. class PhysicsVortexEvent {
  53602. private _scene;
  53603. private _origin;
  53604. private _options;
  53605. private _physicsEngine;
  53606. private _originTop;
  53607. private _tickCallback;
  53608. private _cylinder;
  53609. private _cylinderPosition;
  53610. private _dataFetched;
  53611. /**
  53612. * Initializes the physics vortex event
  53613. * @param _scene The BabylonJS scene
  53614. * @param _origin The origin position of the vortex
  53615. * @param _options The options for the vortex event
  53616. */
  53617. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53618. /**
  53619. * Returns the data related to the vortex event (cylinder).
  53620. * @returns The physics vortex event data
  53621. */
  53622. getData(): PhysicsVortexEventData;
  53623. /**
  53624. * Enables the vortex.
  53625. */
  53626. enable(): void;
  53627. /**
  53628. * Disables the cortex.
  53629. */
  53630. disable(): void;
  53631. /**
  53632. * Disposes the sphere.
  53633. * @param force
  53634. */
  53635. dispose(force?: boolean): void;
  53636. private getImpostorHitData;
  53637. private _tick;
  53638. /*** Helpers ***/
  53639. private _prepareCylinder;
  53640. private _intersectsWithCylinder;
  53641. }
  53642. /**
  53643. * Options fot the radial explosion event
  53644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53645. */
  53646. export class PhysicsRadialExplosionEventOptions {
  53647. /**
  53648. * The radius of the sphere for the radial explosion.
  53649. */
  53650. radius: number;
  53651. /**
  53652. * The strenth of the explosion.
  53653. */
  53654. strength: number;
  53655. /**
  53656. * The strenght of the force in correspondence to the distance of the affected object
  53657. */
  53658. falloff: PhysicsRadialImpulseFalloff;
  53659. /**
  53660. * Sphere options for the radial explosion.
  53661. */
  53662. sphere: {
  53663. segments: number;
  53664. diameter: number;
  53665. };
  53666. /**
  53667. * Sphere options for the radial explosion.
  53668. */
  53669. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53670. }
  53671. /**
  53672. * Options fot the updraft event
  53673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53674. */
  53675. export class PhysicsUpdraftEventOptions {
  53676. /**
  53677. * The radius of the cylinder for the vortex
  53678. */
  53679. radius: number;
  53680. /**
  53681. * The strenth of the updraft.
  53682. */
  53683. strength: number;
  53684. /**
  53685. * The height of the cylinder for the updraft.
  53686. */
  53687. height: number;
  53688. /**
  53689. * The mode for the the updraft.
  53690. */
  53691. updraftMode: PhysicsUpdraftMode;
  53692. }
  53693. /**
  53694. * Options fot the vortex event
  53695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53696. */
  53697. export class PhysicsVortexEventOptions {
  53698. /**
  53699. * The radius of the cylinder for the vortex
  53700. */
  53701. radius: number;
  53702. /**
  53703. * The strenth of the vortex.
  53704. */
  53705. strength: number;
  53706. /**
  53707. * The height of the cylinder for the vortex.
  53708. */
  53709. height: number;
  53710. /**
  53711. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53712. */
  53713. centripetalForceThreshold: number;
  53714. /**
  53715. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53716. */
  53717. centripetalForceMultiplier: number;
  53718. /**
  53719. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53720. */
  53721. centrifugalForceMultiplier: number;
  53722. /**
  53723. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53724. */
  53725. updraftForceMultiplier: number;
  53726. }
  53727. /**
  53728. * The strenght of the force in correspondence to the distance of the affected object
  53729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53730. */
  53731. export enum PhysicsRadialImpulseFalloff {
  53732. /** Defines that impulse is constant in strength across it's whole radius */
  53733. Constant = 0,
  53734. /** Defines that impulse gets weaker if it's further from the origin */
  53735. Linear = 1
  53736. }
  53737. /**
  53738. * The strength of the force in correspondence to the distance of the affected object
  53739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53740. */
  53741. export enum PhysicsUpdraftMode {
  53742. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53743. Center = 0,
  53744. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53745. Perpendicular = 1
  53746. }
  53747. /**
  53748. * Interface for a physics hit data
  53749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53750. */
  53751. export interface PhysicsHitData {
  53752. /**
  53753. * The force applied at the contact point
  53754. */
  53755. force: Vector3;
  53756. /**
  53757. * The contact point
  53758. */
  53759. contactPoint: Vector3;
  53760. /**
  53761. * The distance from the origin to the contact point
  53762. */
  53763. distanceFromOrigin: number;
  53764. }
  53765. /**
  53766. * Interface for radial explosion event data
  53767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53768. */
  53769. export interface PhysicsRadialExplosionEventData {
  53770. /**
  53771. * A sphere used for the radial explosion event
  53772. */
  53773. sphere: Mesh;
  53774. }
  53775. /**
  53776. * Interface for gravitational field event data
  53777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53778. */
  53779. export interface PhysicsGravitationalFieldEventData {
  53780. /**
  53781. * A sphere mesh used for the gravitational field event
  53782. */
  53783. sphere: Mesh;
  53784. }
  53785. /**
  53786. * Interface for updraft event data
  53787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53788. */
  53789. export interface PhysicsUpdraftEventData {
  53790. /**
  53791. * A cylinder used for the updraft event
  53792. */
  53793. cylinder: Mesh;
  53794. }
  53795. /**
  53796. * Interface for vortex event data
  53797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53798. */
  53799. export interface PhysicsVortexEventData {
  53800. /**
  53801. * A cylinder used for the vortex event
  53802. */
  53803. cylinder: Mesh;
  53804. }
  53805. /**
  53806. * Interface for an affected physics impostor
  53807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53808. */
  53809. export interface PhysicsAffectedImpostorWithData {
  53810. /**
  53811. * The impostor affected by the effect
  53812. */
  53813. impostor: PhysicsImpostor;
  53814. /**
  53815. * The data about the hit/horce from the explosion
  53816. */
  53817. hitData: PhysicsHitData;
  53818. }
  53819. }
  53820. declare module "babylonjs/Physics/Plugins/index" {
  53821. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53822. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53823. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53824. }
  53825. declare module "babylonjs/Physics/index" {
  53826. export * from "babylonjs/Physics/IPhysicsEngine";
  53827. export * from "babylonjs/Physics/physicsEngine";
  53828. export * from "babylonjs/Physics/physicsEngineComponent";
  53829. export * from "babylonjs/Physics/physicsHelper";
  53830. export * from "babylonjs/Physics/physicsImpostor";
  53831. export * from "babylonjs/Physics/physicsJoint";
  53832. export * from "babylonjs/Physics/Plugins/index";
  53833. }
  53834. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53835. /** @hidden */
  53836. export var blackAndWhitePixelShader: {
  53837. name: string;
  53838. shader: string;
  53839. };
  53840. }
  53841. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53843. import { Camera } from "babylonjs/Cameras/camera";
  53844. import { Engine } from "babylonjs/Engines/engine";
  53845. import "babylonjs/Shaders/blackAndWhite.fragment";
  53846. /**
  53847. * Post process used to render in black and white
  53848. */
  53849. export class BlackAndWhitePostProcess extends PostProcess {
  53850. /**
  53851. * Linear about to convert he result to black and white (default: 1)
  53852. */
  53853. degree: number;
  53854. /**
  53855. * Creates a black and white post process
  53856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53857. * @param name The name of the effect.
  53858. * @param options The required width/height ratio to downsize to before computing the render pass.
  53859. * @param camera The camera to apply the render pass to.
  53860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53861. * @param engine The engine which the post process will be applied. (default: current engine)
  53862. * @param reusable If the post process can be reused on the same frame. (default: false)
  53863. */
  53864. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53865. }
  53866. }
  53867. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53868. import { Nullable } from "babylonjs/types";
  53869. import { Camera } from "babylonjs/Cameras/camera";
  53870. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53871. import { Engine } from "babylonjs/Engines/engine";
  53872. /**
  53873. * This represents a set of one or more post processes in Babylon.
  53874. * A post process can be used to apply a shader to a texture after it is rendered.
  53875. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53876. */
  53877. export class PostProcessRenderEffect {
  53878. private _postProcesses;
  53879. private _getPostProcesses;
  53880. private _singleInstance;
  53881. private _cameras;
  53882. private _indicesForCamera;
  53883. /**
  53884. * Name of the effect
  53885. * @hidden
  53886. */
  53887. _name: string;
  53888. /**
  53889. * Instantiates a post process render effect.
  53890. * A post process can be used to apply a shader to a texture after it is rendered.
  53891. * @param engine The engine the effect is tied to
  53892. * @param name The name of the effect
  53893. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53894. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53895. */
  53896. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53897. /**
  53898. * Checks if all the post processes in the effect are supported.
  53899. */
  53900. readonly isSupported: boolean;
  53901. /**
  53902. * Updates the current state of the effect
  53903. * @hidden
  53904. */
  53905. _update(): void;
  53906. /**
  53907. * Attaches the effect on cameras
  53908. * @param cameras The camera to attach to.
  53909. * @hidden
  53910. */
  53911. _attachCameras(cameras: Camera): void;
  53912. /**
  53913. * Attaches the effect on cameras
  53914. * @param cameras The camera to attach to.
  53915. * @hidden
  53916. */
  53917. _attachCameras(cameras: Camera[]): void;
  53918. /**
  53919. * Detatches the effect on cameras
  53920. * @param cameras The camera to detatch from.
  53921. * @hidden
  53922. */
  53923. _detachCameras(cameras: Camera): void;
  53924. /**
  53925. * Detatches the effect on cameras
  53926. * @param cameras The camera to detatch from.
  53927. * @hidden
  53928. */
  53929. _detachCameras(cameras: Camera[]): void;
  53930. /**
  53931. * Enables the effect on given cameras
  53932. * @param cameras The camera to enable.
  53933. * @hidden
  53934. */
  53935. _enable(cameras: Camera): void;
  53936. /**
  53937. * Enables the effect on given cameras
  53938. * @param cameras The camera to enable.
  53939. * @hidden
  53940. */
  53941. _enable(cameras: Nullable<Camera[]>): void;
  53942. /**
  53943. * Disables the effect on the given cameras
  53944. * @param cameras The camera to disable.
  53945. * @hidden
  53946. */
  53947. _disable(cameras: Camera): void;
  53948. /**
  53949. * Disables the effect on the given cameras
  53950. * @param cameras The camera to disable.
  53951. * @hidden
  53952. */
  53953. _disable(cameras: Nullable<Camera[]>): void;
  53954. /**
  53955. * Gets a list of the post processes contained in the effect.
  53956. * @param camera The camera to get the post processes on.
  53957. * @returns The list of the post processes in the effect.
  53958. */
  53959. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53960. }
  53961. }
  53962. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53964. /** @hidden */
  53965. export var extractHighlightsPixelShader: {
  53966. name: string;
  53967. shader: string;
  53968. };
  53969. }
  53970. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53971. import { Nullable } from "babylonjs/types";
  53972. import { Camera } from "babylonjs/Cameras/camera";
  53973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53974. import { Engine } from "babylonjs/Engines/engine";
  53975. import "babylonjs/Shaders/extractHighlights.fragment";
  53976. /**
  53977. * 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.
  53978. */
  53979. export class ExtractHighlightsPostProcess extends PostProcess {
  53980. /**
  53981. * The luminance threshold, pixels below this value will be set to black.
  53982. */
  53983. threshold: number;
  53984. /** @hidden */
  53985. _exposure: number;
  53986. /**
  53987. * Post process which has the input texture to be used when performing highlight extraction
  53988. * @hidden
  53989. */
  53990. _inputPostProcess: Nullable<PostProcess>;
  53991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53992. }
  53993. }
  53994. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53995. /** @hidden */
  53996. export var bloomMergePixelShader: {
  53997. name: string;
  53998. shader: string;
  53999. };
  54000. }
  54001. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54002. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54003. import { Nullable } from "babylonjs/types";
  54004. import { Engine } from "babylonjs/Engines/engine";
  54005. import { Camera } from "babylonjs/Cameras/camera";
  54006. import "babylonjs/Shaders/bloomMerge.fragment";
  54007. /**
  54008. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54009. */
  54010. export class BloomMergePostProcess extends PostProcess {
  54011. /** Weight of the bloom to be added to the original input. */
  54012. weight: number;
  54013. /**
  54014. * Creates a new instance of @see BloomMergePostProcess
  54015. * @param name The name of the effect.
  54016. * @param originalFromInput Post process which's input will be used for the merge.
  54017. * @param blurred Blurred highlights post process which's output will be used.
  54018. * @param weight Weight of the bloom to be added to the original input.
  54019. * @param options The required width/height ratio to downsize to before computing the render pass.
  54020. * @param camera The camera to apply the render pass to.
  54021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54022. * @param engine The engine which the post process will be applied. (default: current engine)
  54023. * @param reusable If the post process can be reused on the same frame. (default: false)
  54024. * @param textureType Type of textures used when performing the post process. (default: 0)
  54025. * @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)
  54026. */
  54027. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54028. /** Weight of the bloom to be added to the original input. */
  54029. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54030. }
  54031. }
  54032. declare module "babylonjs/PostProcesses/bloomEffect" {
  54033. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54034. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54035. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54036. import { Camera } from "babylonjs/Cameras/camera";
  54037. import { Scene } from "babylonjs/scene";
  54038. /**
  54039. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54040. */
  54041. export class BloomEffect extends PostProcessRenderEffect {
  54042. private bloomScale;
  54043. /**
  54044. * @hidden Internal
  54045. */
  54046. _effects: Array<PostProcess>;
  54047. /**
  54048. * @hidden Internal
  54049. */
  54050. _downscale: ExtractHighlightsPostProcess;
  54051. private _blurX;
  54052. private _blurY;
  54053. private _merge;
  54054. /**
  54055. * The luminance threshold to find bright areas of the image to bloom.
  54056. */
  54057. threshold: number;
  54058. /**
  54059. * The strength of the bloom.
  54060. */
  54061. weight: number;
  54062. /**
  54063. * Specifies the size of the bloom blur kernel, relative to the final output size
  54064. */
  54065. kernel: number;
  54066. /**
  54067. * Creates a new instance of @see BloomEffect
  54068. * @param scene The scene the effect belongs to.
  54069. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54070. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54071. * @param bloomWeight The the strength of bloom.
  54072. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54073. * @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)
  54074. */
  54075. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54076. /**
  54077. * Disposes each of the internal effects for a given camera.
  54078. * @param camera The camera to dispose the effect on.
  54079. */
  54080. disposeEffects(camera: Camera): void;
  54081. /**
  54082. * @hidden Internal
  54083. */
  54084. _updateEffects(): void;
  54085. /**
  54086. * Internal
  54087. * @returns if all the contained post processes are ready.
  54088. * @hidden
  54089. */
  54090. _isReady(): boolean;
  54091. }
  54092. }
  54093. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54094. /** @hidden */
  54095. export var chromaticAberrationPixelShader: {
  54096. name: string;
  54097. shader: string;
  54098. };
  54099. }
  54100. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54101. import { Vector2 } from "babylonjs/Maths/math";
  54102. import { Nullable } from "babylonjs/types";
  54103. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54104. import { Camera } from "babylonjs/Cameras/camera";
  54105. import { Engine } from "babylonjs/Engines/engine";
  54106. import "babylonjs/Shaders/chromaticAberration.fragment";
  54107. /**
  54108. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54109. */
  54110. export class ChromaticAberrationPostProcess extends PostProcess {
  54111. /**
  54112. * The amount of seperation of rgb channels (default: 30)
  54113. */
  54114. aberrationAmount: number;
  54115. /**
  54116. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54117. */
  54118. radialIntensity: number;
  54119. /**
  54120. * 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))
  54121. */
  54122. direction: Vector2;
  54123. /**
  54124. * 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))
  54125. */
  54126. centerPosition: Vector2;
  54127. /**
  54128. * Creates a new instance ChromaticAberrationPostProcess
  54129. * @param name The name of the effect.
  54130. * @param screenWidth The width of the screen to apply the effect on.
  54131. * @param screenHeight The height of the screen to apply the effect on.
  54132. * @param options The required width/height ratio to downsize to before computing the render pass.
  54133. * @param camera The camera to apply the render pass to.
  54134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54135. * @param engine The engine which the post process will be applied. (default: current engine)
  54136. * @param reusable If the post process can be reused on the same frame. (default: false)
  54137. * @param textureType Type of textures used when performing the post process. (default: 0)
  54138. * @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)
  54139. */
  54140. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54141. }
  54142. }
  54143. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54144. /** @hidden */
  54145. export var circleOfConfusionPixelShader: {
  54146. name: string;
  54147. shader: string;
  54148. };
  54149. }
  54150. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54151. import { Nullable } from "babylonjs/types";
  54152. import { Engine } from "babylonjs/Engines/engine";
  54153. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54155. import { Camera } from "babylonjs/Cameras/camera";
  54156. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54157. /**
  54158. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54159. */
  54160. export class CircleOfConfusionPostProcess extends PostProcess {
  54161. /**
  54162. * 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.
  54163. */
  54164. lensSize: number;
  54165. /**
  54166. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54167. */
  54168. fStop: number;
  54169. /**
  54170. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54171. */
  54172. focusDistance: number;
  54173. /**
  54174. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54175. */
  54176. focalLength: number;
  54177. private _depthTexture;
  54178. /**
  54179. * Creates a new instance CircleOfConfusionPostProcess
  54180. * @param name The name of the effect.
  54181. * @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.
  54182. * @param options The required width/height ratio to downsize to before computing the render pass.
  54183. * @param camera The camera to apply the render pass to.
  54184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54185. * @param engine The engine which the post process will be applied. (default: current engine)
  54186. * @param reusable If the post process can be reused on the same frame. (default: false)
  54187. * @param textureType Type of textures used when performing the post process. (default: 0)
  54188. * @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)
  54189. */
  54190. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54191. /**
  54192. * 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.
  54193. */
  54194. depthTexture: RenderTargetTexture;
  54195. }
  54196. }
  54197. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54198. /** @hidden */
  54199. export var colorCorrectionPixelShader: {
  54200. name: string;
  54201. shader: string;
  54202. };
  54203. }
  54204. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54206. import { Engine } from "babylonjs/Engines/engine";
  54207. import { Camera } from "babylonjs/Cameras/camera";
  54208. import "babylonjs/Shaders/colorCorrection.fragment";
  54209. /**
  54210. *
  54211. * This post-process allows the modification of rendered colors by using
  54212. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54213. *
  54214. * The object needs to be provided an url to a texture containing the color
  54215. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54216. * Use an image editing software to tweak the LUT to match your needs.
  54217. *
  54218. * For an example of a color LUT, see here:
  54219. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54220. * For explanations on color grading, see here:
  54221. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54222. *
  54223. */
  54224. export class ColorCorrectionPostProcess extends PostProcess {
  54225. private _colorTableTexture;
  54226. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54227. }
  54228. }
  54229. declare module "babylonjs/Shaders/convolution.fragment" {
  54230. /** @hidden */
  54231. export var convolutionPixelShader: {
  54232. name: string;
  54233. shader: string;
  54234. };
  54235. }
  54236. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54237. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54238. import { Nullable } from "babylonjs/types";
  54239. import { Camera } from "babylonjs/Cameras/camera";
  54240. import { Engine } from "babylonjs/Engines/engine";
  54241. import "babylonjs/Shaders/convolution.fragment";
  54242. /**
  54243. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54244. * input texture to perform effects such as edge detection or sharpening
  54245. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54246. */
  54247. export class ConvolutionPostProcess extends PostProcess {
  54248. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54249. kernel: number[];
  54250. /**
  54251. * Creates a new instance ConvolutionPostProcess
  54252. * @param name The name of the effect.
  54253. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54254. * @param options The required width/height ratio to downsize to before computing the render pass.
  54255. * @param camera The camera to apply the render pass to.
  54256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54257. * @param engine The engine which the post process will be applied. (default: current engine)
  54258. * @param reusable If the post process can be reused on the same frame. (default: false)
  54259. * @param textureType Type of textures used when performing the post process. (default: 0)
  54260. */
  54261. constructor(name: string,
  54262. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54263. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54264. /**
  54265. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54266. */
  54267. static EdgeDetect0Kernel: number[];
  54268. /**
  54269. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54270. */
  54271. static EdgeDetect1Kernel: number[];
  54272. /**
  54273. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54274. */
  54275. static EdgeDetect2Kernel: number[];
  54276. /**
  54277. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54278. */
  54279. static SharpenKernel: number[];
  54280. /**
  54281. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54282. */
  54283. static EmbossKernel: number[];
  54284. /**
  54285. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54286. */
  54287. static GaussianKernel: number[];
  54288. }
  54289. }
  54290. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54291. import { Nullable } from "babylonjs/types";
  54292. import { Vector2 } from "babylonjs/Maths/math";
  54293. import { Camera } from "babylonjs/Cameras/camera";
  54294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54295. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54296. import { Engine } from "babylonjs/Engines/engine";
  54297. import { Scene } from "babylonjs/scene";
  54298. /**
  54299. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54300. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54301. * based on samples that have a large difference in distance than the center pixel.
  54302. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54303. */
  54304. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54305. direction: Vector2;
  54306. /**
  54307. * Creates a new instance CircleOfConfusionPostProcess
  54308. * @param name The name of the effect.
  54309. * @param scene The scene the effect belongs to.
  54310. * @param direction The direction the blur should be applied.
  54311. * @param kernel The size of the kernel used to blur.
  54312. * @param options The required width/height ratio to downsize to before computing the render pass.
  54313. * @param camera The camera to apply the render pass to.
  54314. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54315. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54317. * @param engine The engine which the post process will be applied. (default: current engine)
  54318. * @param reusable If the post process can be reused on the same frame. (default: false)
  54319. * @param textureType Type of textures used when performing the post process. (default: 0)
  54320. * @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)
  54321. */
  54322. 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);
  54323. }
  54324. }
  54325. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54326. /** @hidden */
  54327. export var depthOfFieldMergePixelShader: {
  54328. name: string;
  54329. shader: string;
  54330. };
  54331. }
  54332. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54333. import { Nullable } from "babylonjs/types";
  54334. import { Camera } from "babylonjs/Cameras/camera";
  54335. import { Effect } from "babylonjs/Materials/effect";
  54336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54337. import { Engine } from "babylonjs/Engines/engine";
  54338. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54339. /**
  54340. * Options to be set when merging outputs from the default pipeline.
  54341. */
  54342. export class DepthOfFieldMergePostProcessOptions {
  54343. /**
  54344. * The original image to merge on top of
  54345. */
  54346. originalFromInput: PostProcess;
  54347. /**
  54348. * Parameters to perform the merge of the depth of field effect
  54349. */
  54350. depthOfField?: {
  54351. circleOfConfusion: PostProcess;
  54352. blurSteps: Array<PostProcess>;
  54353. };
  54354. /**
  54355. * Parameters to perform the merge of bloom effect
  54356. */
  54357. bloom?: {
  54358. blurred: PostProcess;
  54359. weight: number;
  54360. };
  54361. }
  54362. /**
  54363. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54364. */
  54365. export class DepthOfFieldMergePostProcess extends PostProcess {
  54366. private blurSteps;
  54367. /**
  54368. * Creates a new instance of DepthOfFieldMergePostProcess
  54369. * @param name The name of the effect.
  54370. * @param originalFromInput Post process which's input will be used for the merge.
  54371. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54372. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54373. * @param options The required width/height ratio to downsize to before computing the render pass.
  54374. * @param camera The camera to apply the render pass to.
  54375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54376. * @param engine The engine which the post process will be applied. (default: current engine)
  54377. * @param reusable If the post process can be reused on the same frame. (default: false)
  54378. * @param textureType Type of textures used when performing the post process. (default: 0)
  54379. * @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)
  54380. */
  54381. 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);
  54382. /**
  54383. * Updates the effect with the current post process compile time values and recompiles the shader.
  54384. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54385. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54386. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54387. * @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
  54388. * @param onCompiled Called when the shader has been compiled.
  54389. * @param onError Called if there is an error when compiling a shader.
  54390. */
  54391. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54392. }
  54393. }
  54394. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54395. import { Nullable } from "babylonjs/types";
  54396. import { Camera } from "babylonjs/Cameras/camera";
  54397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54398. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54399. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54400. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54401. import { Scene } from "babylonjs/scene";
  54402. /**
  54403. * Specifies the level of max blur that should be applied when using the depth of field effect
  54404. */
  54405. export enum DepthOfFieldEffectBlurLevel {
  54406. /**
  54407. * Subtle blur
  54408. */
  54409. Low = 0,
  54410. /**
  54411. * Medium blur
  54412. */
  54413. Medium = 1,
  54414. /**
  54415. * Large blur
  54416. */
  54417. High = 2
  54418. }
  54419. /**
  54420. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54421. */
  54422. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54423. private _circleOfConfusion;
  54424. /**
  54425. * @hidden Internal, blurs from high to low
  54426. */
  54427. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54428. private _depthOfFieldBlurY;
  54429. private _dofMerge;
  54430. /**
  54431. * @hidden Internal post processes in depth of field effect
  54432. */
  54433. _effects: Array<PostProcess>;
  54434. /**
  54435. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54436. */
  54437. focalLength: number;
  54438. /**
  54439. * F-Stop of the effect's camera. The diameter 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. * 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.
  54448. */
  54449. lensSize: number;
  54450. /**
  54451. * Creates a new instance DepthOfFieldEffect
  54452. * @param scene The scene the effect belongs to.
  54453. * @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.
  54454. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54455. * @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)
  54456. */
  54457. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54458. /**
  54459. * 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.
  54460. */
  54461. depthTexture: RenderTargetTexture;
  54462. /**
  54463. * Disposes each of the internal effects for a given camera.
  54464. * @param camera The camera to dispose the effect on.
  54465. */
  54466. disposeEffects(camera: Camera): void;
  54467. /**
  54468. * @hidden Internal
  54469. */
  54470. _updateEffects(): void;
  54471. /**
  54472. * Internal
  54473. * @returns if all the contained post processes are ready.
  54474. * @hidden
  54475. */
  54476. _isReady(): boolean;
  54477. }
  54478. }
  54479. declare module "babylonjs/Shaders/displayPass.fragment" {
  54480. /** @hidden */
  54481. export var displayPassPixelShader: {
  54482. name: string;
  54483. shader: string;
  54484. };
  54485. }
  54486. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54487. import { Nullable } from "babylonjs/types";
  54488. import { Camera } from "babylonjs/Cameras/camera";
  54489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54490. import { Engine } from "babylonjs/Engines/engine";
  54491. import "babylonjs/Shaders/displayPass.fragment";
  54492. /**
  54493. * DisplayPassPostProcess which produces an output the same as it's input
  54494. */
  54495. export class DisplayPassPostProcess extends PostProcess {
  54496. /**
  54497. * Creates the DisplayPassPostProcess
  54498. * @param name The name of the effect.
  54499. * @param options The required width/height ratio to downsize to before computing the render pass.
  54500. * @param camera The camera to apply the render pass to.
  54501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54502. * @param engine The engine which the post process will be applied. (default: current engine)
  54503. * @param reusable If the post process can be reused on the same frame. (default: false)
  54504. */
  54505. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54506. }
  54507. }
  54508. declare module "babylonjs/Shaders/filter.fragment" {
  54509. /** @hidden */
  54510. export var filterPixelShader: {
  54511. name: string;
  54512. shader: string;
  54513. };
  54514. }
  54515. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54516. import { Nullable } from "babylonjs/types";
  54517. import { Matrix } from "babylonjs/Maths/math";
  54518. import { Camera } from "babylonjs/Cameras/camera";
  54519. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54520. import { Engine } from "babylonjs/Engines/engine";
  54521. import "babylonjs/Shaders/filter.fragment";
  54522. /**
  54523. * Applies a kernel filter to the image
  54524. */
  54525. export class FilterPostProcess extends PostProcess {
  54526. /** The matrix to be applied to the image */
  54527. kernelMatrix: Matrix;
  54528. /**
  54529. *
  54530. * @param name The name of the effect.
  54531. * @param kernelMatrix The matrix to be applied to the image
  54532. * @param options The required width/height ratio to downsize to before computing the render pass.
  54533. * @param camera The camera to apply the render pass to.
  54534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54535. * @param engine The engine which the post process will be applied. (default: current engine)
  54536. * @param reusable If the post process can be reused on the same frame. (default: false)
  54537. */
  54538. constructor(name: string,
  54539. /** The matrix to be applied to the image */
  54540. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54541. }
  54542. }
  54543. declare module "babylonjs/Shaders/fxaa.fragment" {
  54544. /** @hidden */
  54545. export var fxaaPixelShader: {
  54546. name: string;
  54547. shader: string;
  54548. };
  54549. }
  54550. declare module "babylonjs/Shaders/fxaa.vertex" {
  54551. /** @hidden */
  54552. export var fxaaVertexShader: {
  54553. name: string;
  54554. shader: string;
  54555. };
  54556. }
  54557. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54558. import { Nullable } from "babylonjs/types";
  54559. import { Camera } from "babylonjs/Cameras/camera";
  54560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54561. import { Engine } from "babylonjs/Engines/engine";
  54562. import "babylonjs/Shaders/fxaa.fragment";
  54563. import "babylonjs/Shaders/fxaa.vertex";
  54564. /**
  54565. * Fxaa post process
  54566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54567. */
  54568. export class FxaaPostProcess extends PostProcess {
  54569. /** @hidden */
  54570. texelWidth: number;
  54571. /** @hidden */
  54572. texelHeight: number;
  54573. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54574. private _getDefines;
  54575. }
  54576. }
  54577. declare module "babylonjs/Shaders/grain.fragment" {
  54578. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54579. /** @hidden */
  54580. export var grainPixelShader: {
  54581. name: string;
  54582. shader: string;
  54583. };
  54584. }
  54585. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54586. import { Nullable } from "babylonjs/types";
  54587. import { Camera } from "babylonjs/Cameras/camera";
  54588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54589. import { Engine } from "babylonjs/Engines/engine";
  54590. import "babylonjs/Shaders/grain.fragment";
  54591. /**
  54592. * The GrainPostProcess adds noise to the image at mid luminance levels
  54593. */
  54594. export class GrainPostProcess extends PostProcess {
  54595. /**
  54596. * The intensity of the grain added (default: 30)
  54597. */
  54598. intensity: number;
  54599. /**
  54600. * If the grain should be randomized on every frame
  54601. */
  54602. animated: boolean;
  54603. /**
  54604. * Creates a new instance of @see GrainPostProcess
  54605. * @param name The name of the effect.
  54606. * @param options The required width/height ratio to downsize to before computing the render pass.
  54607. * @param camera The camera to apply the render pass to.
  54608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54609. * @param engine The engine which the post process will be applied. (default: current engine)
  54610. * @param reusable If the post process can be reused on the same frame. (default: false)
  54611. * @param textureType Type of textures used when performing the post process. (default: 0)
  54612. * @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)
  54613. */
  54614. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54615. }
  54616. }
  54617. declare module "babylonjs/Shaders/highlights.fragment" {
  54618. /** @hidden */
  54619. export var highlightsPixelShader: {
  54620. name: string;
  54621. shader: string;
  54622. };
  54623. }
  54624. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54625. import { Nullable } from "babylonjs/types";
  54626. import { Camera } from "babylonjs/Cameras/camera";
  54627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54628. import { Engine } from "babylonjs/Engines/engine";
  54629. import "babylonjs/Shaders/highlights.fragment";
  54630. /**
  54631. * Extracts highlights from the image
  54632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54633. */
  54634. export class HighlightsPostProcess extends PostProcess {
  54635. /**
  54636. * Extracts highlights from the image
  54637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54638. * @param name The name of the effect.
  54639. * @param options The required width/height ratio to downsize to before computing the render pass.
  54640. * @param camera The camera to apply the render pass to.
  54641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54642. * @param engine The engine which the post process will be applied. (default: current engine)
  54643. * @param reusable If the post process can be reused on the same frame. (default: false)
  54644. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54645. */
  54646. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54647. }
  54648. }
  54649. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54650. /** @hidden */
  54651. export var mrtFragmentDeclaration: {
  54652. name: string;
  54653. shader: string;
  54654. };
  54655. }
  54656. declare module "babylonjs/Shaders/geometry.fragment" {
  54657. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54658. /** @hidden */
  54659. export var geometryPixelShader: {
  54660. name: string;
  54661. shader: string;
  54662. };
  54663. }
  54664. declare module "babylonjs/Shaders/geometry.vertex" {
  54665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54666. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54667. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54668. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54669. /** @hidden */
  54670. export var geometryVertexShader: {
  54671. name: string;
  54672. shader: string;
  54673. };
  54674. }
  54675. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54676. import { Matrix } from "babylonjs/Maths/math";
  54677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54678. import { Mesh } from "babylonjs/Meshes/mesh";
  54679. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54680. import { Effect } from "babylonjs/Materials/effect";
  54681. import { Scene } from "babylonjs/scene";
  54682. import "babylonjs/Shaders/geometry.fragment";
  54683. import "babylonjs/Shaders/geometry.vertex";
  54684. /**
  54685. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54686. */
  54687. export class GeometryBufferRenderer {
  54688. /**
  54689. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54690. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54691. */
  54692. static readonly POSITION_TEXTURE_TYPE: number;
  54693. /**
  54694. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54695. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54696. */
  54697. static readonly VELOCITY_TEXTURE_TYPE: number;
  54698. /**
  54699. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54700. * in order to compute objects velocities when enableVelocity is set to "true"
  54701. * @hidden
  54702. */
  54703. _previousTransformationMatrices: {
  54704. [index: number]: Matrix;
  54705. };
  54706. private _scene;
  54707. private _multiRenderTarget;
  54708. private _ratio;
  54709. private _enablePosition;
  54710. private _enableVelocity;
  54711. private _positionIndex;
  54712. private _velocityIndex;
  54713. protected _effect: Effect;
  54714. protected _cachedDefines: string;
  54715. /**
  54716. * Set the render list (meshes to be rendered) used in the G buffer.
  54717. */
  54718. renderList: Mesh[];
  54719. /**
  54720. * Gets wether or not G buffer are supported by the running hardware.
  54721. * This requires draw buffer supports
  54722. */
  54723. readonly isSupported: boolean;
  54724. /**
  54725. * Returns the index of the given texture type in the G-Buffer textures array
  54726. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54727. * @returns the index of the given texture type in the G-Buffer textures array
  54728. */
  54729. getTextureIndex(textureType: number): number;
  54730. /**
  54731. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54732. */
  54733. /**
  54734. * Sets whether or not objects positions are enabled for the G buffer.
  54735. */
  54736. enablePosition: boolean;
  54737. /**
  54738. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54739. */
  54740. /**
  54741. * Sets wether or not objects velocities are enabled for the G buffer.
  54742. */
  54743. enableVelocity: boolean;
  54744. /**
  54745. * Gets the scene associated with the buffer.
  54746. */
  54747. readonly scene: Scene;
  54748. /**
  54749. * Gets the ratio used by the buffer during its creation.
  54750. * How big is the buffer related to the main canvas.
  54751. */
  54752. readonly ratio: number;
  54753. /** @hidden */
  54754. static _SceneComponentInitialization: (scene: Scene) => void;
  54755. /**
  54756. * Creates a new G Buffer for the scene
  54757. * @param scene The scene the buffer belongs to
  54758. * @param ratio How big is the buffer related to the main canvas.
  54759. */
  54760. constructor(scene: Scene, ratio?: number);
  54761. /**
  54762. * Checks wether everything is ready to render a submesh to the G buffer.
  54763. * @param subMesh the submesh to check readiness for
  54764. * @param useInstances is the mesh drawn using instance or not
  54765. * @returns true if ready otherwise false
  54766. */
  54767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54768. /**
  54769. * Gets the current underlying G Buffer.
  54770. * @returns the buffer
  54771. */
  54772. getGBuffer(): MultiRenderTarget;
  54773. /**
  54774. * Gets the number of samples used to render the buffer (anti aliasing).
  54775. */
  54776. /**
  54777. * Sets the number of samples used to render the buffer (anti aliasing).
  54778. */
  54779. samples: number;
  54780. /**
  54781. * Disposes the renderer and frees up associated resources.
  54782. */
  54783. dispose(): void;
  54784. protected _createRenderTargets(): void;
  54785. }
  54786. }
  54787. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54788. import { Nullable } from "babylonjs/types";
  54789. import { Scene } from "babylonjs/scene";
  54790. import { ISceneComponent } from "babylonjs/sceneComponent";
  54791. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54792. module "babylonjs/scene" {
  54793. interface Scene {
  54794. /** @hidden (Backing field) */
  54795. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54796. /**
  54797. * Gets or Sets the current geometry buffer associated to the scene.
  54798. */
  54799. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54800. /**
  54801. * Enables a GeometryBufferRender and associates it with the scene
  54802. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54803. * @returns the GeometryBufferRenderer
  54804. */
  54805. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54806. /**
  54807. * Disables the GeometryBufferRender associated with the scene
  54808. */
  54809. disableGeometryBufferRenderer(): void;
  54810. }
  54811. }
  54812. /**
  54813. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54814. * in several rendering techniques.
  54815. */
  54816. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54817. /**
  54818. * The component name helpful to identify the component in the list of scene components.
  54819. */
  54820. readonly name: string;
  54821. /**
  54822. * The scene the component belongs to.
  54823. */
  54824. scene: Scene;
  54825. /**
  54826. * Creates a new instance of the component for the given scene
  54827. * @param scene Defines the scene to register the component in
  54828. */
  54829. constructor(scene: Scene);
  54830. /**
  54831. * Registers the component in a given scene
  54832. */
  54833. register(): void;
  54834. /**
  54835. * Rebuilds the elements related to this component in case of
  54836. * context lost for instance.
  54837. */
  54838. rebuild(): void;
  54839. /**
  54840. * Disposes the component and the associated ressources
  54841. */
  54842. dispose(): void;
  54843. private _gatherRenderTargets;
  54844. }
  54845. }
  54846. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54847. /** @hidden */
  54848. export var motionBlurPixelShader: {
  54849. name: string;
  54850. shader: string;
  54851. };
  54852. }
  54853. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54854. import { Nullable } from "babylonjs/types";
  54855. import { Camera } from "babylonjs/Cameras/camera";
  54856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54857. import { Scene } from "babylonjs/scene";
  54858. import "babylonjs/Animations/animatable";
  54859. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54860. import "babylonjs/Shaders/motionBlur.fragment";
  54861. import { Engine } from "babylonjs/Engines/engine";
  54862. /**
  54863. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54864. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54865. * As an example, all you have to do is to create the post-process:
  54866. * var mb = new BABYLON.MotionBlurPostProcess(
  54867. * 'mb', // The name of the effect.
  54868. * scene, // The scene containing the objects to blur according to their velocity.
  54869. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54870. * camera // The camera to apply the render pass to.
  54871. * );
  54872. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54873. */
  54874. export class MotionBlurPostProcess extends PostProcess {
  54875. /**
  54876. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54877. */
  54878. motionStrength: number;
  54879. /**
  54880. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54881. */
  54882. /**
  54883. * Sets the number of iterations to be used for motion blur quality
  54884. */
  54885. motionBlurSamples: number;
  54886. private _motionBlurSamples;
  54887. private _geometryBufferRenderer;
  54888. /**
  54889. * Creates a new instance MotionBlurPostProcess
  54890. * @param name The name of the effect.
  54891. * @param scene The scene containing the objects to blur according to their velocity.
  54892. * @param options The required width/height ratio to downsize to before computing the render pass.
  54893. * @param camera The camera to apply the render pass to.
  54894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54895. * @param engine The engine which the post process will be applied. (default: current engine)
  54896. * @param reusable If the post process can be reused on the same frame. (default: false)
  54897. * @param textureType Type of textures used when performing the post process. (default: 0)
  54898. * @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)
  54899. */
  54900. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54901. /**
  54902. * Disposes the post process.
  54903. * @param camera The camera to dispose the post process on.
  54904. */
  54905. dispose(camera?: Camera): void;
  54906. }
  54907. }
  54908. declare module "babylonjs/Shaders/refraction.fragment" {
  54909. /** @hidden */
  54910. export var refractionPixelShader: {
  54911. name: string;
  54912. shader: string;
  54913. };
  54914. }
  54915. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54916. import { Color3 } from "babylonjs/Maths/math";
  54917. import { Camera } from "babylonjs/Cameras/camera";
  54918. import { Texture } from "babylonjs/Materials/Textures/texture";
  54919. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54920. import { Engine } from "babylonjs/Engines/engine";
  54921. import "babylonjs/Shaders/refraction.fragment";
  54922. /**
  54923. * Post process which applies a refractin texture
  54924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54925. */
  54926. export class RefractionPostProcess extends PostProcess {
  54927. /** the base color of the refraction (used to taint the rendering) */
  54928. color: Color3;
  54929. /** simulated refraction depth */
  54930. depth: number;
  54931. /** the coefficient of the base color (0 to remove base color tainting) */
  54932. colorLevel: number;
  54933. private _refTexture;
  54934. private _ownRefractionTexture;
  54935. /**
  54936. * Gets or sets the refraction texture
  54937. * Please note that you are responsible for disposing the texture if you set it manually
  54938. */
  54939. refractionTexture: Texture;
  54940. /**
  54941. * Initializes the RefractionPostProcess
  54942. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54943. * @param name The name of the effect.
  54944. * @param refractionTextureUrl Url of the refraction texture to use
  54945. * @param color the base color of the refraction (used to taint the rendering)
  54946. * @param depth simulated refraction depth
  54947. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54948. * @param camera The camera to apply the render pass to.
  54949. * @param options The required width/height ratio to downsize to before computing the render pass.
  54950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54951. * @param engine The engine which the post process will be applied. (default: current engine)
  54952. * @param reusable If the post process can be reused on the same frame. (default: false)
  54953. */
  54954. constructor(name: string, refractionTextureUrl: string,
  54955. /** the base color of the refraction (used to taint the rendering) */
  54956. color: Color3,
  54957. /** simulated refraction depth */
  54958. depth: number,
  54959. /** the coefficient of the base color (0 to remove base color tainting) */
  54960. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54961. /**
  54962. * Disposes of the post process
  54963. * @param camera Camera to dispose post process on
  54964. */
  54965. dispose(camera: Camera): void;
  54966. }
  54967. }
  54968. declare module "babylonjs/Shaders/sharpen.fragment" {
  54969. /** @hidden */
  54970. export var sharpenPixelShader: {
  54971. name: string;
  54972. shader: string;
  54973. };
  54974. }
  54975. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54976. import { Nullable } from "babylonjs/types";
  54977. import { Camera } from "babylonjs/Cameras/camera";
  54978. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54979. import "babylonjs/Shaders/sharpen.fragment";
  54980. import { Engine } from "babylonjs/Engines/engine";
  54981. /**
  54982. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54983. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54984. */
  54985. export class SharpenPostProcess extends PostProcess {
  54986. /**
  54987. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54988. */
  54989. colorAmount: number;
  54990. /**
  54991. * How much sharpness should be applied (default: 0.3)
  54992. */
  54993. edgeAmount: number;
  54994. /**
  54995. * Creates a new instance ConvolutionPostProcess
  54996. * @param name The name of the effect.
  54997. * @param options The required width/height ratio to downsize to before computing the render pass.
  54998. * @param camera The camera to apply the render pass to.
  54999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55000. * @param engine The engine which the post process will be applied. (default: current engine)
  55001. * @param reusable If the post process can be reused on the same frame. (default: false)
  55002. * @param textureType Type of textures used when performing the post process. (default: 0)
  55003. * @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)
  55004. */
  55005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55006. }
  55007. }
  55008. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55009. import { Nullable } from "babylonjs/types";
  55010. import { Camera } from "babylonjs/Cameras/camera";
  55011. import { Engine } from "babylonjs/Engines/engine";
  55012. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55013. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55014. /**
  55015. * PostProcessRenderPipeline
  55016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55017. */
  55018. export class PostProcessRenderPipeline {
  55019. private engine;
  55020. private _renderEffects;
  55021. private _renderEffectsForIsolatedPass;
  55022. /**
  55023. * List of inspectable custom properties (used by the Inspector)
  55024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55025. */
  55026. inspectableCustomProperties: IInspectable[];
  55027. /**
  55028. * @hidden
  55029. */
  55030. protected _cameras: Camera[];
  55031. /** @hidden */
  55032. _name: string;
  55033. /**
  55034. * Gets pipeline name
  55035. */
  55036. readonly name: string;
  55037. /**
  55038. * Initializes a PostProcessRenderPipeline
  55039. * @param engine engine to add the pipeline to
  55040. * @param name name of the pipeline
  55041. */
  55042. constructor(engine: Engine, name: string);
  55043. /**
  55044. * Gets the class name
  55045. * @returns "PostProcessRenderPipeline"
  55046. */
  55047. getClassName(): string;
  55048. /**
  55049. * If all the render effects in the pipeline are supported
  55050. */
  55051. readonly isSupported: boolean;
  55052. /**
  55053. * Adds an effect to the pipeline
  55054. * @param renderEffect the effect to add
  55055. */
  55056. addEffect(renderEffect: PostProcessRenderEffect): void;
  55057. /** @hidden */
  55058. _rebuild(): void;
  55059. /** @hidden */
  55060. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55061. /** @hidden */
  55062. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55063. /** @hidden */
  55064. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55065. /** @hidden */
  55066. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55067. /** @hidden */
  55068. _attachCameras(cameras: Camera, unique: boolean): void;
  55069. /** @hidden */
  55070. _attachCameras(cameras: Camera[], unique: boolean): void;
  55071. /** @hidden */
  55072. _detachCameras(cameras: Camera): void;
  55073. /** @hidden */
  55074. _detachCameras(cameras: Nullable<Camera[]>): void;
  55075. /** @hidden */
  55076. _update(): void;
  55077. /** @hidden */
  55078. _reset(): void;
  55079. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55080. /**
  55081. * Disposes of the pipeline
  55082. */
  55083. dispose(): void;
  55084. }
  55085. }
  55086. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55087. import { Camera } from "babylonjs/Cameras/camera";
  55088. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55089. /**
  55090. * PostProcessRenderPipelineManager class
  55091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55092. */
  55093. export class PostProcessRenderPipelineManager {
  55094. private _renderPipelines;
  55095. /**
  55096. * Initializes a PostProcessRenderPipelineManager
  55097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55098. */
  55099. constructor();
  55100. /**
  55101. * Gets the list of supported render pipelines
  55102. */
  55103. readonly supportedPipelines: PostProcessRenderPipeline[];
  55104. /**
  55105. * Adds a pipeline to the manager
  55106. * @param renderPipeline The pipeline to add
  55107. */
  55108. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55109. /**
  55110. * Attaches a camera to the pipeline
  55111. * @param renderPipelineName The name of the pipeline to attach to
  55112. * @param cameras the camera to attach
  55113. * @param unique if the camera can be attached multiple times to the pipeline
  55114. */
  55115. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55116. /**
  55117. * Detaches a camera from the pipeline
  55118. * @param renderPipelineName The name of the pipeline to detach from
  55119. * @param cameras the camera to detach
  55120. */
  55121. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55122. /**
  55123. * Enables an effect by name on a pipeline
  55124. * @param renderPipelineName the name of the pipeline to enable the effect in
  55125. * @param renderEffectName the name of the effect to enable
  55126. * @param cameras the cameras that the effect should be enabled on
  55127. */
  55128. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55129. /**
  55130. * Disables an effect by name on a pipeline
  55131. * @param renderPipelineName the name of the pipeline to disable the effect in
  55132. * @param renderEffectName the name of the effect to disable
  55133. * @param cameras the cameras that the effect should be disabled on
  55134. */
  55135. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55136. /**
  55137. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55138. */
  55139. update(): void;
  55140. /** @hidden */
  55141. _rebuild(): void;
  55142. /**
  55143. * Disposes of the manager and pipelines
  55144. */
  55145. dispose(): void;
  55146. }
  55147. }
  55148. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55149. import { ISceneComponent } from "babylonjs/sceneComponent";
  55150. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55151. import { Scene } from "babylonjs/scene";
  55152. module "babylonjs/scene" {
  55153. interface Scene {
  55154. /** @hidden (Backing field) */
  55155. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55156. /**
  55157. * Gets the postprocess render pipeline manager
  55158. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55159. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55160. */
  55161. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55162. }
  55163. }
  55164. /**
  55165. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55166. */
  55167. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55168. /**
  55169. * The component name helpfull to identify the component in the list of scene components.
  55170. */
  55171. readonly name: string;
  55172. /**
  55173. * The scene the component belongs to.
  55174. */
  55175. scene: Scene;
  55176. /**
  55177. * Creates a new instance of the component for the given scene
  55178. * @param scene Defines the scene to register the component in
  55179. */
  55180. constructor(scene: Scene);
  55181. /**
  55182. * Registers the component in a given scene
  55183. */
  55184. register(): void;
  55185. /**
  55186. * Rebuilds the elements related to this component in case of
  55187. * context lost for instance.
  55188. */
  55189. rebuild(): void;
  55190. /**
  55191. * Disposes the component and the associated ressources
  55192. */
  55193. dispose(): void;
  55194. private _gatherRenderTargets;
  55195. }
  55196. }
  55197. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55198. import { IAnimatable } from "babylonjs/Misc/tools";
  55199. import { Camera } from "babylonjs/Cameras/camera";
  55200. import { IDisposable } from "babylonjs/scene";
  55201. import { Scene } from "babylonjs/scene";
  55202. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55203. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55204. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55205. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55206. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55207. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55208. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55209. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55210. import { Animation } from "babylonjs/Animations/animation";
  55211. /**
  55212. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55213. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55214. */
  55215. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55216. private _scene;
  55217. private _camerasToBeAttached;
  55218. /**
  55219. * ID of the sharpen post process,
  55220. */
  55221. private readonly SharpenPostProcessId;
  55222. /**
  55223. * @ignore
  55224. * ID of the image processing post process;
  55225. */
  55226. readonly ImageProcessingPostProcessId: string;
  55227. /**
  55228. * @ignore
  55229. * ID of the Fast Approximate Anti-Aliasing post process;
  55230. */
  55231. readonly FxaaPostProcessId: string;
  55232. /**
  55233. * ID of the chromatic aberration post process,
  55234. */
  55235. private readonly ChromaticAberrationPostProcessId;
  55236. /**
  55237. * ID of the grain post process
  55238. */
  55239. private readonly GrainPostProcessId;
  55240. /**
  55241. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55242. */
  55243. sharpen: SharpenPostProcess;
  55244. private _sharpenEffect;
  55245. private bloom;
  55246. /**
  55247. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55248. */
  55249. depthOfField: DepthOfFieldEffect;
  55250. /**
  55251. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55252. */
  55253. fxaa: FxaaPostProcess;
  55254. /**
  55255. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55256. */
  55257. imageProcessing: ImageProcessingPostProcess;
  55258. /**
  55259. * Chromatic aberration post process which will shift rgb colors in the image
  55260. */
  55261. chromaticAberration: ChromaticAberrationPostProcess;
  55262. private _chromaticAberrationEffect;
  55263. /**
  55264. * Grain post process which add noise to the image
  55265. */
  55266. grain: GrainPostProcess;
  55267. private _grainEffect;
  55268. /**
  55269. * Glow post process which adds a glow to emissive areas of the image
  55270. */
  55271. private _glowLayer;
  55272. /**
  55273. * Animations which can be used to tweak settings over a period of time
  55274. */
  55275. animations: Animation[];
  55276. private _imageProcessingConfigurationObserver;
  55277. private _sharpenEnabled;
  55278. private _bloomEnabled;
  55279. private _depthOfFieldEnabled;
  55280. private _depthOfFieldBlurLevel;
  55281. private _fxaaEnabled;
  55282. private _imageProcessingEnabled;
  55283. private _defaultPipelineTextureType;
  55284. private _bloomScale;
  55285. private _chromaticAberrationEnabled;
  55286. private _grainEnabled;
  55287. private _buildAllowed;
  55288. /**
  55289. * Gets active scene
  55290. */
  55291. readonly scene: Scene;
  55292. /**
  55293. * Enable or disable the sharpen process from the pipeline
  55294. */
  55295. sharpenEnabled: boolean;
  55296. private _resizeObserver;
  55297. private _hardwareScaleLevel;
  55298. private _bloomKernel;
  55299. /**
  55300. * Specifies the size of the bloom blur kernel, relative to the final output size
  55301. */
  55302. bloomKernel: number;
  55303. /**
  55304. * Specifies the weight of the bloom in the final rendering
  55305. */
  55306. private _bloomWeight;
  55307. /**
  55308. * Specifies the luma threshold for the area that will be blurred by the bloom
  55309. */
  55310. private _bloomThreshold;
  55311. private _hdr;
  55312. /**
  55313. * The strength of the bloom.
  55314. */
  55315. bloomWeight: number;
  55316. /**
  55317. * The strength of the bloom.
  55318. */
  55319. bloomThreshold: number;
  55320. /**
  55321. * The scale of the bloom, lower value will provide better performance.
  55322. */
  55323. bloomScale: number;
  55324. /**
  55325. * Enable or disable the bloom from the pipeline
  55326. */
  55327. bloomEnabled: boolean;
  55328. private _rebuildBloom;
  55329. /**
  55330. * If the depth of field is enabled.
  55331. */
  55332. depthOfFieldEnabled: boolean;
  55333. /**
  55334. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55335. */
  55336. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55337. /**
  55338. * If the anti aliasing is enabled.
  55339. */
  55340. fxaaEnabled: boolean;
  55341. private _samples;
  55342. /**
  55343. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55344. */
  55345. samples: number;
  55346. /**
  55347. * If image processing is enabled.
  55348. */
  55349. imageProcessingEnabled: boolean;
  55350. /**
  55351. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55352. */
  55353. glowLayerEnabled: boolean;
  55354. /**
  55355. * Enable or disable the chromaticAberration process from the pipeline
  55356. */
  55357. chromaticAberrationEnabled: boolean;
  55358. /**
  55359. * Enable or disable the grain process from the pipeline
  55360. */
  55361. grainEnabled: boolean;
  55362. /**
  55363. * @constructor
  55364. * @param name - The rendering pipeline name (default: "")
  55365. * @param hdr - If high dynamic range textures should be used (default: true)
  55366. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55367. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55368. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55369. */
  55370. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55371. /**
  55372. * Get the class name
  55373. * @returns "DefaultRenderingPipeline"
  55374. */
  55375. getClassName(): string;
  55376. /**
  55377. * Force the compilation of the entire pipeline.
  55378. */
  55379. prepare(): void;
  55380. private _hasCleared;
  55381. private _prevPostProcess;
  55382. private _prevPrevPostProcess;
  55383. private _setAutoClearAndTextureSharing;
  55384. private _depthOfFieldSceneObserver;
  55385. private _buildPipeline;
  55386. private _disposePostProcesses;
  55387. /**
  55388. * Adds a camera to the pipeline
  55389. * @param camera the camera to be added
  55390. */
  55391. addCamera(camera: Camera): void;
  55392. /**
  55393. * Removes a camera from the pipeline
  55394. * @param camera the camera to remove
  55395. */
  55396. removeCamera(camera: Camera): void;
  55397. /**
  55398. * Dispose of the pipeline and stop all post processes
  55399. */
  55400. dispose(): void;
  55401. /**
  55402. * Serialize the rendering pipeline (Used when exporting)
  55403. * @returns the serialized object
  55404. */
  55405. serialize(): any;
  55406. /**
  55407. * Parse the serialized pipeline
  55408. * @param source Source pipeline.
  55409. * @param scene The scene to load the pipeline to.
  55410. * @param rootUrl The URL of the serialized pipeline.
  55411. * @returns An instantiated pipeline from the serialized object.
  55412. */
  55413. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55414. }
  55415. }
  55416. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55417. /** @hidden */
  55418. export var lensHighlightsPixelShader: {
  55419. name: string;
  55420. shader: string;
  55421. };
  55422. }
  55423. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55424. /** @hidden */
  55425. export var depthOfFieldPixelShader: {
  55426. name: string;
  55427. shader: string;
  55428. };
  55429. }
  55430. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55431. import { Camera } from "babylonjs/Cameras/camera";
  55432. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55433. import { Scene } from "babylonjs/scene";
  55434. import "babylonjs/Shaders/chromaticAberration.fragment";
  55435. import "babylonjs/Shaders/lensHighlights.fragment";
  55436. import "babylonjs/Shaders/depthOfField.fragment";
  55437. /**
  55438. * BABYLON.JS Chromatic Aberration GLSL Shader
  55439. * Author: Olivier Guyot
  55440. * Separates very slightly R, G and B colors on the edges of the screen
  55441. * Inspired by Francois Tarlier & Martins Upitis
  55442. */
  55443. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55444. /**
  55445. * @ignore
  55446. * The chromatic aberration PostProcess id in the pipeline
  55447. */
  55448. LensChromaticAberrationEffect: string;
  55449. /**
  55450. * @ignore
  55451. * The highlights enhancing PostProcess id in the pipeline
  55452. */
  55453. HighlightsEnhancingEffect: string;
  55454. /**
  55455. * @ignore
  55456. * The depth-of-field PostProcess id in the pipeline
  55457. */
  55458. LensDepthOfFieldEffect: string;
  55459. private _scene;
  55460. private _depthTexture;
  55461. private _grainTexture;
  55462. private _chromaticAberrationPostProcess;
  55463. private _highlightsPostProcess;
  55464. private _depthOfFieldPostProcess;
  55465. private _edgeBlur;
  55466. private _grainAmount;
  55467. private _chromaticAberration;
  55468. private _distortion;
  55469. private _highlightsGain;
  55470. private _highlightsThreshold;
  55471. private _dofDistance;
  55472. private _dofAperture;
  55473. private _dofDarken;
  55474. private _dofPentagon;
  55475. private _blurNoise;
  55476. /**
  55477. * @constructor
  55478. *
  55479. * Effect parameters are as follow:
  55480. * {
  55481. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55482. * edge_blur: number; // from 0 to x (1 for realism)
  55483. * distortion: number; // from 0 to x (1 for realism)
  55484. * grain_amount: number; // from 0 to 1
  55485. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55486. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55487. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55488. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55489. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55490. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55491. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55492. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55493. * }
  55494. * Note: if an effect parameter is unset, effect is disabled
  55495. *
  55496. * @param name The rendering pipeline name
  55497. * @param parameters - An object containing all parameters (see above)
  55498. * @param scene The scene linked to this pipeline
  55499. * @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)
  55500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55501. */
  55502. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55503. /**
  55504. * Get the class name
  55505. * @returns "LensRenderingPipeline"
  55506. */
  55507. getClassName(): string;
  55508. /**
  55509. * Gets associated scene
  55510. */
  55511. readonly scene: Scene;
  55512. /**
  55513. * Gets or sets the edge blur
  55514. */
  55515. edgeBlur: number;
  55516. /**
  55517. * Gets or sets the grain amount
  55518. */
  55519. grainAmount: number;
  55520. /**
  55521. * Gets or sets the chromatic aberration amount
  55522. */
  55523. chromaticAberration: number;
  55524. /**
  55525. * Gets or sets the depth of field aperture
  55526. */
  55527. dofAperture: number;
  55528. /**
  55529. * Gets or sets the edge distortion
  55530. */
  55531. edgeDistortion: number;
  55532. /**
  55533. * Gets or sets the depth of field distortion
  55534. */
  55535. dofDistortion: number;
  55536. /**
  55537. * Gets or sets the darken out of focus amount
  55538. */
  55539. darkenOutOfFocus: number;
  55540. /**
  55541. * Gets or sets a boolean indicating if blur noise is enabled
  55542. */
  55543. blurNoise: boolean;
  55544. /**
  55545. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55546. */
  55547. pentagonBokeh: boolean;
  55548. /**
  55549. * Gets or sets the highlight grain amount
  55550. */
  55551. highlightsGain: number;
  55552. /**
  55553. * Gets or sets the highlight threshold
  55554. */
  55555. highlightsThreshold: number;
  55556. /**
  55557. * Sets the amount of blur at the edges
  55558. * @param amount blur amount
  55559. */
  55560. setEdgeBlur(amount: number): void;
  55561. /**
  55562. * Sets edge blur to 0
  55563. */
  55564. disableEdgeBlur(): void;
  55565. /**
  55566. * Sets the amout of grain
  55567. * @param amount Amount of grain
  55568. */
  55569. setGrainAmount(amount: number): void;
  55570. /**
  55571. * Set grain amount to 0
  55572. */
  55573. disableGrain(): void;
  55574. /**
  55575. * Sets the chromatic aberration amount
  55576. * @param amount amount of chromatic aberration
  55577. */
  55578. setChromaticAberration(amount: number): void;
  55579. /**
  55580. * Sets chromatic aberration amount to 0
  55581. */
  55582. disableChromaticAberration(): void;
  55583. /**
  55584. * Sets the EdgeDistortion amount
  55585. * @param amount amount of EdgeDistortion
  55586. */
  55587. setEdgeDistortion(amount: number): void;
  55588. /**
  55589. * Sets edge distortion to 0
  55590. */
  55591. disableEdgeDistortion(): void;
  55592. /**
  55593. * Sets the FocusDistance amount
  55594. * @param amount amount of FocusDistance
  55595. */
  55596. setFocusDistance(amount: number): void;
  55597. /**
  55598. * Disables depth of field
  55599. */
  55600. disableDepthOfField(): void;
  55601. /**
  55602. * Sets the Aperture amount
  55603. * @param amount amount of Aperture
  55604. */
  55605. setAperture(amount: number): void;
  55606. /**
  55607. * Sets the DarkenOutOfFocus amount
  55608. * @param amount amount of DarkenOutOfFocus
  55609. */
  55610. setDarkenOutOfFocus(amount: number): void;
  55611. private _pentagonBokehIsEnabled;
  55612. /**
  55613. * Creates a pentagon bokeh effect
  55614. */
  55615. enablePentagonBokeh(): void;
  55616. /**
  55617. * Disables the pentagon bokeh effect
  55618. */
  55619. disablePentagonBokeh(): void;
  55620. /**
  55621. * Enables noise blur
  55622. */
  55623. enableNoiseBlur(): void;
  55624. /**
  55625. * Disables noise blur
  55626. */
  55627. disableNoiseBlur(): void;
  55628. /**
  55629. * Sets the HighlightsGain amount
  55630. * @param amount amount of HighlightsGain
  55631. */
  55632. setHighlightsGain(amount: number): void;
  55633. /**
  55634. * Sets the HighlightsThreshold amount
  55635. * @param amount amount of HighlightsThreshold
  55636. */
  55637. setHighlightsThreshold(amount: number): void;
  55638. /**
  55639. * Disables highlights
  55640. */
  55641. disableHighlights(): void;
  55642. /**
  55643. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55644. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55645. */
  55646. dispose(disableDepthRender?: boolean): void;
  55647. private _createChromaticAberrationPostProcess;
  55648. private _createHighlightsPostProcess;
  55649. private _createDepthOfFieldPostProcess;
  55650. private _createGrainTexture;
  55651. }
  55652. }
  55653. declare module "babylonjs/Shaders/ssao2.fragment" {
  55654. /** @hidden */
  55655. export var ssao2PixelShader: {
  55656. name: string;
  55657. shader: string;
  55658. };
  55659. }
  55660. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55661. /** @hidden */
  55662. export var ssaoCombinePixelShader: {
  55663. name: string;
  55664. shader: string;
  55665. };
  55666. }
  55667. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55668. import { Camera } from "babylonjs/Cameras/camera";
  55669. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55670. import { Scene } from "babylonjs/scene";
  55671. import "babylonjs/Shaders/ssao2.fragment";
  55672. import "babylonjs/Shaders/ssaoCombine.fragment";
  55673. /**
  55674. * Render pipeline to produce ssao effect
  55675. */
  55676. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55677. /**
  55678. * @ignore
  55679. * The PassPostProcess id in the pipeline that contains the original scene color
  55680. */
  55681. SSAOOriginalSceneColorEffect: string;
  55682. /**
  55683. * @ignore
  55684. * The SSAO PostProcess id in the pipeline
  55685. */
  55686. SSAORenderEffect: string;
  55687. /**
  55688. * @ignore
  55689. * The horizontal blur PostProcess id in the pipeline
  55690. */
  55691. SSAOBlurHRenderEffect: string;
  55692. /**
  55693. * @ignore
  55694. * The vertical blur PostProcess id in the pipeline
  55695. */
  55696. SSAOBlurVRenderEffect: string;
  55697. /**
  55698. * @ignore
  55699. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55700. */
  55701. SSAOCombineRenderEffect: string;
  55702. /**
  55703. * The output strength of the SSAO post-process. Default value is 1.0.
  55704. */
  55705. totalStrength: number;
  55706. /**
  55707. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55708. */
  55709. maxZ: number;
  55710. /**
  55711. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55712. */
  55713. minZAspect: number;
  55714. private _samples;
  55715. /**
  55716. * Number of samples used for the SSAO calculations. Default value is 8
  55717. */
  55718. samples: number;
  55719. private _textureSamples;
  55720. /**
  55721. * Number of samples to use for antialiasing
  55722. */
  55723. textureSamples: number;
  55724. /**
  55725. * Ratio object used for SSAO ratio and blur ratio
  55726. */
  55727. private _ratio;
  55728. /**
  55729. * Dynamically generated sphere sampler.
  55730. */
  55731. private _sampleSphere;
  55732. /**
  55733. * Blur filter offsets
  55734. */
  55735. private _samplerOffsets;
  55736. private _expensiveBlur;
  55737. /**
  55738. * If bilateral blur should be used
  55739. */
  55740. expensiveBlur: boolean;
  55741. /**
  55742. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55743. */
  55744. radius: number;
  55745. /**
  55746. * The base color of the SSAO post-process
  55747. * The final result is "base + ssao" between [0, 1]
  55748. */
  55749. base: number;
  55750. /**
  55751. * Support test.
  55752. */
  55753. static readonly IsSupported: boolean;
  55754. private _scene;
  55755. private _depthTexture;
  55756. private _normalTexture;
  55757. private _randomTexture;
  55758. private _originalColorPostProcess;
  55759. private _ssaoPostProcess;
  55760. private _blurHPostProcess;
  55761. private _blurVPostProcess;
  55762. private _ssaoCombinePostProcess;
  55763. private _firstUpdate;
  55764. /**
  55765. * Gets active scene
  55766. */
  55767. readonly scene: Scene;
  55768. /**
  55769. * @constructor
  55770. * @param name The rendering pipeline name
  55771. * @param scene The scene linked to this pipeline
  55772. * @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 }
  55773. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55774. */
  55775. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55776. /**
  55777. * Get the class name
  55778. * @returns "SSAO2RenderingPipeline"
  55779. */
  55780. getClassName(): string;
  55781. /**
  55782. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55783. */
  55784. dispose(disableGeometryBufferRenderer?: boolean): void;
  55785. private _createBlurPostProcess;
  55786. /** @hidden */
  55787. _rebuild(): void;
  55788. private _bits;
  55789. private _radicalInverse_VdC;
  55790. private _hammersley;
  55791. private _hemisphereSample_uniform;
  55792. private _generateHemisphere;
  55793. private _createSSAOPostProcess;
  55794. private _createSSAOCombinePostProcess;
  55795. private _createRandomTexture;
  55796. /**
  55797. * Serialize the rendering pipeline (Used when exporting)
  55798. * @returns the serialized object
  55799. */
  55800. serialize(): any;
  55801. /**
  55802. * Parse the serialized pipeline
  55803. * @param source Source pipeline.
  55804. * @param scene The scene to load the pipeline to.
  55805. * @param rootUrl The URL of the serialized pipeline.
  55806. * @returns An instantiated pipeline from the serialized object.
  55807. */
  55808. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55809. }
  55810. }
  55811. declare module "babylonjs/Shaders/ssao.fragment" {
  55812. /** @hidden */
  55813. export var ssaoPixelShader: {
  55814. name: string;
  55815. shader: string;
  55816. };
  55817. }
  55818. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55819. import { Camera } from "babylonjs/Cameras/camera";
  55820. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55821. import { Scene } from "babylonjs/scene";
  55822. import "babylonjs/Shaders/ssao.fragment";
  55823. import "babylonjs/Shaders/ssaoCombine.fragment";
  55824. /**
  55825. * Render pipeline to produce ssao effect
  55826. */
  55827. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55828. /**
  55829. * @ignore
  55830. * The PassPostProcess id in the pipeline that contains the original scene color
  55831. */
  55832. SSAOOriginalSceneColorEffect: string;
  55833. /**
  55834. * @ignore
  55835. * The SSAO PostProcess id in the pipeline
  55836. */
  55837. SSAORenderEffect: string;
  55838. /**
  55839. * @ignore
  55840. * The horizontal blur PostProcess id in the pipeline
  55841. */
  55842. SSAOBlurHRenderEffect: string;
  55843. /**
  55844. * @ignore
  55845. * The vertical blur PostProcess id in the pipeline
  55846. */
  55847. SSAOBlurVRenderEffect: string;
  55848. /**
  55849. * @ignore
  55850. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55851. */
  55852. SSAOCombineRenderEffect: string;
  55853. /**
  55854. * The output strength of the SSAO post-process. Default value is 1.0.
  55855. */
  55856. totalStrength: number;
  55857. /**
  55858. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55859. */
  55860. radius: number;
  55861. /**
  55862. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55863. * Must not be equal to fallOff and superior to fallOff.
  55864. * Default value is 0.0075
  55865. */
  55866. area: number;
  55867. /**
  55868. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55869. * Must not be equal to area and inferior to area.
  55870. * Default value is 0.000001
  55871. */
  55872. fallOff: number;
  55873. /**
  55874. * The base color of the SSAO post-process
  55875. * The final result is "base + ssao" between [0, 1]
  55876. */
  55877. base: number;
  55878. private _scene;
  55879. private _depthTexture;
  55880. private _randomTexture;
  55881. private _originalColorPostProcess;
  55882. private _ssaoPostProcess;
  55883. private _blurHPostProcess;
  55884. private _blurVPostProcess;
  55885. private _ssaoCombinePostProcess;
  55886. private _firstUpdate;
  55887. /**
  55888. * Gets active scene
  55889. */
  55890. readonly scene: Scene;
  55891. /**
  55892. * @constructor
  55893. * @param name - The rendering pipeline name
  55894. * @param scene - The scene linked to this pipeline
  55895. * @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 }
  55896. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55897. */
  55898. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55899. /**
  55900. * Get the class name
  55901. * @returns "SSAORenderingPipeline"
  55902. */
  55903. getClassName(): string;
  55904. /**
  55905. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55906. */
  55907. dispose(disableDepthRender?: boolean): void;
  55908. private _createBlurPostProcess;
  55909. /** @hidden */
  55910. _rebuild(): void;
  55911. private _createSSAOPostProcess;
  55912. private _createSSAOCombinePostProcess;
  55913. private _createRandomTexture;
  55914. }
  55915. }
  55916. declare module "babylonjs/Shaders/standard.fragment" {
  55917. /** @hidden */
  55918. export var standardPixelShader: {
  55919. name: string;
  55920. shader: string;
  55921. };
  55922. }
  55923. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55924. import { Nullable } from "babylonjs/types";
  55925. import { IAnimatable } from "babylonjs/Misc/tools";
  55926. import { Camera } from "babylonjs/Cameras/camera";
  55927. import { Texture } from "babylonjs/Materials/Textures/texture";
  55928. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55929. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55930. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55931. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55932. import { IDisposable } from "babylonjs/scene";
  55933. import { SpotLight } from "babylonjs/Lights/spotLight";
  55934. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55935. import { Scene } from "babylonjs/scene";
  55936. import { Animation } from "babylonjs/Animations/animation";
  55937. import "babylonjs/Shaders/standard.fragment";
  55938. /**
  55939. * Standard rendering pipeline
  55940. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55941. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55942. */
  55943. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55944. /**
  55945. * Public members
  55946. */
  55947. /**
  55948. * Post-process which contains the original scene color before the pipeline applies all the effects
  55949. */
  55950. originalPostProcess: Nullable<PostProcess>;
  55951. /**
  55952. * Post-process used to down scale an image x4
  55953. */
  55954. downSampleX4PostProcess: Nullable<PostProcess>;
  55955. /**
  55956. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55957. */
  55958. brightPassPostProcess: Nullable<PostProcess>;
  55959. /**
  55960. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55961. */
  55962. blurHPostProcesses: PostProcess[];
  55963. /**
  55964. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55965. */
  55966. blurVPostProcesses: PostProcess[];
  55967. /**
  55968. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55969. */
  55970. textureAdderPostProcess: Nullable<PostProcess>;
  55971. /**
  55972. * Post-process used to create volumetric lighting effect
  55973. */
  55974. volumetricLightPostProcess: Nullable<PostProcess>;
  55975. /**
  55976. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55977. */
  55978. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55979. /**
  55980. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55981. */
  55982. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55983. /**
  55984. * Post-process used to merge the volumetric light effect and the real scene color
  55985. */
  55986. volumetricLightMergePostProces: Nullable<PostProcess>;
  55987. /**
  55988. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55989. */
  55990. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55991. /**
  55992. * Base post-process used to calculate the average luminance of the final image for HDR
  55993. */
  55994. luminancePostProcess: Nullable<PostProcess>;
  55995. /**
  55996. * Post-processes used to create down sample post-processes in order to get
  55997. * the average luminance of the final image for HDR
  55998. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55999. */
  56000. luminanceDownSamplePostProcesses: PostProcess[];
  56001. /**
  56002. * Post-process used to create a HDR effect (light adaptation)
  56003. */
  56004. hdrPostProcess: Nullable<PostProcess>;
  56005. /**
  56006. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56007. */
  56008. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56009. /**
  56010. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56011. */
  56012. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56013. /**
  56014. * Post-process used to merge the final HDR post-process and the real scene color
  56015. */
  56016. hdrFinalPostProcess: Nullable<PostProcess>;
  56017. /**
  56018. * Post-process used to create a lens flare effect
  56019. */
  56020. lensFlarePostProcess: Nullable<PostProcess>;
  56021. /**
  56022. * Post-process that merges the result of the lens flare post-process and the real scene color
  56023. */
  56024. lensFlareComposePostProcess: Nullable<PostProcess>;
  56025. /**
  56026. * Post-process used to create a motion blur effect
  56027. */
  56028. motionBlurPostProcess: Nullable<PostProcess>;
  56029. /**
  56030. * Post-process used to create a depth of field effect
  56031. */
  56032. depthOfFieldPostProcess: Nullable<PostProcess>;
  56033. /**
  56034. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56035. */
  56036. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56037. /**
  56038. * Represents the brightness threshold in order to configure the illuminated surfaces
  56039. */
  56040. brightThreshold: number;
  56041. /**
  56042. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56043. */
  56044. blurWidth: number;
  56045. /**
  56046. * Sets if the blur for highlighted surfaces must be only horizontal
  56047. */
  56048. horizontalBlur: boolean;
  56049. /**
  56050. * Gets the overall exposure used by the pipeline
  56051. */
  56052. /**
  56053. * Sets the overall exposure used by the pipeline
  56054. */
  56055. exposure: number;
  56056. /**
  56057. * Texture used typically to simulate "dirty" on camera lens
  56058. */
  56059. lensTexture: Nullable<Texture>;
  56060. /**
  56061. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56062. */
  56063. volumetricLightCoefficient: number;
  56064. /**
  56065. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56066. */
  56067. volumetricLightPower: number;
  56068. /**
  56069. * Used the set the blur intensity to smooth the volumetric lights
  56070. */
  56071. volumetricLightBlurScale: number;
  56072. /**
  56073. * Light (spot or directional) used to generate the volumetric lights rays
  56074. * The source light must have a shadow generate so the pipeline can get its
  56075. * depth map
  56076. */
  56077. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56078. /**
  56079. * For eye adaptation, represents the minimum luminance the eye can see
  56080. */
  56081. hdrMinimumLuminance: number;
  56082. /**
  56083. * For eye adaptation, represents the decrease luminance speed
  56084. */
  56085. hdrDecreaseRate: number;
  56086. /**
  56087. * For eye adaptation, represents the increase luminance speed
  56088. */
  56089. hdrIncreaseRate: number;
  56090. /**
  56091. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56092. */
  56093. /**
  56094. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56095. */
  56096. hdrAutoExposure: boolean;
  56097. /**
  56098. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56099. */
  56100. lensColorTexture: Nullable<Texture>;
  56101. /**
  56102. * The overall strengh for the lens flare effect
  56103. */
  56104. lensFlareStrength: number;
  56105. /**
  56106. * Dispersion coefficient for lens flare ghosts
  56107. */
  56108. lensFlareGhostDispersal: number;
  56109. /**
  56110. * Main lens flare halo width
  56111. */
  56112. lensFlareHaloWidth: number;
  56113. /**
  56114. * Based on the lens distortion effect, defines how much the lens flare result
  56115. * is distorted
  56116. */
  56117. lensFlareDistortionStrength: number;
  56118. /**
  56119. * Lens star texture must be used to simulate rays on the flares and is available
  56120. * in the documentation
  56121. */
  56122. lensStarTexture: Nullable<Texture>;
  56123. /**
  56124. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56125. * flare effect by taking account of the dirt texture
  56126. */
  56127. lensFlareDirtTexture: Nullable<Texture>;
  56128. /**
  56129. * Represents the focal length for the depth of field effect
  56130. */
  56131. depthOfFieldDistance: number;
  56132. /**
  56133. * Represents the blur intensity for the blurred part of the depth of field effect
  56134. */
  56135. depthOfFieldBlurWidth: number;
  56136. /**
  56137. * For motion blur, defines how much the image is blurred by the movement
  56138. */
  56139. motionStrength: number;
  56140. /**
  56141. * List of animations for the pipeline (IAnimatable implementation)
  56142. */
  56143. animations: Animation[];
  56144. /**
  56145. * Private members
  56146. */
  56147. private _scene;
  56148. private _currentDepthOfFieldSource;
  56149. private _basePostProcess;
  56150. private _fixedExposure;
  56151. private _currentExposure;
  56152. private _hdrAutoExposure;
  56153. private _hdrCurrentLuminance;
  56154. private _floatTextureType;
  56155. private _ratio;
  56156. private _bloomEnabled;
  56157. private _depthOfFieldEnabled;
  56158. private _vlsEnabled;
  56159. private _lensFlareEnabled;
  56160. private _hdrEnabled;
  56161. private _motionBlurEnabled;
  56162. private _fxaaEnabled;
  56163. private _motionBlurSamples;
  56164. private _volumetricLightStepsCount;
  56165. private _samples;
  56166. /**
  56167. * @ignore
  56168. * Specifies if the bloom pipeline is enabled
  56169. */
  56170. BloomEnabled: boolean;
  56171. /**
  56172. * @ignore
  56173. * Specifies if the depth of field pipeline is enabed
  56174. */
  56175. DepthOfFieldEnabled: boolean;
  56176. /**
  56177. * @ignore
  56178. * Specifies if the lens flare pipeline is enabed
  56179. */
  56180. LensFlareEnabled: boolean;
  56181. /**
  56182. * @ignore
  56183. * Specifies if the HDR pipeline is enabled
  56184. */
  56185. HDREnabled: boolean;
  56186. /**
  56187. * @ignore
  56188. * Specifies if the volumetric lights scattering effect is enabled
  56189. */
  56190. VLSEnabled: boolean;
  56191. /**
  56192. * @ignore
  56193. * Specifies if the motion blur effect is enabled
  56194. */
  56195. MotionBlurEnabled: boolean;
  56196. /**
  56197. * Specifies if anti-aliasing is enabled
  56198. */
  56199. fxaaEnabled: boolean;
  56200. /**
  56201. * Specifies the number of steps used to calculate the volumetric lights
  56202. * Typically in interval [50, 200]
  56203. */
  56204. volumetricLightStepsCount: number;
  56205. /**
  56206. * Specifies the number of samples used for the motion blur effect
  56207. * Typically in interval [16, 64]
  56208. */
  56209. motionBlurSamples: number;
  56210. /**
  56211. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56212. */
  56213. samples: number;
  56214. /**
  56215. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56216. * @constructor
  56217. * @param name The rendering pipeline name
  56218. * @param scene The scene linked to this pipeline
  56219. * @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)
  56220. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56221. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56222. */
  56223. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56224. private _buildPipeline;
  56225. private _createDownSampleX4PostProcess;
  56226. private _createBrightPassPostProcess;
  56227. private _createBlurPostProcesses;
  56228. private _createTextureAdderPostProcess;
  56229. private _createVolumetricLightPostProcess;
  56230. private _createLuminancePostProcesses;
  56231. private _createHdrPostProcess;
  56232. private _createLensFlarePostProcess;
  56233. private _createDepthOfFieldPostProcess;
  56234. private _createMotionBlurPostProcess;
  56235. private _getDepthTexture;
  56236. private _disposePostProcesses;
  56237. /**
  56238. * Dispose of the pipeline and stop all post processes
  56239. */
  56240. dispose(): void;
  56241. /**
  56242. * Serialize the rendering pipeline (Used when exporting)
  56243. * @returns the serialized object
  56244. */
  56245. serialize(): any;
  56246. /**
  56247. * Parse the serialized pipeline
  56248. * @param source Source pipeline.
  56249. * @param scene The scene to load the pipeline to.
  56250. * @param rootUrl The URL of the serialized pipeline.
  56251. * @returns An instantiated pipeline from the serialized object.
  56252. */
  56253. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56254. /**
  56255. * Luminance steps
  56256. */
  56257. static LuminanceSteps: number;
  56258. }
  56259. }
  56260. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56261. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56262. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56263. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56264. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56265. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56266. }
  56267. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56268. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56269. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56270. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56271. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56272. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56273. }
  56274. declare module "babylonjs/Shaders/tonemap.fragment" {
  56275. /** @hidden */
  56276. export var tonemapPixelShader: {
  56277. name: string;
  56278. shader: string;
  56279. };
  56280. }
  56281. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56282. import { Camera } from "babylonjs/Cameras/camera";
  56283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56284. import "babylonjs/Shaders/tonemap.fragment";
  56285. import { Engine } from "babylonjs/Engines/engine";
  56286. /** Defines operator used for tonemapping */
  56287. export enum TonemappingOperator {
  56288. /** Hable */
  56289. Hable = 0,
  56290. /** Reinhard */
  56291. Reinhard = 1,
  56292. /** HejiDawson */
  56293. HejiDawson = 2,
  56294. /** Photographic */
  56295. Photographic = 3
  56296. }
  56297. /**
  56298. * Defines a post process to apply tone mapping
  56299. */
  56300. export class TonemapPostProcess extends PostProcess {
  56301. private _operator;
  56302. /** Defines the required exposure adjustement */
  56303. exposureAdjustment: number;
  56304. /**
  56305. * Creates a new TonemapPostProcess
  56306. * @param name defines the name of the postprocess
  56307. * @param _operator defines the operator to use
  56308. * @param exposureAdjustment defines the required exposure adjustement
  56309. * @param camera defines the camera to use (can be null)
  56310. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56311. * @param engine defines the hosting engine (can be ignore if camera is set)
  56312. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56313. */
  56314. constructor(name: string, _operator: TonemappingOperator,
  56315. /** Defines the required exposure adjustement */
  56316. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56317. }
  56318. }
  56319. declare module "babylonjs/Shaders/depth.vertex" {
  56320. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56321. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56322. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56323. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56324. /** @hidden */
  56325. export var depthVertexShader: {
  56326. name: string;
  56327. shader: string;
  56328. };
  56329. }
  56330. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56331. /** @hidden */
  56332. export var volumetricLightScatteringPixelShader: {
  56333. name: string;
  56334. shader: string;
  56335. };
  56336. }
  56337. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56338. /** @hidden */
  56339. export var volumetricLightScatteringPassPixelShader: {
  56340. name: string;
  56341. shader: string;
  56342. };
  56343. }
  56344. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56345. import { Vector3 } from "babylonjs/Maths/math";
  56346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56347. import { Mesh } from "babylonjs/Meshes/mesh";
  56348. import { Camera } from "babylonjs/Cameras/camera";
  56349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56351. import { Scene } from "babylonjs/scene";
  56352. import "babylonjs/Meshes/Builders/planeBuilder";
  56353. import "babylonjs/Shaders/depth.vertex";
  56354. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56355. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56356. import { Engine } from "babylonjs/Engines/engine";
  56357. /**
  56358. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56359. */
  56360. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56361. private _volumetricLightScatteringPass;
  56362. private _volumetricLightScatteringRTT;
  56363. private _viewPort;
  56364. private _screenCoordinates;
  56365. private _cachedDefines;
  56366. /**
  56367. * If not undefined, the mesh position is computed from the attached node position
  56368. */
  56369. attachedNode: {
  56370. position: Vector3;
  56371. };
  56372. /**
  56373. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56374. */
  56375. customMeshPosition: Vector3;
  56376. /**
  56377. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56378. */
  56379. useCustomMeshPosition: boolean;
  56380. /**
  56381. * If the post-process should inverse the light scattering direction
  56382. */
  56383. invert: boolean;
  56384. /**
  56385. * The internal mesh used by the post-process
  56386. */
  56387. mesh: Mesh;
  56388. /**
  56389. * @hidden
  56390. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56391. */
  56392. useDiffuseColor: boolean;
  56393. /**
  56394. * Array containing the excluded meshes not rendered in the internal pass
  56395. */
  56396. excludedMeshes: AbstractMesh[];
  56397. /**
  56398. * Controls the overall intensity of the post-process
  56399. */
  56400. exposure: number;
  56401. /**
  56402. * Dissipates each sample's contribution in range [0, 1]
  56403. */
  56404. decay: number;
  56405. /**
  56406. * Controls the overall intensity of each sample
  56407. */
  56408. weight: number;
  56409. /**
  56410. * Controls the density of each sample
  56411. */
  56412. density: number;
  56413. /**
  56414. * @constructor
  56415. * @param name The post-process name
  56416. * @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)
  56417. * @param camera The camera that the post-process will be attached to
  56418. * @param mesh The mesh used to create the light scattering
  56419. * @param samples The post-process quality, default 100
  56420. * @param samplingModeThe post-process filtering mode
  56421. * @param engine The babylon engine
  56422. * @param reusable If the post-process is reusable
  56423. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56424. */
  56425. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56426. /**
  56427. * Returns the string "VolumetricLightScatteringPostProcess"
  56428. * @returns "VolumetricLightScatteringPostProcess"
  56429. */
  56430. getClassName(): string;
  56431. private _isReady;
  56432. /**
  56433. * Sets the new light position for light scattering effect
  56434. * @param position The new custom light position
  56435. */
  56436. setCustomMeshPosition(position: Vector3): void;
  56437. /**
  56438. * Returns the light position for light scattering effect
  56439. * @return Vector3 The custom light position
  56440. */
  56441. getCustomMeshPosition(): Vector3;
  56442. /**
  56443. * Disposes the internal assets and detaches the post-process from the camera
  56444. */
  56445. dispose(camera: Camera): void;
  56446. /**
  56447. * Returns the render target texture used by the post-process
  56448. * @return the render target texture used by the post-process
  56449. */
  56450. getPass(): RenderTargetTexture;
  56451. private _meshExcluded;
  56452. private _createPass;
  56453. private _updateMeshScreenCoordinates;
  56454. /**
  56455. * Creates a default mesh for the Volumeric Light Scattering post-process
  56456. * @param name The mesh name
  56457. * @param scene The scene where to create the mesh
  56458. * @return the default mesh
  56459. */
  56460. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56461. }
  56462. }
  56463. declare module "babylonjs/PostProcesses/index" {
  56464. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56465. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56466. export * from "babylonjs/PostProcesses/bloomEffect";
  56467. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56468. export * from "babylonjs/PostProcesses/blurPostProcess";
  56469. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56470. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56471. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56472. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56473. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56474. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56475. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56476. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56477. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56478. export * from "babylonjs/PostProcesses/filterPostProcess";
  56479. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56480. export * from "babylonjs/PostProcesses/grainPostProcess";
  56481. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56482. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56483. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56484. export * from "babylonjs/PostProcesses/passPostProcess";
  56485. export * from "babylonjs/PostProcesses/postProcess";
  56486. export * from "babylonjs/PostProcesses/postProcessManager";
  56487. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56488. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56489. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56490. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56491. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56492. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56493. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56494. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56495. }
  56496. declare module "babylonjs/Probes/index" {
  56497. export * from "babylonjs/Probes/reflectionProbe";
  56498. }
  56499. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56500. import { Scene } from "babylonjs/scene";
  56501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56502. import { Color3 } from "babylonjs/Maths/math";
  56503. import { SmartArray } from "babylonjs/Misc/smartArray";
  56504. import { ISceneComponent } from "babylonjs/sceneComponent";
  56505. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56506. import "babylonjs/Meshes/Builders/boxBuilder";
  56507. import "babylonjs/Shaders/color.fragment";
  56508. import "babylonjs/Shaders/color.vertex";
  56509. module "babylonjs/scene" {
  56510. interface Scene {
  56511. /** @hidden (Backing field) */
  56512. _boundingBoxRenderer: BoundingBoxRenderer;
  56513. /** @hidden (Backing field) */
  56514. _forceShowBoundingBoxes: boolean;
  56515. /**
  56516. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56517. */
  56518. forceShowBoundingBoxes: boolean;
  56519. /**
  56520. * Gets the bounding box renderer associated with the scene
  56521. * @returns a BoundingBoxRenderer
  56522. */
  56523. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56524. }
  56525. }
  56526. module "babylonjs/Meshes/abstractMesh" {
  56527. interface AbstractMesh {
  56528. /** @hidden (Backing field) */
  56529. _showBoundingBox: boolean;
  56530. /**
  56531. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56532. */
  56533. showBoundingBox: boolean;
  56534. }
  56535. }
  56536. /**
  56537. * Component responsible of rendering the bounding box of the meshes in a scene.
  56538. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56539. */
  56540. export class BoundingBoxRenderer implements ISceneComponent {
  56541. /**
  56542. * The component name helpfull to identify the component in the list of scene components.
  56543. */
  56544. readonly name: string;
  56545. /**
  56546. * The scene the component belongs to.
  56547. */
  56548. scene: Scene;
  56549. /**
  56550. * Color of the bounding box lines placed in front of an object
  56551. */
  56552. frontColor: Color3;
  56553. /**
  56554. * Color of the bounding box lines placed behind an object
  56555. */
  56556. backColor: Color3;
  56557. /**
  56558. * Defines if the renderer should show the back lines or not
  56559. */
  56560. showBackLines: boolean;
  56561. /**
  56562. * @hidden
  56563. */
  56564. renderList: SmartArray<BoundingBox>;
  56565. private _colorShader;
  56566. private _vertexBuffers;
  56567. private _indexBuffer;
  56568. /**
  56569. * Instantiates a new bounding box renderer in a scene.
  56570. * @param scene the scene the renderer renders in
  56571. */
  56572. constructor(scene: Scene);
  56573. /**
  56574. * Registers the component in a given scene
  56575. */
  56576. register(): void;
  56577. private _evaluateSubMesh;
  56578. private _activeMesh;
  56579. private _prepareRessources;
  56580. private _createIndexBuffer;
  56581. /**
  56582. * Rebuilds the elements related to this component in case of
  56583. * context lost for instance.
  56584. */
  56585. rebuild(): void;
  56586. /**
  56587. * @hidden
  56588. */
  56589. reset(): void;
  56590. /**
  56591. * Render the bounding boxes of a specific rendering group
  56592. * @param renderingGroupId defines the rendering group to render
  56593. */
  56594. render(renderingGroupId: number): void;
  56595. /**
  56596. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56597. * @param mesh Define the mesh to render the occlusion bounding box for
  56598. */
  56599. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56600. /**
  56601. * Dispose and release the resources attached to this renderer.
  56602. */
  56603. dispose(): void;
  56604. }
  56605. }
  56606. declare module "babylonjs/Shaders/depth.fragment" {
  56607. /** @hidden */
  56608. export var depthPixelShader: {
  56609. name: string;
  56610. shader: string;
  56611. };
  56612. }
  56613. declare module "babylonjs/Rendering/depthRenderer" {
  56614. import { Nullable } from "babylonjs/types";
  56615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56616. import { Scene } from "babylonjs/scene";
  56617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56618. import { Camera } from "babylonjs/Cameras/camera";
  56619. import "babylonjs/Shaders/depth.fragment";
  56620. import "babylonjs/Shaders/depth.vertex";
  56621. /**
  56622. * This represents a depth renderer in Babylon.
  56623. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56624. */
  56625. export class DepthRenderer {
  56626. private _scene;
  56627. private _depthMap;
  56628. private _effect;
  56629. private _cachedDefines;
  56630. private _camera;
  56631. /**
  56632. * Specifiess that the depth renderer will only be used within
  56633. * the camera it is created for.
  56634. * This can help forcing its rendering during the camera processing.
  56635. */
  56636. useOnlyInActiveCamera: boolean;
  56637. /** @hidden */
  56638. static _SceneComponentInitialization: (scene: Scene) => void;
  56639. /**
  56640. * Instantiates a depth renderer
  56641. * @param scene The scene the renderer belongs to
  56642. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56643. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56644. */
  56645. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56646. /**
  56647. * Creates the depth rendering effect and checks if the effect is ready.
  56648. * @param subMesh The submesh to be used to render the depth map of
  56649. * @param useInstances If multiple world instances should be used
  56650. * @returns if the depth renderer is ready to render the depth map
  56651. */
  56652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56653. /**
  56654. * Gets the texture which the depth map will be written to.
  56655. * @returns The depth map texture
  56656. */
  56657. getDepthMap(): RenderTargetTexture;
  56658. /**
  56659. * Disposes of the depth renderer.
  56660. */
  56661. dispose(): void;
  56662. }
  56663. }
  56664. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56665. import { Nullable } from "babylonjs/types";
  56666. import { Scene } from "babylonjs/scene";
  56667. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56668. import { Camera } from "babylonjs/Cameras/camera";
  56669. import { ISceneComponent } from "babylonjs/sceneComponent";
  56670. module "babylonjs/scene" {
  56671. interface Scene {
  56672. /** @hidden (Backing field) */
  56673. _depthRenderer: {
  56674. [id: string]: DepthRenderer;
  56675. };
  56676. /**
  56677. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56678. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56679. * @returns the created depth renderer
  56680. */
  56681. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56682. /**
  56683. * Disables a depth renderer for a given camera
  56684. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56685. */
  56686. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56687. }
  56688. }
  56689. /**
  56690. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56691. * in several rendering techniques.
  56692. */
  56693. export class DepthRendererSceneComponent implements ISceneComponent {
  56694. /**
  56695. * The component name helpfull to identify the component in the list of scene components.
  56696. */
  56697. readonly name: string;
  56698. /**
  56699. * The scene the component belongs to.
  56700. */
  56701. scene: Scene;
  56702. /**
  56703. * Creates a new instance of the component for the given scene
  56704. * @param scene Defines the scene to register the component in
  56705. */
  56706. constructor(scene: Scene);
  56707. /**
  56708. * Registers the component in a given scene
  56709. */
  56710. register(): void;
  56711. /**
  56712. * Rebuilds the elements related to this component in case of
  56713. * context lost for instance.
  56714. */
  56715. rebuild(): void;
  56716. /**
  56717. * Disposes the component and the associated ressources
  56718. */
  56719. dispose(): void;
  56720. private _gatherRenderTargets;
  56721. private _gatherActiveCameraRenderTargets;
  56722. }
  56723. }
  56724. declare module "babylonjs/Shaders/outline.fragment" {
  56725. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56726. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56727. /** @hidden */
  56728. export var outlinePixelShader: {
  56729. name: string;
  56730. shader: string;
  56731. };
  56732. }
  56733. declare module "babylonjs/Shaders/outline.vertex" {
  56734. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56736. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56739. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56740. /** @hidden */
  56741. export var outlineVertexShader: {
  56742. name: string;
  56743. shader: string;
  56744. };
  56745. }
  56746. declare module "babylonjs/Rendering/outlineRenderer" {
  56747. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56748. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56749. import { Scene } from "babylonjs/scene";
  56750. import { ISceneComponent } from "babylonjs/sceneComponent";
  56751. import "babylonjs/Shaders/outline.fragment";
  56752. import "babylonjs/Shaders/outline.vertex";
  56753. module "babylonjs/scene" {
  56754. interface Scene {
  56755. /** @hidden */
  56756. _outlineRenderer: OutlineRenderer;
  56757. /**
  56758. * Gets the outline renderer associated with the scene
  56759. * @returns a OutlineRenderer
  56760. */
  56761. getOutlineRenderer(): OutlineRenderer;
  56762. }
  56763. }
  56764. module "babylonjs/Meshes/abstractMesh" {
  56765. interface AbstractMesh {
  56766. /** @hidden (Backing field) */
  56767. _renderOutline: boolean;
  56768. /**
  56769. * Gets or sets a boolean indicating if the outline must be rendered as well
  56770. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56771. */
  56772. renderOutline: boolean;
  56773. /** @hidden (Backing field) */
  56774. _renderOverlay: boolean;
  56775. /**
  56776. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56777. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56778. */
  56779. renderOverlay: boolean;
  56780. }
  56781. }
  56782. /**
  56783. * This class is responsible to draw bothe outline/overlay of meshes.
  56784. * It should not be used directly but through the available method on mesh.
  56785. */
  56786. export class OutlineRenderer implements ISceneComponent {
  56787. /**
  56788. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56789. */
  56790. private static _StencilReference;
  56791. /**
  56792. * The name of the component. Each component must have a unique name.
  56793. */
  56794. name: string;
  56795. /**
  56796. * The scene the component belongs to.
  56797. */
  56798. scene: Scene;
  56799. /**
  56800. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56801. */
  56802. zOffset: number;
  56803. private _engine;
  56804. private _effect;
  56805. private _cachedDefines;
  56806. private _savedDepthWrite;
  56807. /**
  56808. * Instantiates a new outline renderer. (There could be only one per scene).
  56809. * @param scene Defines the scene it belongs to
  56810. */
  56811. constructor(scene: Scene);
  56812. /**
  56813. * Register the component to one instance of a scene.
  56814. */
  56815. register(): void;
  56816. /**
  56817. * Rebuilds the elements related to this component in case of
  56818. * context lost for instance.
  56819. */
  56820. rebuild(): void;
  56821. /**
  56822. * Disposes the component and the associated ressources.
  56823. */
  56824. dispose(): void;
  56825. /**
  56826. * Renders the outline in the canvas.
  56827. * @param subMesh Defines the sumesh to render
  56828. * @param batch Defines the batch of meshes in case of instances
  56829. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56830. */
  56831. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56832. /**
  56833. * Returns whether or not the outline renderer is ready for a given submesh.
  56834. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56835. * @param subMesh Defines the submesh to check readyness for
  56836. * @param useInstances Defines wheter wee are trying to render instances or not
  56837. * @returns true if ready otherwise false
  56838. */
  56839. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56840. private _beforeRenderingMesh;
  56841. private _afterRenderingMesh;
  56842. }
  56843. }
  56844. declare module "babylonjs/Rendering/index" {
  56845. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56846. export * from "babylonjs/Rendering/depthRenderer";
  56847. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56848. export * from "babylonjs/Rendering/edgesRenderer";
  56849. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56850. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56851. export * from "babylonjs/Rendering/outlineRenderer";
  56852. export * from "babylonjs/Rendering/renderingGroup";
  56853. export * from "babylonjs/Rendering/renderingManager";
  56854. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56855. }
  56856. declare module "babylonjs/Sprites/index" {
  56857. export * from "babylonjs/Sprites/sprite";
  56858. export * from "babylonjs/Sprites/spriteManager";
  56859. export * from "babylonjs/Sprites/spriteSceneComponent";
  56860. }
  56861. declare module "babylonjs/Misc/assetsManager" {
  56862. import { Scene } from "babylonjs/scene";
  56863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56865. import { Skeleton } from "babylonjs/Bones/skeleton";
  56866. import { Observable } from "babylonjs/Misc/observable";
  56867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56868. import { Texture } from "babylonjs/Materials/Textures/texture";
  56869. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56870. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56871. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56872. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56873. /**
  56874. * Defines the list of states available for a task inside a AssetsManager
  56875. */
  56876. export enum AssetTaskState {
  56877. /**
  56878. * Initialization
  56879. */
  56880. INIT = 0,
  56881. /**
  56882. * Running
  56883. */
  56884. RUNNING = 1,
  56885. /**
  56886. * Done
  56887. */
  56888. DONE = 2,
  56889. /**
  56890. * Error
  56891. */
  56892. ERROR = 3
  56893. }
  56894. /**
  56895. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56896. */
  56897. export abstract class AbstractAssetTask {
  56898. /**
  56899. * Task name
  56900. */ name: string;
  56901. /**
  56902. * Callback called when the task is successful
  56903. */
  56904. onSuccess: (task: any) => void;
  56905. /**
  56906. * Callback called when the task is not successful
  56907. */
  56908. onError: (task: any, message?: string, exception?: any) => void;
  56909. /**
  56910. * Creates a new AssetsManager
  56911. * @param name defines the name of the task
  56912. */
  56913. constructor(
  56914. /**
  56915. * Task name
  56916. */ name: string);
  56917. private _isCompleted;
  56918. private _taskState;
  56919. private _errorObject;
  56920. /**
  56921. * Get if the task is completed
  56922. */
  56923. readonly isCompleted: boolean;
  56924. /**
  56925. * Gets the current state of the task
  56926. */
  56927. readonly taskState: AssetTaskState;
  56928. /**
  56929. * Gets the current error object (if task is in error)
  56930. */
  56931. readonly errorObject: {
  56932. message?: string;
  56933. exception?: any;
  56934. };
  56935. /**
  56936. * Internal only
  56937. * @hidden
  56938. */
  56939. _setErrorObject(message?: string, exception?: any): void;
  56940. /**
  56941. * Execute the current task
  56942. * @param scene defines the scene where you want your assets to be loaded
  56943. * @param onSuccess is a callback called when the task is successfully executed
  56944. * @param onError is a callback called if an error occurs
  56945. */
  56946. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56947. /**
  56948. * Execute the current task
  56949. * @param scene defines the scene where you want your assets to be loaded
  56950. * @param onSuccess is a callback called when the task is successfully executed
  56951. * @param onError is a callback called if an error occurs
  56952. */
  56953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56954. /**
  56955. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56956. * This can be used with failed tasks that have the reason for failure fixed.
  56957. */
  56958. reset(): void;
  56959. private onErrorCallback;
  56960. private onDoneCallback;
  56961. }
  56962. /**
  56963. * Define the interface used by progress events raised during assets loading
  56964. */
  56965. export interface IAssetsProgressEvent {
  56966. /**
  56967. * Defines the number of remaining tasks to process
  56968. */
  56969. remainingCount: number;
  56970. /**
  56971. * Defines the total number of tasks
  56972. */
  56973. totalCount: number;
  56974. /**
  56975. * Defines the task that was just processed
  56976. */
  56977. task: AbstractAssetTask;
  56978. }
  56979. /**
  56980. * Class used to share progress information about assets loading
  56981. */
  56982. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56983. /**
  56984. * Defines the number of remaining tasks to process
  56985. */
  56986. remainingCount: number;
  56987. /**
  56988. * Defines the total number of tasks
  56989. */
  56990. totalCount: number;
  56991. /**
  56992. * Defines the task that was just processed
  56993. */
  56994. task: AbstractAssetTask;
  56995. /**
  56996. * Creates a AssetsProgressEvent
  56997. * @param remainingCount defines the number of remaining tasks to process
  56998. * @param totalCount defines the total number of tasks
  56999. * @param task defines the task that was just processed
  57000. */
  57001. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57002. }
  57003. /**
  57004. * Define a task used by AssetsManager to load meshes
  57005. */
  57006. export class MeshAssetTask extends AbstractAssetTask {
  57007. /**
  57008. * Defines the name of the task
  57009. */
  57010. name: string;
  57011. /**
  57012. * Defines the list of mesh's names you want to load
  57013. */
  57014. meshesNames: any;
  57015. /**
  57016. * Defines the root url to use as a base to load your meshes and associated resources
  57017. */
  57018. rootUrl: string;
  57019. /**
  57020. * Defines the filename of the scene to load from
  57021. */
  57022. sceneFilename: string;
  57023. /**
  57024. * Gets the list of loaded meshes
  57025. */
  57026. loadedMeshes: Array<AbstractMesh>;
  57027. /**
  57028. * Gets the list of loaded particle systems
  57029. */
  57030. loadedParticleSystems: Array<IParticleSystem>;
  57031. /**
  57032. * Gets the list of loaded skeletons
  57033. */
  57034. loadedSkeletons: Array<Skeleton>;
  57035. /**
  57036. * Gets the list of loaded animation groups
  57037. */
  57038. loadedAnimationGroups: Array<AnimationGroup>;
  57039. /**
  57040. * Callback called when the task is successful
  57041. */
  57042. onSuccess: (task: MeshAssetTask) => void;
  57043. /**
  57044. * Callback called when the task is successful
  57045. */
  57046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57047. /**
  57048. * Creates a new MeshAssetTask
  57049. * @param name defines the name of the task
  57050. * @param meshesNames defines the list of mesh's names you want to load
  57051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57052. * @param sceneFilename defines the filename of the scene to load from
  57053. */
  57054. constructor(
  57055. /**
  57056. * Defines the name of the task
  57057. */
  57058. name: string,
  57059. /**
  57060. * Defines the list of mesh's names you want to load
  57061. */
  57062. meshesNames: any,
  57063. /**
  57064. * Defines the root url to use as a base to load your meshes and associated resources
  57065. */
  57066. rootUrl: string,
  57067. /**
  57068. * Defines the filename of the scene to load from
  57069. */
  57070. sceneFilename: string);
  57071. /**
  57072. * Execute the current task
  57073. * @param scene defines the scene where you want your assets to be loaded
  57074. * @param onSuccess is a callback called when the task is successfully executed
  57075. * @param onError is a callback called if an error occurs
  57076. */
  57077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57078. }
  57079. /**
  57080. * Define a task used by AssetsManager to load text content
  57081. */
  57082. export class TextFileAssetTask extends AbstractAssetTask {
  57083. /**
  57084. * Defines the name of the task
  57085. */
  57086. name: string;
  57087. /**
  57088. * Defines the location of the file to load
  57089. */
  57090. url: string;
  57091. /**
  57092. * Gets the loaded text string
  57093. */
  57094. text: string;
  57095. /**
  57096. * Callback called when the task is successful
  57097. */
  57098. onSuccess: (task: TextFileAssetTask) => void;
  57099. /**
  57100. * Callback called when the task is successful
  57101. */
  57102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57103. /**
  57104. * Creates a new TextFileAssetTask object
  57105. * @param name defines the name of the task
  57106. * @param url defines the location of the file to load
  57107. */
  57108. constructor(
  57109. /**
  57110. * Defines the name of the task
  57111. */
  57112. name: string,
  57113. /**
  57114. * Defines the location of the file to load
  57115. */
  57116. url: string);
  57117. /**
  57118. * Execute the current task
  57119. * @param scene defines the scene where you want your assets to be loaded
  57120. * @param onSuccess is a callback called when the task is successfully executed
  57121. * @param onError is a callback called if an error occurs
  57122. */
  57123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57124. }
  57125. /**
  57126. * Define a task used by AssetsManager to load binary data
  57127. */
  57128. export class BinaryFileAssetTask extends AbstractAssetTask {
  57129. /**
  57130. * Defines the name of the task
  57131. */
  57132. name: string;
  57133. /**
  57134. * Defines the location of the file to load
  57135. */
  57136. url: string;
  57137. /**
  57138. * Gets the lodaded data (as an array buffer)
  57139. */
  57140. data: ArrayBuffer;
  57141. /**
  57142. * Callback called when the task is successful
  57143. */
  57144. onSuccess: (task: BinaryFileAssetTask) => void;
  57145. /**
  57146. * Callback called when the task is successful
  57147. */
  57148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57149. /**
  57150. * Creates a new BinaryFileAssetTask object
  57151. * @param name defines the name of the new task
  57152. * @param url defines the location of the file to load
  57153. */
  57154. constructor(
  57155. /**
  57156. * Defines the name of the task
  57157. */
  57158. name: string,
  57159. /**
  57160. * Defines the location of the file to load
  57161. */
  57162. url: string);
  57163. /**
  57164. * Execute the current task
  57165. * @param scene defines the scene where you want your assets to be loaded
  57166. * @param onSuccess is a callback called when the task is successfully executed
  57167. * @param onError is a callback called if an error occurs
  57168. */
  57169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57170. }
  57171. /**
  57172. * Define a task used by AssetsManager to load images
  57173. */
  57174. export class ImageAssetTask extends AbstractAssetTask {
  57175. /**
  57176. * Defines the name of the task
  57177. */
  57178. name: string;
  57179. /**
  57180. * Defines the location of the image to load
  57181. */
  57182. url: string;
  57183. /**
  57184. * Gets the loaded images
  57185. */
  57186. image: HTMLImageElement;
  57187. /**
  57188. * Callback called when the task is successful
  57189. */
  57190. onSuccess: (task: ImageAssetTask) => void;
  57191. /**
  57192. * Callback called when the task is successful
  57193. */
  57194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57195. /**
  57196. * Creates a new ImageAssetTask
  57197. * @param name defines the name of the task
  57198. * @param url defines the location of the image to load
  57199. */
  57200. constructor(
  57201. /**
  57202. * Defines the name of the task
  57203. */
  57204. name: string,
  57205. /**
  57206. * Defines the location of the image to load
  57207. */
  57208. url: string);
  57209. /**
  57210. * Execute the current task
  57211. * @param scene defines the scene where you want your assets to be loaded
  57212. * @param onSuccess is a callback called when the task is successfully executed
  57213. * @param onError is a callback called if an error occurs
  57214. */
  57215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57216. }
  57217. /**
  57218. * Defines the interface used by texture loading tasks
  57219. */
  57220. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57221. /**
  57222. * Gets the loaded texture
  57223. */
  57224. texture: TEX;
  57225. }
  57226. /**
  57227. * Define a task used by AssetsManager to load 2D textures
  57228. */
  57229. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57230. /**
  57231. * Defines the name of the task
  57232. */
  57233. name: string;
  57234. /**
  57235. * Defines the location of the file to load
  57236. */
  57237. url: string;
  57238. /**
  57239. * Defines if mipmap should not be generated (default is false)
  57240. */
  57241. noMipmap?: boolean | undefined;
  57242. /**
  57243. * Defines if texture must be inverted on Y axis (default is false)
  57244. */
  57245. invertY?: boolean | undefined;
  57246. /**
  57247. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57248. */
  57249. samplingMode: number;
  57250. /**
  57251. * Gets the loaded texture
  57252. */
  57253. texture: Texture;
  57254. /**
  57255. * Callback called when the task is successful
  57256. */
  57257. onSuccess: (task: TextureAssetTask) => void;
  57258. /**
  57259. * Callback called when the task is successful
  57260. */
  57261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57262. /**
  57263. * Creates a new TextureAssetTask object
  57264. * @param name defines the name of the task
  57265. * @param url defines the location of the file to load
  57266. * @param noMipmap defines if mipmap should not be generated (default is false)
  57267. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57269. */
  57270. constructor(
  57271. /**
  57272. * Defines the name of the task
  57273. */
  57274. name: string,
  57275. /**
  57276. * Defines the location of the file to load
  57277. */
  57278. url: string,
  57279. /**
  57280. * Defines if mipmap should not be generated (default is false)
  57281. */
  57282. noMipmap?: boolean | undefined,
  57283. /**
  57284. * Defines if texture must be inverted on Y axis (default is false)
  57285. */
  57286. invertY?: boolean | undefined,
  57287. /**
  57288. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57289. */
  57290. samplingMode?: number);
  57291. /**
  57292. * Execute the current task
  57293. * @param scene defines the scene where you want your assets to be loaded
  57294. * @param onSuccess is a callback called when the task is successfully executed
  57295. * @param onError is a callback called if an error occurs
  57296. */
  57297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57298. }
  57299. /**
  57300. * Define a task used by AssetsManager to load cube textures
  57301. */
  57302. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57303. /**
  57304. * Defines the name of the task
  57305. */
  57306. name: string;
  57307. /**
  57308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57309. */
  57310. url: string;
  57311. /**
  57312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57313. */
  57314. extensions?: string[] | undefined;
  57315. /**
  57316. * Defines if mipmaps should not be generated (default is false)
  57317. */
  57318. noMipmap?: boolean | undefined;
  57319. /**
  57320. * Defines the explicit list of files (undefined by default)
  57321. */
  57322. files?: string[] | undefined;
  57323. /**
  57324. * Gets the loaded texture
  57325. */
  57326. texture: CubeTexture;
  57327. /**
  57328. * Callback called when the task is successful
  57329. */
  57330. onSuccess: (task: CubeTextureAssetTask) => void;
  57331. /**
  57332. * Callback called when the task is successful
  57333. */
  57334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57335. /**
  57336. * Creates a new CubeTextureAssetTask
  57337. * @param name defines the name of the task
  57338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57341. * @param files defines the explicit list of files (undefined by default)
  57342. */
  57343. constructor(
  57344. /**
  57345. * Defines the name of the task
  57346. */
  57347. name: string,
  57348. /**
  57349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57350. */
  57351. url: string,
  57352. /**
  57353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57354. */
  57355. extensions?: string[] | undefined,
  57356. /**
  57357. * Defines if mipmaps should not be generated (default is false)
  57358. */
  57359. noMipmap?: boolean | undefined,
  57360. /**
  57361. * Defines the explicit list of files (undefined by default)
  57362. */
  57363. files?: string[] | undefined);
  57364. /**
  57365. * Execute the current task
  57366. * @param scene defines the scene where you want your assets to be loaded
  57367. * @param onSuccess is a callback called when the task is successfully executed
  57368. * @param onError is a callback called if an error occurs
  57369. */
  57370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57371. }
  57372. /**
  57373. * Define a task used by AssetsManager to load HDR cube textures
  57374. */
  57375. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57376. /**
  57377. * Defines the name of the task
  57378. */
  57379. name: string;
  57380. /**
  57381. * Defines the location of the file to load
  57382. */
  57383. url: string;
  57384. /**
  57385. * Defines the desired size (the more it increases the longer the generation will be)
  57386. */
  57387. size: number;
  57388. /**
  57389. * Defines if mipmaps should not be generated (default is false)
  57390. */
  57391. noMipmap: boolean;
  57392. /**
  57393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57394. */
  57395. generateHarmonics: boolean;
  57396. /**
  57397. * 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)
  57398. */
  57399. gammaSpace: boolean;
  57400. /**
  57401. * Internal Use Only
  57402. */
  57403. reserved: boolean;
  57404. /**
  57405. * Gets the loaded texture
  57406. */
  57407. texture: HDRCubeTexture;
  57408. /**
  57409. * Callback called when the task is successful
  57410. */
  57411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57412. /**
  57413. * Callback called when the task is successful
  57414. */
  57415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57416. /**
  57417. * Creates a new HDRCubeTextureAssetTask object
  57418. * @param name defines the name of the task
  57419. * @param url defines the location of the file to load
  57420. * @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.
  57421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57423. * @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)
  57424. * @param reserved Internal use only
  57425. */
  57426. constructor(
  57427. /**
  57428. * Defines the name of the task
  57429. */
  57430. name: string,
  57431. /**
  57432. * Defines the location of the file to load
  57433. */
  57434. url: string,
  57435. /**
  57436. * Defines the desired size (the more it increases the longer the generation will be)
  57437. */
  57438. size: number,
  57439. /**
  57440. * Defines if mipmaps should not be generated (default is false)
  57441. */
  57442. noMipmap?: boolean,
  57443. /**
  57444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57445. */
  57446. generateHarmonics?: boolean,
  57447. /**
  57448. * 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)
  57449. */
  57450. gammaSpace?: boolean,
  57451. /**
  57452. * Internal Use Only
  57453. */
  57454. reserved?: boolean);
  57455. /**
  57456. * Execute the current task
  57457. * @param scene defines the scene where you want your assets to be loaded
  57458. * @param onSuccess is a callback called when the task is successfully executed
  57459. * @param onError is a callback called if an error occurs
  57460. */
  57461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57462. }
  57463. /**
  57464. * Define a task used by AssetsManager to load Equirectangular cube textures
  57465. */
  57466. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57467. /**
  57468. * Defines the name of the task
  57469. */
  57470. name: string;
  57471. /**
  57472. * Defines the location of the file to load
  57473. */
  57474. url: string;
  57475. /**
  57476. * Defines the desired size (the more it increases the longer the generation will be)
  57477. */
  57478. size: number;
  57479. /**
  57480. * Defines if mipmaps should not be generated (default is false)
  57481. */
  57482. noMipmap: boolean;
  57483. /**
  57484. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57485. * but the standard material would require them in Gamma space) (default is true)
  57486. */
  57487. gammaSpace: boolean;
  57488. /**
  57489. * Gets the loaded texture
  57490. */
  57491. texture: EquiRectangularCubeTexture;
  57492. /**
  57493. * Callback called when the task is successful
  57494. */
  57495. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57496. /**
  57497. * Callback called when the task is successful
  57498. */
  57499. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57500. /**
  57501. * Creates a new EquiRectangularCubeTextureAssetTask object
  57502. * @param name defines the name of the task
  57503. * @param url defines the location of the file to load
  57504. * @param size defines the desired size (the more it increases the longer the generation will be)
  57505. * If the size is omitted this implies you are using a preprocessed cubemap.
  57506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57507. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57508. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57509. * (default is true)
  57510. */
  57511. constructor(
  57512. /**
  57513. * Defines the name of the task
  57514. */
  57515. name: string,
  57516. /**
  57517. * Defines the location of the file to load
  57518. */
  57519. url: string,
  57520. /**
  57521. * Defines the desired size (the more it increases the longer the generation will be)
  57522. */
  57523. size: number,
  57524. /**
  57525. * Defines if mipmaps should not be generated (default is false)
  57526. */
  57527. noMipmap?: boolean,
  57528. /**
  57529. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57530. * but the standard material would require them in Gamma space) (default is true)
  57531. */
  57532. gammaSpace?: boolean);
  57533. /**
  57534. * Execute the current task
  57535. * @param scene defines the scene where you want your assets to be loaded
  57536. * @param onSuccess is a callback called when the task is successfully executed
  57537. * @param onError is a callback called if an error occurs
  57538. */
  57539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57540. }
  57541. /**
  57542. * This class can be used to easily import assets into a scene
  57543. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57544. */
  57545. export class AssetsManager {
  57546. private _scene;
  57547. private _isLoading;
  57548. protected _tasks: AbstractAssetTask[];
  57549. protected _waitingTasksCount: number;
  57550. protected _totalTasksCount: number;
  57551. /**
  57552. * Callback called when all tasks are processed
  57553. */
  57554. onFinish: (tasks: AbstractAssetTask[]) => void;
  57555. /**
  57556. * Callback called when a task is successful
  57557. */
  57558. onTaskSuccess: (task: AbstractAssetTask) => void;
  57559. /**
  57560. * Callback called when a task had an error
  57561. */
  57562. onTaskError: (task: AbstractAssetTask) => void;
  57563. /**
  57564. * Callback called when a task is done (whatever the result is)
  57565. */
  57566. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57567. /**
  57568. * Observable called when all tasks are processed
  57569. */
  57570. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57571. /**
  57572. * Observable called when a task had an error
  57573. */
  57574. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57575. /**
  57576. * Observable called when all tasks were executed
  57577. */
  57578. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57579. /**
  57580. * Observable called when a task is done (whatever the result is)
  57581. */
  57582. onProgressObservable: Observable<IAssetsProgressEvent>;
  57583. /**
  57584. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57585. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57586. */
  57587. useDefaultLoadingScreen: boolean;
  57588. /**
  57589. * Creates a new AssetsManager
  57590. * @param scene defines the scene to work on
  57591. */
  57592. constructor(scene: Scene);
  57593. /**
  57594. * Add a MeshAssetTask to the list of active tasks
  57595. * @param taskName defines the name of the new task
  57596. * @param meshesNames defines the name of meshes to load
  57597. * @param rootUrl defines the root url to use to locate files
  57598. * @param sceneFilename defines the filename of the scene file
  57599. * @returns a new MeshAssetTask object
  57600. */
  57601. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57602. /**
  57603. * Add a TextFileAssetTask to the list of active tasks
  57604. * @param taskName defines the name of the new task
  57605. * @param url defines the url of the file to load
  57606. * @returns a new TextFileAssetTask object
  57607. */
  57608. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57609. /**
  57610. * Add a BinaryFileAssetTask to the list of active tasks
  57611. * @param taskName defines the name of the new task
  57612. * @param url defines the url of the file to load
  57613. * @returns a new BinaryFileAssetTask object
  57614. */
  57615. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57616. /**
  57617. * Add a ImageAssetTask to the list of active tasks
  57618. * @param taskName defines the name of the new task
  57619. * @param url defines the url of the file to load
  57620. * @returns a new ImageAssetTask object
  57621. */
  57622. addImageTask(taskName: string, url: string): ImageAssetTask;
  57623. /**
  57624. * Add a TextureAssetTask to the list of active tasks
  57625. * @param taskName defines the name of the new task
  57626. * @param url defines the url of the file to load
  57627. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57628. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57629. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57630. * @returns a new TextureAssetTask object
  57631. */
  57632. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57633. /**
  57634. * Add a CubeTextureAssetTask to the list of active tasks
  57635. * @param taskName defines the name of the new task
  57636. * @param url defines the url of the file to load
  57637. * @param extensions defines the extension to use to load the cube map (can be null)
  57638. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57639. * @param files defines the list of files to load (can be null)
  57640. * @returns a new CubeTextureAssetTask object
  57641. */
  57642. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57643. /**
  57644. *
  57645. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57646. * @param taskName defines the name of the new task
  57647. * @param url defines the url of the file to load
  57648. * @param size defines the size you want for the cubemap (can be null)
  57649. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57650. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57651. * @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)
  57652. * @param reserved Internal use only
  57653. * @returns a new HDRCubeTextureAssetTask object
  57654. */
  57655. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57656. /**
  57657. *
  57658. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57659. * @param taskName defines the name of the new task
  57660. * @param url defines the url of the file to load
  57661. * @param size defines the size you want for the cubemap (can be null)
  57662. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57663. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57664. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57665. * @returns a new EquiRectangularCubeTextureAssetTask object
  57666. */
  57667. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57668. /**
  57669. * Remove a task from the assets manager.
  57670. * @param task the task to remove
  57671. */
  57672. removeTask(task: AbstractAssetTask): void;
  57673. private _decreaseWaitingTasksCount;
  57674. private _runTask;
  57675. /**
  57676. * Reset the AssetsManager and remove all tasks
  57677. * @return the current instance of the AssetsManager
  57678. */
  57679. reset(): AssetsManager;
  57680. /**
  57681. * Start the loading process
  57682. * @return the current instance of the AssetsManager
  57683. */
  57684. load(): AssetsManager;
  57685. /**
  57686. * Start the loading process as an async operation
  57687. * @return a promise returning the list of failed tasks
  57688. */
  57689. loadAsync(): Promise<void>;
  57690. }
  57691. }
  57692. declare module "babylonjs/Misc/deferred" {
  57693. /**
  57694. * Wrapper class for promise with external resolve and reject.
  57695. */
  57696. export class Deferred<T> {
  57697. /**
  57698. * The promise associated with this deferred object.
  57699. */
  57700. readonly promise: Promise<T>;
  57701. private _resolve;
  57702. private _reject;
  57703. /**
  57704. * The resolve method of the promise associated with this deferred object.
  57705. */
  57706. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57707. /**
  57708. * The reject method of the promise associated with this deferred object.
  57709. */
  57710. readonly reject: (reason?: any) => void;
  57711. /**
  57712. * Constructor for this deferred object.
  57713. */
  57714. constructor();
  57715. }
  57716. }
  57717. declare module "babylonjs/Misc/meshExploder" {
  57718. import { Mesh } from "babylonjs/Meshes/mesh";
  57719. /**
  57720. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57721. */
  57722. export class MeshExploder {
  57723. private _centerMesh;
  57724. private _meshes;
  57725. private _meshesOrigins;
  57726. private _toCenterVectors;
  57727. private _scaledDirection;
  57728. private _newPosition;
  57729. private _centerPosition;
  57730. /**
  57731. * Explodes meshes from a center mesh.
  57732. * @param meshes The meshes to explode.
  57733. * @param centerMesh The mesh to be center of explosion.
  57734. */
  57735. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57736. private _setCenterMesh;
  57737. /**
  57738. * Get class name
  57739. * @returns "MeshExploder"
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * "Exploded meshes"
  57744. * @returns Array of meshes with the centerMesh at index 0.
  57745. */
  57746. getMeshes(): Array<Mesh>;
  57747. /**
  57748. * Explodes meshes giving a specific direction
  57749. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57750. */
  57751. explode(direction?: number): void;
  57752. }
  57753. }
  57754. declare module "babylonjs/Misc/filesInput" {
  57755. import { Engine } from "babylonjs/Engines/engine";
  57756. import { Scene } from "babylonjs/scene";
  57757. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57758. /**
  57759. * Class used to help managing file picking and drag'n'drop
  57760. */
  57761. export class FilesInput {
  57762. /**
  57763. * List of files ready to be loaded
  57764. */
  57765. static readonly FilesToLoad: {
  57766. [key: string]: File;
  57767. };
  57768. /**
  57769. * Callback called when a file is processed
  57770. */
  57771. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57772. private _engine;
  57773. private _currentScene;
  57774. private _sceneLoadedCallback;
  57775. private _progressCallback;
  57776. private _additionalRenderLoopLogicCallback;
  57777. private _textureLoadingCallback;
  57778. private _startingProcessingFilesCallback;
  57779. private _onReloadCallback;
  57780. private _errorCallback;
  57781. private _elementToMonitor;
  57782. private _sceneFileToLoad;
  57783. private _filesToLoad;
  57784. /**
  57785. * Creates a new FilesInput
  57786. * @param engine defines the rendering engine
  57787. * @param scene defines the hosting scene
  57788. * @param sceneLoadedCallback callback called when scene is loaded
  57789. * @param progressCallback callback called to track progress
  57790. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57791. * @param textureLoadingCallback callback called when a texture is loading
  57792. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57793. * @param onReloadCallback callback called when a reload is requested
  57794. * @param errorCallback callback call if an error occurs
  57795. */
  57796. 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);
  57797. private _dragEnterHandler;
  57798. private _dragOverHandler;
  57799. private _dropHandler;
  57800. /**
  57801. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57802. * @param elementToMonitor defines the DOM element to track
  57803. */
  57804. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57805. /**
  57806. * Release all associated resources
  57807. */
  57808. dispose(): void;
  57809. private renderFunction;
  57810. private drag;
  57811. private drop;
  57812. private _traverseFolder;
  57813. private _processFiles;
  57814. /**
  57815. * Load files from a drop event
  57816. * @param event defines the drop event to use as source
  57817. */
  57818. loadFiles(event: any): void;
  57819. private _processReload;
  57820. /**
  57821. * Reload the current scene from the loaded files
  57822. */
  57823. reload(): void;
  57824. }
  57825. }
  57826. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57827. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57828. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57829. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57830. }
  57831. declare module "babylonjs/Misc/sceneOptimizer" {
  57832. import { Scene, IDisposable } from "babylonjs/scene";
  57833. import { Observable } from "babylonjs/Misc/observable";
  57834. /**
  57835. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57837. */
  57838. export class SceneOptimization {
  57839. /**
  57840. * Defines the priority of this optimization (0 by default which means first in the list)
  57841. */
  57842. priority: number;
  57843. /**
  57844. * Gets a string describing the action executed by the current optimization
  57845. * @returns description string
  57846. */
  57847. getDescription(): string;
  57848. /**
  57849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57850. * @param scene defines the current scene where to apply this optimization
  57851. * @param optimizer defines the current optimizer
  57852. * @returns true if everything that can be done was applied
  57853. */
  57854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57855. /**
  57856. * Creates the SceneOptimization object
  57857. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57858. * @param desc defines the description associated with the optimization
  57859. */
  57860. constructor(
  57861. /**
  57862. * Defines the priority of this optimization (0 by default which means first in the list)
  57863. */
  57864. priority?: number);
  57865. }
  57866. /**
  57867. * Defines an optimization used to reduce the size of render target textures
  57868. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57869. */
  57870. export class TextureOptimization extends SceneOptimization {
  57871. /**
  57872. * Defines the priority of this optimization (0 by default which means first in the list)
  57873. */
  57874. priority: number;
  57875. /**
  57876. * 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
  57877. */
  57878. maximumSize: number;
  57879. /**
  57880. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57881. */
  57882. step: number;
  57883. /**
  57884. * Gets a string describing the action executed by the current optimization
  57885. * @returns description string
  57886. */
  57887. getDescription(): string;
  57888. /**
  57889. * Creates the TextureOptimization object
  57890. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57891. * @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
  57892. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57893. */
  57894. constructor(
  57895. /**
  57896. * Defines the priority of this optimization (0 by default which means first in the list)
  57897. */
  57898. priority?: number,
  57899. /**
  57900. * 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
  57901. */
  57902. maximumSize?: number,
  57903. /**
  57904. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57905. */
  57906. step?: number);
  57907. /**
  57908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57909. * @param scene defines the current scene where to apply this optimization
  57910. * @param optimizer defines the current optimizer
  57911. * @returns true if everything that can be done was applied
  57912. */
  57913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57914. }
  57915. /**
  57916. * Defines an optimization used to increase or decrease the rendering resolution
  57917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57918. */
  57919. export class HardwareScalingOptimization extends SceneOptimization {
  57920. /**
  57921. * Defines the priority of this optimization (0 by default which means first in the list)
  57922. */
  57923. priority: number;
  57924. /**
  57925. * Defines the maximum scale to use (2 by default)
  57926. */
  57927. maximumScale: number;
  57928. /**
  57929. * Defines the step to use between two passes (0.5 by default)
  57930. */
  57931. step: number;
  57932. private _currentScale;
  57933. private _directionOffset;
  57934. /**
  57935. * Gets a string describing the action executed by the current optimization
  57936. * @return description string
  57937. */
  57938. getDescription(): string;
  57939. /**
  57940. * Creates the HardwareScalingOptimization object
  57941. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57942. * @param maximumScale defines the maximum scale to use (2 by default)
  57943. * @param step defines the step to use between two passes (0.5 by default)
  57944. */
  57945. constructor(
  57946. /**
  57947. * Defines the priority of this optimization (0 by default which means first in the list)
  57948. */
  57949. priority?: number,
  57950. /**
  57951. * Defines the maximum scale to use (2 by default)
  57952. */
  57953. maximumScale?: number,
  57954. /**
  57955. * Defines the step to use between two passes (0.5 by default)
  57956. */
  57957. step?: number);
  57958. /**
  57959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57960. * @param scene defines the current scene where to apply this optimization
  57961. * @param optimizer defines the current optimizer
  57962. * @returns true if everything that can be done was applied
  57963. */
  57964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57965. }
  57966. /**
  57967. * Defines an optimization used to remove shadows
  57968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57969. */
  57970. export class ShadowsOptimization extends SceneOptimization {
  57971. /**
  57972. * Gets a string describing the action executed by the current optimization
  57973. * @return description string
  57974. */
  57975. getDescription(): string;
  57976. /**
  57977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57978. * @param scene defines the current scene where to apply this optimization
  57979. * @param optimizer defines the current optimizer
  57980. * @returns true if everything that can be done was applied
  57981. */
  57982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57983. }
  57984. /**
  57985. * Defines an optimization used to turn post-processes off
  57986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57987. */
  57988. export class PostProcessesOptimization extends SceneOptimization {
  57989. /**
  57990. * Gets a string describing the action executed by the current optimization
  57991. * @return description string
  57992. */
  57993. getDescription(): string;
  57994. /**
  57995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57996. * @param scene defines the current scene where to apply this optimization
  57997. * @param optimizer defines the current optimizer
  57998. * @returns true if everything that can be done was applied
  57999. */
  58000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58001. }
  58002. /**
  58003. * Defines an optimization used to turn lens flares off
  58004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58005. */
  58006. export class LensFlaresOptimization extends SceneOptimization {
  58007. /**
  58008. * Gets a string describing the action executed by the current optimization
  58009. * @return description string
  58010. */
  58011. getDescription(): string;
  58012. /**
  58013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58014. * @param scene defines the current scene where to apply this optimization
  58015. * @param optimizer defines the current optimizer
  58016. * @returns true if everything that can be done was applied
  58017. */
  58018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58019. }
  58020. /**
  58021. * Defines an optimization based on user defined callback.
  58022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58023. */
  58024. export class CustomOptimization extends SceneOptimization {
  58025. /**
  58026. * Callback called to apply the custom optimization.
  58027. */
  58028. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58029. /**
  58030. * Callback called to get custom description
  58031. */
  58032. onGetDescription: () => string;
  58033. /**
  58034. * Gets a string describing the action executed by the current optimization
  58035. * @returns description string
  58036. */
  58037. getDescription(): string;
  58038. /**
  58039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58040. * @param scene defines the current scene where to apply this optimization
  58041. * @param optimizer defines the current optimizer
  58042. * @returns true if everything that can be done was applied
  58043. */
  58044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58045. }
  58046. /**
  58047. * Defines an optimization used to turn particles off
  58048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58049. */
  58050. export class ParticlesOptimization extends SceneOptimization {
  58051. /**
  58052. * Gets a string describing the action executed by the current optimization
  58053. * @return description string
  58054. */
  58055. getDescription(): string;
  58056. /**
  58057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58058. * @param scene defines the current scene where to apply this optimization
  58059. * @param optimizer defines the current optimizer
  58060. * @returns true if everything that can be done was applied
  58061. */
  58062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58063. }
  58064. /**
  58065. * Defines an optimization used to turn render targets off
  58066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58067. */
  58068. export class RenderTargetsOptimization extends SceneOptimization {
  58069. /**
  58070. * Gets a string describing the action executed by the current optimization
  58071. * @return description string
  58072. */
  58073. getDescription(): string;
  58074. /**
  58075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58076. * @param scene defines the current scene where to apply this optimization
  58077. * @param optimizer defines the current optimizer
  58078. * @returns true if everything that can be done was applied
  58079. */
  58080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58081. }
  58082. /**
  58083. * Defines an optimization used to merge meshes with compatible materials
  58084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58085. */
  58086. export class MergeMeshesOptimization extends SceneOptimization {
  58087. private static _UpdateSelectionTree;
  58088. /**
  58089. * Gets or sets a boolean which defines if optimization octree has to be updated
  58090. */
  58091. /**
  58092. * Gets or sets a boolean which defines if optimization octree has to be updated
  58093. */
  58094. static UpdateSelectionTree: boolean;
  58095. /**
  58096. * Gets a string describing the action executed by the current optimization
  58097. * @return description string
  58098. */
  58099. getDescription(): string;
  58100. private _canBeMerged;
  58101. /**
  58102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58103. * @param scene defines the current scene where to apply this optimization
  58104. * @param optimizer defines the current optimizer
  58105. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58106. * @returns true if everything that can be done was applied
  58107. */
  58108. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58109. }
  58110. /**
  58111. * Defines a list of options used by SceneOptimizer
  58112. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58113. */
  58114. export class SceneOptimizerOptions {
  58115. /**
  58116. * Defines the target frame rate to reach (60 by default)
  58117. */
  58118. targetFrameRate: number;
  58119. /**
  58120. * Defines the interval between two checkes (2000ms by default)
  58121. */
  58122. trackerDuration: number;
  58123. /**
  58124. * Gets the list of optimizations to apply
  58125. */
  58126. optimizations: SceneOptimization[];
  58127. /**
  58128. * Creates a new list of options used by SceneOptimizer
  58129. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58130. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58131. */
  58132. constructor(
  58133. /**
  58134. * Defines the target frame rate to reach (60 by default)
  58135. */
  58136. targetFrameRate?: number,
  58137. /**
  58138. * Defines the interval between two checkes (2000ms by default)
  58139. */
  58140. trackerDuration?: number);
  58141. /**
  58142. * Add a new optimization
  58143. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58144. * @returns the current SceneOptimizerOptions
  58145. */
  58146. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58147. /**
  58148. * Add a new custom optimization
  58149. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58150. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58152. * @returns the current SceneOptimizerOptions
  58153. */
  58154. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58155. /**
  58156. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58157. * @param targetFrameRate defines the target frame rate (60 by default)
  58158. * @returns a SceneOptimizerOptions object
  58159. */
  58160. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58161. /**
  58162. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58163. * @param targetFrameRate defines the target frame rate (60 by default)
  58164. * @returns a SceneOptimizerOptions object
  58165. */
  58166. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58167. /**
  58168. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58169. * @param targetFrameRate defines the target frame rate (60 by default)
  58170. * @returns a SceneOptimizerOptions object
  58171. */
  58172. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58173. }
  58174. /**
  58175. * Class used to run optimizations in order to reach a target frame rate
  58176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58177. */
  58178. export class SceneOptimizer implements IDisposable {
  58179. private _isRunning;
  58180. private _options;
  58181. private _scene;
  58182. private _currentPriorityLevel;
  58183. private _targetFrameRate;
  58184. private _trackerDuration;
  58185. private _currentFrameRate;
  58186. private _sceneDisposeObserver;
  58187. private _improvementMode;
  58188. /**
  58189. * Defines an observable called when the optimizer reaches the target frame rate
  58190. */
  58191. onSuccessObservable: Observable<SceneOptimizer>;
  58192. /**
  58193. * Defines an observable called when the optimizer enables an optimization
  58194. */
  58195. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58196. /**
  58197. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58198. */
  58199. onFailureObservable: Observable<SceneOptimizer>;
  58200. /**
  58201. * Gets a boolean indicating if the optimizer is in improvement mode
  58202. */
  58203. readonly isInImprovementMode: boolean;
  58204. /**
  58205. * Gets the current priority level (0 at start)
  58206. */
  58207. readonly currentPriorityLevel: number;
  58208. /**
  58209. * Gets the current frame rate checked by the SceneOptimizer
  58210. */
  58211. readonly currentFrameRate: number;
  58212. /**
  58213. * Gets or sets the current target frame rate (60 by default)
  58214. */
  58215. /**
  58216. * Gets or sets the current target frame rate (60 by default)
  58217. */
  58218. targetFrameRate: number;
  58219. /**
  58220. * Gets or sets the current interval between two checks (every 2000ms by default)
  58221. */
  58222. /**
  58223. * Gets or sets the current interval between two checks (every 2000ms by default)
  58224. */
  58225. trackerDuration: number;
  58226. /**
  58227. * Gets the list of active optimizations
  58228. */
  58229. readonly optimizations: SceneOptimization[];
  58230. /**
  58231. * Creates a new SceneOptimizer
  58232. * @param scene defines the scene to work on
  58233. * @param options defines the options to use with the SceneOptimizer
  58234. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58235. * @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)
  58236. */
  58237. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58238. /**
  58239. * Stops the current optimizer
  58240. */
  58241. stop(): void;
  58242. /**
  58243. * Reset the optimizer to initial step (current priority level = 0)
  58244. */
  58245. reset(): void;
  58246. /**
  58247. * Start the optimizer. By default it will try to reach a specific framerate
  58248. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58249. */
  58250. start(): void;
  58251. private _checkCurrentState;
  58252. /**
  58253. * Release all resources
  58254. */
  58255. dispose(): void;
  58256. /**
  58257. * Helper function to create a SceneOptimizer with one single line of code
  58258. * @param scene defines the scene to work on
  58259. * @param options defines the options to use with the SceneOptimizer
  58260. * @param onSuccess defines a callback to call on success
  58261. * @param onFailure defines a callback to call on failure
  58262. * @returns the new SceneOptimizer object
  58263. */
  58264. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58265. }
  58266. }
  58267. declare module "babylonjs/Misc/sceneSerializer" {
  58268. import { Scene } from "babylonjs/scene";
  58269. /**
  58270. * Class used to serialize a scene into a string
  58271. */
  58272. export class SceneSerializer {
  58273. /**
  58274. * Clear cache used by a previous serialization
  58275. */
  58276. static ClearCache(): void;
  58277. /**
  58278. * Serialize a scene into a JSON compatible object
  58279. * @param scene defines the scene to serialize
  58280. * @returns a JSON compatible object
  58281. */
  58282. static Serialize(scene: Scene): any;
  58283. /**
  58284. * Serialize a mesh into a JSON compatible object
  58285. * @param toSerialize defines the mesh to serialize
  58286. * @param withParents defines if parents must be serialized as well
  58287. * @param withChildren defines if children must be serialized as well
  58288. * @returns a JSON compatible object
  58289. */
  58290. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58291. }
  58292. }
  58293. declare module "babylonjs/Misc/textureTools" {
  58294. import { Texture } from "babylonjs/Materials/Textures/texture";
  58295. /**
  58296. * Class used to host texture specific utilities
  58297. */
  58298. export class TextureTools {
  58299. /**
  58300. * Uses the GPU to create a copy texture rescaled at a given size
  58301. * @param texture Texture to copy from
  58302. * @param width defines the desired width
  58303. * @param height defines the desired height
  58304. * @param useBilinearMode defines if bilinear mode has to be used
  58305. * @return the generated texture
  58306. */
  58307. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58308. }
  58309. }
  58310. declare module "babylonjs/Misc/videoRecorder" {
  58311. import { Nullable } from "babylonjs/types";
  58312. import { Engine } from "babylonjs/Engines/engine";
  58313. /**
  58314. * This represents the different options avilable for the video capture.
  58315. */
  58316. export interface VideoRecorderOptions {
  58317. /** Defines the mime type of the video */
  58318. mimeType: string;
  58319. /** Defines the video the video should be recorded at */
  58320. fps: number;
  58321. /** Defines the chunk size for the recording data */
  58322. recordChunckSize: number;
  58323. /** The audio tracks to attach to the record */
  58324. audioTracks?: MediaStreamTrack[];
  58325. }
  58326. /**
  58327. * This can helps recording videos from BabylonJS.
  58328. * This is based on the available WebRTC functionalities of the browser.
  58329. *
  58330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58331. */
  58332. export class VideoRecorder {
  58333. private static readonly _defaultOptions;
  58334. /**
  58335. * Returns wehther or not the VideoRecorder is available in your browser.
  58336. * @param engine Defines the Babylon Engine to check the support for
  58337. * @returns true if supported otherwise false
  58338. */
  58339. static IsSupported(engine: Engine): boolean;
  58340. private readonly _options;
  58341. private _canvas;
  58342. private _mediaRecorder;
  58343. private _recordedChunks;
  58344. private _fileName;
  58345. private _resolve;
  58346. private _reject;
  58347. /**
  58348. * True wether a recording is already in progress.
  58349. */
  58350. readonly isRecording: boolean;
  58351. /**
  58352. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58353. * a video file.
  58354. * @param engine Defines the BabylonJS Engine you wish to record
  58355. * @param options Defines options that can be used to customized the capture
  58356. */
  58357. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58358. /**
  58359. * Stops the current recording before the default capture timeout passed in the startRecording
  58360. * functions.
  58361. */
  58362. stopRecording(): void;
  58363. /**
  58364. * Starts recording the canvas for a max duration specified in parameters.
  58365. * @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.
  58366. * @param maxDuration Defines the maximum recording time in seconds.
  58367. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58368. * @return a promise callback at the end of the recording with the video data in Blob.
  58369. */
  58370. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58371. /**
  58372. * Releases internal resources used during the recording.
  58373. */
  58374. dispose(): void;
  58375. private _handleDataAvailable;
  58376. private _handleError;
  58377. private _handleStop;
  58378. }
  58379. }
  58380. declare module "babylonjs/Misc/workerPool" {
  58381. import { IDisposable } from "babylonjs/scene";
  58382. /**
  58383. * Helper class to push actions to a pool of workers.
  58384. */
  58385. export class WorkerPool implements IDisposable {
  58386. private _workerInfos;
  58387. private _pendingActions;
  58388. /**
  58389. * Constructor
  58390. * @param workers Array of workers to use for actions
  58391. */
  58392. constructor(workers: Array<Worker>);
  58393. /**
  58394. * Terminates all workers and clears any pending actions.
  58395. */
  58396. dispose(): void;
  58397. /**
  58398. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58399. * pended until a worker has completed its action.
  58400. * @param action The action to perform. Call onComplete when the action is complete.
  58401. */
  58402. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58403. private _execute;
  58404. }
  58405. }
  58406. declare module "babylonjs/Misc/screenshotTools" {
  58407. import { Camera } from "babylonjs/Cameras/camera";
  58408. import { Engine } from "babylonjs/Engines/engine";
  58409. /**
  58410. * Class containing a set of static utilities functions for screenshots
  58411. */
  58412. export class ScreenshotTools {
  58413. /**
  58414. * Captures a screenshot of the current rendering
  58415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58416. * @param engine defines the rendering engine
  58417. * @param camera defines the source camera
  58418. * @param size This parameter can be set to a single number or to an object with the
  58419. * following (optional) properties: precision, width, height. If a single number is passed,
  58420. * it will be used for both width and height. If an object is passed, the screenshot size
  58421. * will be derived from the parameters. The precision property is a multiplier allowing
  58422. * rendering at a higher or lower resolution
  58423. * @param successCallback defines the callback receives a single parameter which contains the
  58424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58425. * src parameter of an <img> to display it
  58426. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58427. * Check your browser for supported MIME types
  58428. */
  58429. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58430. /**
  58431. * Generates an image screenshot from the specified camera.
  58432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58433. * @param engine The engine to use for rendering
  58434. * @param camera The camera to use for rendering
  58435. * @param size This parameter can be set to a single number or to an object with the
  58436. * following (optional) properties: precision, width, height. If a single number is passed,
  58437. * it will be used for both width and height. If an object is passed, the screenshot size
  58438. * will be derived from the parameters. The precision property is a multiplier allowing
  58439. * rendering at a higher or lower resolution
  58440. * @param successCallback The callback receives a single parameter which contains the
  58441. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58442. * src parameter of an <img> to display it
  58443. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58444. * Check your browser for supported MIME types
  58445. * @param samples Texture samples (default: 1)
  58446. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58447. * @param fileName A name for for the downloaded file.
  58448. */
  58449. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58450. }
  58451. }
  58452. declare module "babylonjs/Misc/index" {
  58453. export * from "babylonjs/Misc/andOrNotEvaluator";
  58454. export * from "babylonjs/Misc/assetsManager";
  58455. export * from "babylonjs/Misc/dds";
  58456. export * from "babylonjs/Misc/decorators";
  58457. export * from "babylonjs/Misc/deferred";
  58458. export * from "babylonjs/Misc/environmentTextureTools";
  58459. export * from "babylonjs/Misc/meshExploder";
  58460. export * from "babylonjs/Misc/filesInput";
  58461. export * from "babylonjs/Misc/HighDynamicRange/index";
  58462. export * from "babylonjs/Misc/khronosTextureContainer";
  58463. export * from "babylonjs/Misc/observable";
  58464. export * from "babylonjs/Misc/performanceMonitor";
  58465. export * from "babylonjs/Misc/promise";
  58466. export * from "babylonjs/Misc/sceneOptimizer";
  58467. export * from "babylonjs/Misc/sceneSerializer";
  58468. export * from "babylonjs/Misc/smartArray";
  58469. export * from "babylonjs/Misc/stringDictionary";
  58470. export * from "babylonjs/Misc/tags";
  58471. export * from "babylonjs/Misc/textureTools";
  58472. export * from "babylonjs/Misc/tga";
  58473. export * from "babylonjs/Misc/tools";
  58474. export * from "babylonjs/Misc/videoRecorder";
  58475. export * from "babylonjs/Misc/virtualJoystick";
  58476. export * from "babylonjs/Misc/workerPool";
  58477. export * from "babylonjs/Misc/logger";
  58478. export * from "babylonjs/Misc/typeStore";
  58479. export * from "babylonjs/Misc/filesInputStore";
  58480. export * from "babylonjs/Misc/deepCopier";
  58481. export * from "babylonjs/Misc/pivotTools";
  58482. export * from "babylonjs/Misc/precisionDate";
  58483. export * from "babylonjs/Misc/screenshotTools";
  58484. export * from "babylonjs/Misc/typeStore";
  58485. export * from "babylonjs/Misc/webRequest";
  58486. export * from "babylonjs/Misc/iInspectable";
  58487. }
  58488. declare module "babylonjs/index" {
  58489. export * from "babylonjs/abstractScene";
  58490. export * from "babylonjs/Actions/index";
  58491. export * from "babylonjs/Animations/index";
  58492. export * from "babylonjs/assetContainer";
  58493. export * from "babylonjs/Audio/index";
  58494. export * from "babylonjs/Behaviors/index";
  58495. export * from "babylonjs/Bones/index";
  58496. export * from "babylonjs/Cameras/index";
  58497. export * from "babylonjs/Collisions/index";
  58498. export * from "babylonjs/Culling/index";
  58499. export * from "babylonjs/Debug/index";
  58500. export * from "babylonjs/Engines/index";
  58501. export * from "babylonjs/Events/index";
  58502. export * from "babylonjs/Gamepads/index";
  58503. export * from "babylonjs/Gizmos/index";
  58504. export * from "babylonjs/Helpers/index";
  58505. export * from "babylonjs/Instrumentation/index";
  58506. export * from "babylonjs/Layers/index";
  58507. export * from "babylonjs/LensFlares/index";
  58508. export * from "babylonjs/Lights/index";
  58509. export * from "babylonjs/Loading/index";
  58510. export * from "babylonjs/Materials/index";
  58511. export * from "babylonjs/Maths/index";
  58512. export * from "babylonjs/Meshes/index";
  58513. export * from "babylonjs/Morph/index";
  58514. export * from "babylonjs/node";
  58515. export * from "babylonjs/Offline/index";
  58516. export * from "babylonjs/Particles/index";
  58517. export * from "babylonjs/Physics/index";
  58518. export * from "babylonjs/PostProcesses/index";
  58519. export * from "babylonjs/Probes/index";
  58520. export * from "babylonjs/Rendering/index";
  58521. export * from "babylonjs/scene";
  58522. export * from "babylonjs/sceneComponent";
  58523. export * from "babylonjs/Sprites/index";
  58524. export * from "babylonjs/States/index";
  58525. export * from "babylonjs/Misc/index";
  58526. export * from "babylonjs/types";
  58527. }
  58528. declare module "babylonjs/Animations/pathCursor" {
  58529. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58530. /**
  58531. * A cursor which tracks a point on a path
  58532. */
  58533. export class PathCursor {
  58534. private path;
  58535. /**
  58536. * Stores path cursor callbacks for when an onchange event is triggered
  58537. */
  58538. private _onchange;
  58539. /**
  58540. * The value of the path cursor
  58541. */
  58542. value: number;
  58543. /**
  58544. * The animation array of the path cursor
  58545. */
  58546. animations: Animation[];
  58547. /**
  58548. * Initializes the path cursor
  58549. * @param path The path to track
  58550. */
  58551. constructor(path: Path2);
  58552. /**
  58553. * Gets the cursor point on the path
  58554. * @returns A point on the path cursor at the cursor location
  58555. */
  58556. getPoint(): Vector3;
  58557. /**
  58558. * Moves the cursor ahead by the step amount
  58559. * @param step The amount to move the cursor forward
  58560. * @returns This path cursor
  58561. */
  58562. moveAhead(step?: number): PathCursor;
  58563. /**
  58564. * Moves the cursor behind by the step amount
  58565. * @param step The amount to move the cursor back
  58566. * @returns This path cursor
  58567. */
  58568. moveBack(step?: number): PathCursor;
  58569. /**
  58570. * Moves the cursor by the step amount
  58571. * If the step amount is greater than one, an exception is thrown
  58572. * @param step The amount to move the cursor
  58573. * @returns This path cursor
  58574. */
  58575. move(step: number): PathCursor;
  58576. /**
  58577. * Ensures that the value is limited between zero and one
  58578. * @returns This path cursor
  58579. */
  58580. private ensureLimits;
  58581. /**
  58582. * Runs onchange callbacks on change (used by the animation engine)
  58583. * @returns This path cursor
  58584. */
  58585. private raiseOnChange;
  58586. /**
  58587. * Executes a function on change
  58588. * @param f A path cursor onchange callback
  58589. * @returns This path cursor
  58590. */
  58591. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58592. }
  58593. }
  58594. declare module "babylonjs/Legacy/legacy" {
  58595. import * as Babylon from "babylonjs/index";
  58596. export * from "babylonjs/index";
  58597. }
  58598. declare module "babylonjs/Shaders/blur.fragment" {
  58599. /** @hidden */
  58600. export var blurPixelShader: {
  58601. name: string;
  58602. shader: string;
  58603. };
  58604. }
  58605. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58606. /** @hidden */
  58607. export var bones300Declaration: {
  58608. name: string;
  58609. shader: string;
  58610. };
  58611. }
  58612. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58613. /** @hidden */
  58614. export var instances300Declaration: {
  58615. name: string;
  58616. shader: string;
  58617. };
  58618. }
  58619. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58620. /** @hidden */
  58621. export var pointCloudVertexDeclaration: {
  58622. name: string;
  58623. shader: string;
  58624. };
  58625. }
  58626. // Mixins
  58627. interface Window {
  58628. mozIndexedDB: IDBFactory;
  58629. webkitIndexedDB: IDBFactory;
  58630. msIndexedDB: IDBFactory;
  58631. webkitURL: typeof URL;
  58632. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58633. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58634. WebGLRenderingContext: WebGLRenderingContext;
  58635. MSGesture: MSGesture;
  58636. CANNON: any;
  58637. AudioContext: AudioContext;
  58638. webkitAudioContext: AudioContext;
  58639. PointerEvent: any;
  58640. Math: Math;
  58641. Uint8Array: Uint8ArrayConstructor;
  58642. Float32Array: Float32ArrayConstructor;
  58643. mozURL: typeof URL;
  58644. msURL: typeof URL;
  58645. VRFrameData: any; // WebVR, from specs 1.1
  58646. DracoDecoderModule: any;
  58647. setImmediate(handler: (...args: any[]) => void): number;
  58648. }
  58649. interface HTMLCanvasElement {
  58650. requestPointerLock(): void;
  58651. msRequestPointerLock?(): void;
  58652. mozRequestPointerLock?(): void;
  58653. webkitRequestPointerLock?(): void;
  58654. /** Track wether a record is in progress */
  58655. isRecording: boolean;
  58656. /** Capture Stream method defined by some browsers */
  58657. captureStream(fps?: number): MediaStream;
  58658. }
  58659. interface CanvasRenderingContext2D {
  58660. msImageSmoothingEnabled: boolean;
  58661. }
  58662. interface MouseEvent {
  58663. mozMovementX: number;
  58664. mozMovementY: number;
  58665. webkitMovementX: number;
  58666. webkitMovementY: number;
  58667. msMovementX: number;
  58668. msMovementY: number;
  58669. }
  58670. interface Navigator {
  58671. mozGetVRDevices: (any: any) => any;
  58672. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58673. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58674. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58675. webkitGetGamepads(): Gamepad[];
  58676. msGetGamepads(): Gamepad[];
  58677. webkitGamepads(): Gamepad[];
  58678. }
  58679. interface HTMLVideoElement {
  58680. mozSrcObject: any;
  58681. }
  58682. interface Math {
  58683. fround(x: number): number;
  58684. imul(a: number, b: number): number;
  58685. }
  58686. interface WebGLProgram {
  58687. context?: WebGLRenderingContext;
  58688. vertexShader?: WebGLShader;
  58689. fragmentShader?: WebGLShader;
  58690. isParallelCompiled: boolean;
  58691. onCompiled?: () => void;
  58692. }
  58693. interface WebGLRenderingContext {
  58694. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58695. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58696. vertexAttribDivisor(index: number, divisor: number): void;
  58697. createVertexArray(): any;
  58698. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58699. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58700. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58701. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58702. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58703. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58704. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58705. // Queries
  58706. createQuery(): WebGLQuery;
  58707. deleteQuery(query: WebGLQuery): void;
  58708. beginQuery(target: number, query: WebGLQuery): void;
  58709. endQuery(target: number): void;
  58710. getQueryParameter(query: WebGLQuery, pname: number): any;
  58711. getQuery(target: number, pname: number): any;
  58712. MAX_SAMPLES: number;
  58713. RGBA8: number;
  58714. READ_FRAMEBUFFER: number;
  58715. DRAW_FRAMEBUFFER: number;
  58716. UNIFORM_BUFFER: number;
  58717. HALF_FLOAT_OES: number;
  58718. RGBA16F: number;
  58719. RGBA32F: number;
  58720. R32F: number;
  58721. RG32F: number;
  58722. RGB32F: number;
  58723. R16F: number;
  58724. RG16F: number;
  58725. RGB16F: number;
  58726. RED: number;
  58727. RG: number;
  58728. R8: number;
  58729. RG8: number;
  58730. UNSIGNED_INT_24_8: number;
  58731. DEPTH24_STENCIL8: number;
  58732. /* Multiple Render Targets */
  58733. drawBuffers(buffers: number[]): void;
  58734. readBuffer(src: number): void;
  58735. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58736. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58737. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58738. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58739. // Occlusion Query
  58740. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58741. ANY_SAMPLES_PASSED: number;
  58742. QUERY_RESULT_AVAILABLE: number;
  58743. QUERY_RESULT: number;
  58744. }
  58745. interface WebGLBuffer {
  58746. references: number;
  58747. capacity: number;
  58748. is32Bits: boolean;
  58749. }
  58750. interface WebGLProgram {
  58751. transformFeedback?: WebGLTransformFeedback | null;
  58752. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58753. }
  58754. interface EXT_disjoint_timer_query {
  58755. QUERY_COUNTER_BITS_EXT: number;
  58756. TIME_ELAPSED_EXT: number;
  58757. TIMESTAMP_EXT: number;
  58758. GPU_DISJOINT_EXT: number;
  58759. QUERY_RESULT_EXT: number;
  58760. QUERY_RESULT_AVAILABLE_EXT: number;
  58761. queryCounterEXT(query: WebGLQuery, target: number): void;
  58762. createQueryEXT(): WebGLQuery;
  58763. beginQueryEXT(target: number, query: WebGLQuery): void;
  58764. endQueryEXT(target: number): void;
  58765. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58766. deleteQueryEXT(query: WebGLQuery): void;
  58767. }
  58768. interface WebGLUniformLocation {
  58769. _currentState: any;
  58770. }
  58771. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58772. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58773. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58774. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58775. interface WebGLRenderingContext {
  58776. readonly RASTERIZER_DISCARD: number;
  58777. readonly DEPTH_COMPONENT24: number;
  58778. readonly TEXTURE_3D: number;
  58779. readonly TEXTURE_2D_ARRAY: number;
  58780. readonly TEXTURE_COMPARE_FUNC: number;
  58781. readonly TEXTURE_COMPARE_MODE: number;
  58782. readonly COMPARE_REF_TO_TEXTURE: number;
  58783. readonly TEXTURE_WRAP_R: number;
  58784. readonly HALF_FLOAT: number;
  58785. readonly RGB8: number;
  58786. readonly RED_INTEGER: number;
  58787. readonly RG_INTEGER: number;
  58788. readonly RGB_INTEGER: number;
  58789. readonly RGBA_INTEGER: number;
  58790. readonly R8_SNORM: number;
  58791. readonly RG8_SNORM: number;
  58792. readonly RGB8_SNORM: number;
  58793. readonly RGBA8_SNORM: number;
  58794. readonly R8I: number;
  58795. readonly RG8I: number;
  58796. readonly RGB8I: number;
  58797. readonly RGBA8I: number;
  58798. readonly R8UI: number;
  58799. readonly RG8UI: number;
  58800. readonly RGB8UI: number;
  58801. readonly RGBA8UI: number;
  58802. readonly R16I: number;
  58803. readonly RG16I: number;
  58804. readonly RGB16I: number;
  58805. readonly RGBA16I: number;
  58806. readonly R16UI: number;
  58807. readonly RG16UI: number;
  58808. readonly RGB16UI: number;
  58809. readonly RGBA16UI: number;
  58810. readonly R32I: number;
  58811. readonly RG32I: number;
  58812. readonly RGB32I: number;
  58813. readonly RGBA32I: number;
  58814. readonly R32UI: number;
  58815. readonly RG32UI: number;
  58816. readonly RGB32UI: number;
  58817. readonly RGBA32UI: number;
  58818. readonly RGB10_A2UI: number;
  58819. readonly R11F_G11F_B10F: number;
  58820. readonly RGB9_E5: number;
  58821. readonly RGB10_A2: number;
  58822. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58823. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58824. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58825. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58826. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58827. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58828. 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;
  58829. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58830. readonly TRANSFORM_FEEDBACK: number;
  58831. readonly INTERLEAVED_ATTRIBS: number;
  58832. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58833. createTransformFeedback(): WebGLTransformFeedback;
  58834. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58835. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58836. beginTransformFeedback(primitiveMode: number): void;
  58837. endTransformFeedback(): void;
  58838. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58839. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58840. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58841. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58842. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58843. }
  58844. interface ImageBitmap {
  58845. readonly width: number;
  58846. readonly height: number;
  58847. close(): void;
  58848. }
  58849. interface WebGLQuery extends WebGLObject {
  58850. }
  58851. declare var WebGLQuery: {
  58852. prototype: WebGLQuery;
  58853. new(): WebGLQuery;
  58854. };
  58855. interface WebGLSampler extends WebGLObject {
  58856. }
  58857. declare var WebGLSampler: {
  58858. prototype: WebGLSampler;
  58859. new(): WebGLSampler;
  58860. };
  58861. interface WebGLSync extends WebGLObject {
  58862. }
  58863. declare var WebGLSync: {
  58864. prototype: WebGLSync;
  58865. new(): WebGLSync;
  58866. };
  58867. interface WebGLTransformFeedback extends WebGLObject {
  58868. }
  58869. declare var WebGLTransformFeedback: {
  58870. prototype: WebGLTransformFeedback;
  58871. new(): WebGLTransformFeedback;
  58872. };
  58873. interface WebGLVertexArrayObject extends WebGLObject {
  58874. }
  58875. declare var WebGLVertexArrayObject: {
  58876. prototype: WebGLVertexArrayObject;
  58877. new(): WebGLVertexArrayObject;
  58878. };
  58879. // Type definitions for WebVR API
  58880. // Project: https://w3c.github.io/webvr/
  58881. // Definitions by: six a <https://github.com/lostfictions>
  58882. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58883. interface VRDisplay extends EventTarget {
  58884. /**
  58885. * Dictionary of capabilities describing the VRDisplay.
  58886. */
  58887. readonly capabilities: VRDisplayCapabilities;
  58888. /**
  58889. * z-depth defining the far plane of the eye view frustum
  58890. * enables mapping of values in the render target depth
  58891. * attachment to scene coordinates. Initially set to 10000.0.
  58892. */
  58893. depthFar: number;
  58894. /**
  58895. * z-depth defining the near plane of the eye view frustum
  58896. * enables mapping of values in the render target depth
  58897. * attachment to scene coordinates. Initially set to 0.01.
  58898. */
  58899. depthNear: number;
  58900. /**
  58901. * An identifier for this distinct VRDisplay. Used as an
  58902. * association point in the Gamepad API.
  58903. */
  58904. readonly displayId: number;
  58905. /**
  58906. * A display name, a user-readable name identifying it.
  58907. */
  58908. readonly displayName: string;
  58909. readonly isConnected: boolean;
  58910. readonly isPresenting: boolean;
  58911. /**
  58912. * If this VRDisplay supports room-scale experiences, the optional
  58913. * stage attribute contains details on the room-scale parameters.
  58914. */
  58915. readonly stageParameters: VRStageParameters | null;
  58916. /**
  58917. * Passing the value returned by `requestAnimationFrame` to
  58918. * `cancelAnimationFrame` will unregister the callback.
  58919. * @param handle Define the hanle of the request to cancel
  58920. */
  58921. cancelAnimationFrame(handle: number): void;
  58922. /**
  58923. * Stops presenting to the VRDisplay.
  58924. * @returns a promise to know when it stopped
  58925. */
  58926. exitPresent(): Promise<void>;
  58927. /**
  58928. * Return the current VREyeParameters for the given eye.
  58929. * @param whichEye Define the eye we want the parameter for
  58930. * @returns the eye parameters
  58931. */
  58932. getEyeParameters(whichEye: string): VREyeParameters;
  58933. /**
  58934. * Populates the passed VRFrameData with the information required to render
  58935. * the current frame.
  58936. * @param frameData Define the data structure to populate
  58937. * @returns true if ok otherwise false
  58938. */
  58939. getFrameData(frameData: VRFrameData): boolean;
  58940. /**
  58941. * Get the layers currently being presented.
  58942. * @returns the list of VR layers
  58943. */
  58944. getLayers(): VRLayer[];
  58945. /**
  58946. * Return a VRPose containing the future predicted pose of the VRDisplay
  58947. * when the current frame will be presented. The value returned will not
  58948. * change until JavaScript has returned control to the browser.
  58949. *
  58950. * The VRPose will contain the position, orientation, velocity,
  58951. * and acceleration of each of these properties.
  58952. * @returns the pose object
  58953. */
  58954. getPose(): VRPose;
  58955. /**
  58956. * Return the current instantaneous pose of the VRDisplay, with no
  58957. * prediction applied.
  58958. * @returns the current instantaneous pose
  58959. */
  58960. getImmediatePose(): VRPose;
  58961. /**
  58962. * The callback passed to `requestAnimationFrame` will be called
  58963. * any time a new frame should be rendered. When the VRDisplay is
  58964. * presenting the callback will be called at the native refresh
  58965. * rate of the HMD. When not presenting this function acts
  58966. * identically to how window.requestAnimationFrame acts. Content should
  58967. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58968. * asynchronously from other displays and at differing refresh rates.
  58969. * @param callback Define the eaction to run next frame
  58970. * @returns the request handle it
  58971. */
  58972. requestAnimationFrame(callback: FrameRequestCallback): number;
  58973. /**
  58974. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58975. * Repeat calls while already presenting will update the VRLayers being displayed.
  58976. * @param layers Define the list of layer to present
  58977. * @returns a promise to know when the request has been fulfilled
  58978. */
  58979. requestPresent(layers: VRLayer[]): Promise<void>;
  58980. /**
  58981. * Reset the pose for this display, treating its current position and
  58982. * orientation as the "origin/zero" values. VRPose.position,
  58983. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58984. * updated when calling resetPose(). This should be called in only
  58985. * sitting-space experiences.
  58986. */
  58987. resetPose(): void;
  58988. /**
  58989. * The VRLayer provided to the VRDisplay will be captured and presented
  58990. * in the HMD. Calling this function has the same effect on the source
  58991. * canvas as any other operation that uses its source image, and canvases
  58992. * created without preserveDrawingBuffer set to true will be cleared.
  58993. * @param pose Define the pose to submit
  58994. */
  58995. submitFrame(pose?: VRPose): void;
  58996. }
  58997. declare var VRDisplay: {
  58998. prototype: VRDisplay;
  58999. new(): VRDisplay;
  59000. };
  59001. interface VRLayer {
  59002. leftBounds?: number[] | Float32Array | null;
  59003. rightBounds?: number[] | Float32Array | null;
  59004. source?: HTMLCanvasElement | null;
  59005. }
  59006. interface VRDisplayCapabilities {
  59007. readonly canPresent: boolean;
  59008. readonly hasExternalDisplay: boolean;
  59009. readonly hasOrientation: boolean;
  59010. readonly hasPosition: boolean;
  59011. readonly maxLayers: number;
  59012. }
  59013. interface VREyeParameters {
  59014. /** @deprecated */
  59015. readonly fieldOfView: VRFieldOfView;
  59016. readonly offset: Float32Array;
  59017. readonly renderHeight: number;
  59018. readonly renderWidth: number;
  59019. }
  59020. interface VRFieldOfView {
  59021. readonly downDegrees: number;
  59022. readonly leftDegrees: number;
  59023. readonly rightDegrees: number;
  59024. readonly upDegrees: number;
  59025. }
  59026. interface VRFrameData {
  59027. readonly leftProjectionMatrix: Float32Array;
  59028. readonly leftViewMatrix: Float32Array;
  59029. readonly pose: VRPose;
  59030. readonly rightProjectionMatrix: Float32Array;
  59031. readonly rightViewMatrix: Float32Array;
  59032. readonly timestamp: number;
  59033. }
  59034. interface VRPose {
  59035. readonly angularAcceleration: Float32Array | null;
  59036. readonly angularVelocity: Float32Array | null;
  59037. readonly linearAcceleration: Float32Array | null;
  59038. readonly linearVelocity: Float32Array | null;
  59039. readonly orientation: Float32Array | null;
  59040. readonly position: Float32Array | null;
  59041. readonly timestamp: number;
  59042. }
  59043. interface VRStageParameters {
  59044. sittingToStandingTransform?: Float32Array;
  59045. sizeX?: number;
  59046. sizeY?: number;
  59047. }
  59048. interface Navigator {
  59049. getVRDisplays(): Promise<VRDisplay[]>;
  59050. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59051. }
  59052. interface Window {
  59053. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59054. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59055. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59056. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59057. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59058. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59059. }
  59060. interface Gamepad {
  59061. readonly displayId: number;
  59062. }
  59063. interface XRDevice {
  59064. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59065. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59066. }
  59067. interface XRSession {
  59068. getInputSources(): Array<any>;
  59069. baseLayer: XRWebGLLayer;
  59070. requestFrameOfReference(type: string): Promise<void>;
  59071. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59072. end(): Promise<void>;
  59073. requestAnimationFrame: Function;
  59074. addEventListener: Function;
  59075. }
  59076. interface XRSessionCreationOptions {
  59077. outputContext?: WebGLRenderingContext | null;
  59078. immersive?: boolean;
  59079. environmentIntegration?: boolean;
  59080. }
  59081. interface XRLayer {
  59082. getViewport: Function;
  59083. framebufferWidth: number;
  59084. framebufferHeight: number;
  59085. }
  59086. interface XRView {
  59087. projectionMatrix: Float32Array;
  59088. }
  59089. interface XRFrame {
  59090. getDevicePose: Function;
  59091. getInputPose: Function;
  59092. views: Array<XRView>;
  59093. baseLayer: XRLayer;
  59094. }
  59095. interface XRFrameOfReference {
  59096. }
  59097. interface XRWebGLLayer extends XRLayer {
  59098. framebuffer: WebGLFramebuffer;
  59099. }
  59100. declare var XRWebGLLayer: {
  59101. prototype: XRWebGLLayer;
  59102. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59103. };
  59104. declare module "babylonjs" {
  59105. export * from "babylonjs/Legacy/legacy";
  59106. }
  59107. declare module BABYLON {
  59108. /** Alias type for value that can be null */
  59109. export type Nullable<T> = T | null;
  59110. /**
  59111. * Alias type for number that are floats
  59112. * @ignorenaming
  59113. */
  59114. export type float = number;
  59115. /**
  59116. * Alias type for number that are doubles.
  59117. * @ignorenaming
  59118. */
  59119. export type double = number;
  59120. /**
  59121. * Alias type for number that are integer
  59122. * @ignorenaming
  59123. */
  59124. export type int = number;
  59125. /** Alias type for number array or Float32Array */
  59126. export type FloatArray = number[] | Float32Array;
  59127. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59128. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59129. /**
  59130. * Alias for types that can be used by a Buffer or VertexBuffer.
  59131. */
  59132. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59133. /**
  59134. * Alias type for primitive types
  59135. * @ignorenaming
  59136. */
  59137. type Primitive = undefined | null | boolean | string | number | Function;
  59138. /**
  59139. * Type modifier to make all the properties of an object Readonly
  59140. */
  59141. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59142. /**
  59143. * Type modifier to make all the properties of an object Readonly recursively
  59144. */
  59145. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59146. /** @hidden */
  59147. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59148. }
  59149. /** @hidden */
  59150. /** @hidden */
  59151. type DeepImmutableObject<T> = {
  59152. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59153. };
  59154. }
  59155. declare module BABYLON {
  59156. /**
  59157. * Class containing a set of static utilities functions for arrays.
  59158. */
  59159. export class ArrayTools {
  59160. /**
  59161. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59162. * @param size the number of element to construct and put in the array
  59163. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59164. * @returns a new array filled with new objects
  59165. */
  59166. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59167. }
  59168. }
  59169. declare module BABYLON {
  59170. /**
  59171. * Scalar computation library
  59172. */
  59173. export class Scalar {
  59174. /**
  59175. * Two pi constants convenient for computation.
  59176. */
  59177. static TwoPi: number;
  59178. /**
  59179. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59180. * @param a number
  59181. * @param b number
  59182. * @param epsilon (default = 1.401298E-45)
  59183. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59184. */
  59185. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59186. /**
  59187. * Returns a string : the upper case translation of the number i to hexadecimal.
  59188. * @param i number
  59189. * @returns the upper case translation of the number i to hexadecimal.
  59190. */
  59191. static ToHex(i: number): string;
  59192. /**
  59193. * Returns -1 if value is negative and +1 is value is positive.
  59194. * @param value the value
  59195. * @returns the value itself if it's equal to zero.
  59196. */
  59197. static Sign(value: number): number;
  59198. /**
  59199. * Returns the value itself if it's between min and max.
  59200. * Returns min if the value is lower than min.
  59201. * Returns max if the value is greater than max.
  59202. * @param value the value to clmap
  59203. * @param min the min value to clamp to (default: 0)
  59204. * @param max the max value to clamp to (default: 1)
  59205. * @returns the clamped value
  59206. */
  59207. static Clamp(value: number, min?: number, max?: number): number;
  59208. /**
  59209. * the log2 of value.
  59210. * @param value the value to compute log2 of
  59211. * @returns the log2 of value.
  59212. */
  59213. static Log2(value: number): number;
  59214. /**
  59215. * Loops the value, so that it is never larger than length and never smaller than 0.
  59216. *
  59217. * This is similar to the modulo operator but it works with floating point numbers.
  59218. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59219. * With t = 5 and length = 2.5, the result would be 0.0.
  59220. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59221. * @param value the value
  59222. * @param length the length
  59223. * @returns the looped value
  59224. */
  59225. static Repeat(value: number, length: number): number;
  59226. /**
  59227. * Normalize the value between 0.0 and 1.0 using min and max values
  59228. * @param value value to normalize
  59229. * @param min max to normalize between
  59230. * @param max min to normalize between
  59231. * @returns the normalized value
  59232. */
  59233. static Normalize(value: number, min: number, max: number): number;
  59234. /**
  59235. * Denormalize the value from 0.0 and 1.0 using min and max values
  59236. * @param normalized value to denormalize
  59237. * @param min max to denormalize between
  59238. * @param max min to denormalize between
  59239. * @returns the denormalized value
  59240. */
  59241. static Denormalize(normalized: number, min: number, max: number): number;
  59242. /**
  59243. * Calculates the shortest difference between two given angles given in degrees.
  59244. * @param current current angle in degrees
  59245. * @param target target angle in degrees
  59246. * @returns the delta
  59247. */
  59248. static DeltaAngle(current: number, target: number): number;
  59249. /**
  59250. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59251. * @param tx value
  59252. * @param length length
  59253. * @returns The returned value will move back and forth between 0 and length
  59254. */
  59255. static PingPong(tx: number, length: number): number;
  59256. /**
  59257. * Interpolates between min and max with smoothing at the limits.
  59258. *
  59259. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59260. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59261. * @param from from
  59262. * @param to to
  59263. * @param tx value
  59264. * @returns the smooth stepped value
  59265. */
  59266. static SmoothStep(from: number, to: number, tx: number): number;
  59267. /**
  59268. * Moves a value current towards target.
  59269. *
  59270. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59271. * Negative values of maxDelta pushes the value away from target.
  59272. * @param current current value
  59273. * @param target target value
  59274. * @param maxDelta max distance to move
  59275. * @returns resulting value
  59276. */
  59277. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59278. /**
  59279. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59280. *
  59281. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59282. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59283. * @param current current value
  59284. * @param target target value
  59285. * @param maxDelta max distance to move
  59286. * @returns resulting angle
  59287. */
  59288. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59289. /**
  59290. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59291. * @param start start value
  59292. * @param end target value
  59293. * @param amount amount to lerp between
  59294. * @returns the lerped value
  59295. */
  59296. static Lerp(start: number, end: number, amount: number): number;
  59297. /**
  59298. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59299. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59300. * @param start start value
  59301. * @param end target value
  59302. * @param amount amount to lerp between
  59303. * @returns the lerped value
  59304. */
  59305. static LerpAngle(start: number, end: number, amount: number): number;
  59306. /**
  59307. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59308. * @param a start value
  59309. * @param b target value
  59310. * @param value value between a and b
  59311. * @returns the inverseLerp value
  59312. */
  59313. static InverseLerp(a: number, b: number, value: number): number;
  59314. /**
  59315. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59316. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59317. * @param value1 spline value
  59318. * @param tangent1 spline value
  59319. * @param value2 spline value
  59320. * @param tangent2 spline value
  59321. * @param amount input value
  59322. * @returns hermite result
  59323. */
  59324. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59325. /**
  59326. * Returns a random float number between and min and max values
  59327. * @param min min value of random
  59328. * @param max max value of random
  59329. * @returns random value
  59330. */
  59331. static RandomRange(min: number, max: number): number;
  59332. /**
  59333. * This function returns percentage of a number in a given range.
  59334. *
  59335. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59336. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59337. * @param number to convert to percentage
  59338. * @param min min range
  59339. * @param max max range
  59340. * @returns the percentage
  59341. */
  59342. static RangeToPercent(number: number, min: number, max: number): number;
  59343. /**
  59344. * This function returns number that corresponds to the percentage in a given range.
  59345. *
  59346. * PercentToRange(0.34,0,100) will return 34.
  59347. * @param percent to convert to number
  59348. * @param min min range
  59349. * @param max max range
  59350. * @returns the number
  59351. */
  59352. static PercentToRange(percent: number, min: number, max: number): number;
  59353. /**
  59354. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59355. * @param angle The angle to normalize in radian.
  59356. * @return The converted angle.
  59357. */
  59358. static NormalizeRadians(angle: number): number;
  59359. }
  59360. }
  59361. declare module BABYLON {
  59362. /**
  59363. * Constant used to convert a value to gamma space
  59364. * @ignorenaming
  59365. */
  59366. export const ToGammaSpace: number;
  59367. /**
  59368. * Constant used to convert a value to linear space
  59369. * @ignorenaming
  59370. */
  59371. export const ToLinearSpace = 2.2;
  59372. /**
  59373. * Constant used to define the minimal number value in Babylon.js
  59374. * @ignorenaming
  59375. */
  59376. export const Epsilon = 0.001;
  59377. /**
  59378. * Class used to hold a RBG color
  59379. */
  59380. export class Color3 {
  59381. /**
  59382. * Defines the red component (between 0 and 1, default is 0)
  59383. */
  59384. r: number;
  59385. /**
  59386. * Defines the green component (between 0 and 1, default is 0)
  59387. */
  59388. g: number;
  59389. /**
  59390. * Defines the blue component (between 0 and 1, default is 0)
  59391. */
  59392. b: number;
  59393. /**
  59394. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59395. * @param r defines the red component (between 0 and 1, default is 0)
  59396. * @param g defines the green component (between 0 and 1, default is 0)
  59397. * @param b defines the blue component (between 0 and 1, default is 0)
  59398. */
  59399. constructor(
  59400. /**
  59401. * Defines the red component (between 0 and 1, default is 0)
  59402. */
  59403. r?: number,
  59404. /**
  59405. * Defines the green component (between 0 and 1, default is 0)
  59406. */
  59407. g?: number,
  59408. /**
  59409. * Defines the blue component (between 0 and 1, default is 0)
  59410. */
  59411. b?: number);
  59412. /**
  59413. * Creates a string with the Color3 current values
  59414. * @returns the string representation of the Color3 object
  59415. */
  59416. toString(): string;
  59417. /**
  59418. * Returns the string "Color3"
  59419. * @returns "Color3"
  59420. */
  59421. getClassName(): string;
  59422. /**
  59423. * Compute the Color3 hash code
  59424. * @returns an unique number that can be used to hash Color3 objects
  59425. */
  59426. getHashCode(): number;
  59427. /**
  59428. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59429. * @param array defines the array where to store the r,g,b components
  59430. * @param index defines an optional index in the target array to define where to start storing values
  59431. * @returns the current Color3 object
  59432. */
  59433. toArray(array: FloatArray, index?: number): Color3;
  59434. /**
  59435. * Returns a new Color4 object from the current Color3 and the given alpha
  59436. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59437. * @returns a new Color4 object
  59438. */
  59439. toColor4(alpha?: number): Color4;
  59440. /**
  59441. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59442. * @returns the new array
  59443. */
  59444. asArray(): number[];
  59445. /**
  59446. * Returns the luminance value
  59447. * @returns a float value
  59448. */
  59449. toLuminance(): number;
  59450. /**
  59451. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59452. * @param otherColor defines the second operand
  59453. * @returns the new Color3 object
  59454. */
  59455. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59456. /**
  59457. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59458. * @param otherColor defines the second operand
  59459. * @param result defines the Color3 object where to store the result
  59460. * @returns the current Color3
  59461. */
  59462. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59463. /**
  59464. * Determines equality between Color3 objects
  59465. * @param otherColor defines the second operand
  59466. * @returns true if the rgb values are equal to the given ones
  59467. */
  59468. equals(otherColor: DeepImmutable<Color3>): boolean;
  59469. /**
  59470. * Determines equality between the current Color3 object and a set of r,b,g values
  59471. * @param r defines the red component to check
  59472. * @param g defines the green component to check
  59473. * @param b defines the blue component to check
  59474. * @returns true if the rgb values are equal to the given ones
  59475. */
  59476. equalsFloats(r: number, g: number, b: number): boolean;
  59477. /**
  59478. * Multiplies in place each rgb value by scale
  59479. * @param scale defines the scaling factor
  59480. * @returns the updated Color3
  59481. */
  59482. scale(scale: number): Color3;
  59483. /**
  59484. * Multiplies the rgb values by scale and stores the result into "result"
  59485. * @param scale defines the scaling factor
  59486. * @param result defines the Color3 object where to store the result
  59487. * @returns the unmodified current Color3
  59488. */
  59489. scaleToRef(scale: number, result: Color3): Color3;
  59490. /**
  59491. * Scale the current Color3 values by a factor and add the result to a given Color3
  59492. * @param scale defines the scale factor
  59493. * @param result defines color to store the result into
  59494. * @returns the unmodified current Color3
  59495. */
  59496. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59497. /**
  59498. * Clamps the rgb values by the min and max values and stores the result into "result"
  59499. * @param min defines minimum clamping value (default is 0)
  59500. * @param max defines maximum clamping value (default is 1)
  59501. * @param result defines color to store the result into
  59502. * @returns the original Color3
  59503. */
  59504. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59505. /**
  59506. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59507. * @param otherColor defines the second operand
  59508. * @returns the new Color3
  59509. */
  59510. add(otherColor: DeepImmutable<Color3>): Color3;
  59511. /**
  59512. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59513. * @param otherColor defines the second operand
  59514. * @param result defines Color3 object to store the result into
  59515. * @returns the unmodified current Color3
  59516. */
  59517. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59518. /**
  59519. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59520. * @param otherColor defines the second operand
  59521. * @returns the new Color3
  59522. */
  59523. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59524. /**
  59525. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59526. * @param otherColor defines the second operand
  59527. * @param result defines Color3 object to store the result into
  59528. * @returns the unmodified current Color3
  59529. */
  59530. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59531. /**
  59532. * Copy the current object
  59533. * @returns a new Color3 copied the current one
  59534. */
  59535. clone(): Color3;
  59536. /**
  59537. * Copies the rgb values from the source in the current Color3
  59538. * @param source defines the source Color3 object
  59539. * @returns the updated Color3 object
  59540. */
  59541. copyFrom(source: DeepImmutable<Color3>): Color3;
  59542. /**
  59543. * Updates the Color3 rgb values from the given floats
  59544. * @param r defines the red component to read from
  59545. * @param g defines the green component to read from
  59546. * @param b defines the blue component to read from
  59547. * @returns the current Color3 object
  59548. */
  59549. copyFromFloats(r: number, g: number, b: number): Color3;
  59550. /**
  59551. * Updates the Color3 rgb values from the given floats
  59552. * @param r defines the red component to read from
  59553. * @param g defines the green component to read from
  59554. * @param b defines the blue component to read from
  59555. * @returns the current Color3 object
  59556. */
  59557. set(r: number, g: number, b: number): Color3;
  59558. /**
  59559. * Compute the Color3 hexadecimal code as a string
  59560. * @returns a string containing the hexadecimal representation of the Color3 object
  59561. */
  59562. toHexString(): string;
  59563. /**
  59564. * Computes a new Color3 converted from the current one to linear space
  59565. * @returns a new Color3 object
  59566. */
  59567. toLinearSpace(): Color3;
  59568. /**
  59569. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59570. * @param convertedColor defines the Color3 object where to store the linear space version
  59571. * @returns the unmodified Color3
  59572. */
  59573. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59574. /**
  59575. * Computes a new Color3 converted from the current one to gamma space
  59576. * @returns a new Color3 object
  59577. */
  59578. toGammaSpace(): Color3;
  59579. /**
  59580. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59581. * @param convertedColor defines the Color3 object where to store the gamma space version
  59582. * @returns the unmodified Color3
  59583. */
  59584. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59585. private static _BlackReadOnly;
  59586. /**
  59587. * Creates a new Color3 from the string containing valid hexadecimal values
  59588. * @param hex defines a string containing valid hexadecimal values
  59589. * @returns a new Color3 object
  59590. */
  59591. static FromHexString(hex: string): Color3;
  59592. /**
  59593. * Creates a new Vector3 from the starting index of the given array
  59594. * @param array defines the source array
  59595. * @param offset defines an offset in the source array
  59596. * @returns a new Color3 object
  59597. */
  59598. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59599. /**
  59600. * Creates a new Color3 from integer values (< 256)
  59601. * @param r defines the red component to read from (value between 0 and 255)
  59602. * @param g defines the green component to read from (value between 0 and 255)
  59603. * @param b defines the blue component to read from (value between 0 and 255)
  59604. * @returns a new Color3 object
  59605. */
  59606. static FromInts(r: number, g: number, b: number): Color3;
  59607. /**
  59608. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59609. * @param start defines the start Color3 value
  59610. * @param end defines the end Color3 value
  59611. * @param amount defines the gradient value between start and end
  59612. * @returns a new Color3 object
  59613. */
  59614. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59615. /**
  59616. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59617. * @param left defines the start value
  59618. * @param right defines the end value
  59619. * @param amount defines the gradient factor
  59620. * @param result defines the Color3 object where to store the result
  59621. */
  59622. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59623. /**
  59624. * Returns a Color3 value containing a red color
  59625. * @returns a new Color3 object
  59626. */
  59627. static Red(): Color3;
  59628. /**
  59629. * Returns a Color3 value containing a green color
  59630. * @returns a new Color3 object
  59631. */
  59632. static Green(): Color3;
  59633. /**
  59634. * Returns a Color3 value containing a blue color
  59635. * @returns a new Color3 object
  59636. */
  59637. static Blue(): Color3;
  59638. /**
  59639. * Returns a Color3 value containing a black color
  59640. * @returns a new Color3 object
  59641. */
  59642. static Black(): Color3;
  59643. /**
  59644. * Gets a Color3 value containing a black color that must not be updated
  59645. */
  59646. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59647. /**
  59648. * Returns a Color3 value containing a white color
  59649. * @returns a new Color3 object
  59650. */
  59651. static White(): Color3;
  59652. /**
  59653. * Returns a Color3 value containing a purple color
  59654. * @returns a new Color3 object
  59655. */
  59656. static Purple(): Color3;
  59657. /**
  59658. * Returns a Color3 value containing a magenta color
  59659. * @returns a new Color3 object
  59660. */
  59661. static Magenta(): Color3;
  59662. /**
  59663. * Returns a Color3 value containing a yellow color
  59664. * @returns a new Color3 object
  59665. */
  59666. static Yellow(): Color3;
  59667. /**
  59668. * Returns a Color3 value containing a gray color
  59669. * @returns a new Color3 object
  59670. */
  59671. static Gray(): Color3;
  59672. /**
  59673. * Returns a Color3 value containing a teal color
  59674. * @returns a new Color3 object
  59675. */
  59676. static Teal(): Color3;
  59677. /**
  59678. * Returns a Color3 value containing a random color
  59679. * @returns a new Color3 object
  59680. */
  59681. static Random(): Color3;
  59682. }
  59683. /**
  59684. * Class used to hold a RBGA color
  59685. */
  59686. export class Color4 {
  59687. /**
  59688. * Defines the red component (between 0 and 1, default is 0)
  59689. */
  59690. r: number;
  59691. /**
  59692. * Defines the green component (between 0 and 1, default is 0)
  59693. */
  59694. g: number;
  59695. /**
  59696. * Defines the blue component (between 0 and 1, default is 0)
  59697. */
  59698. b: number;
  59699. /**
  59700. * Defines the alpha component (between 0 and 1, default is 1)
  59701. */
  59702. a: number;
  59703. /**
  59704. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59705. * @param r defines the red component (between 0 and 1, default is 0)
  59706. * @param g defines the green component (between 0 and 1, default is 0)
  59707. * @param b defines the blue component (between 0 and 1, default is 0)
  59708. * @param a defines the alpha component (between 0 and 1, default is 1)
  59709. */
  59710. constructor(
  59711. /**
  59712. * Defines the red component (between 0 and 1, default is 0)
  59713. */
  59714. r?: number,
  59715. /**
  59716. * Defines the green component (between 0 and 1, default is 0)
  59717. */
  59718. g?: number,
  59719. /**
  59720. * Defines the blue component (between 0 and 1, default is 0)
  59721. */
  59722. b?: number,
  59723. /**
  59724. * Defines the alpha component (between 0 and 1, default is 1)
  59725. */
  59726. a?: number);
  59727. /**
  59728. * Adds in place the given Color4 values to the current Color4 object
  59729. * @param right defines the second operand
  59730. * @returns the current updated Color4 object
  59731. */
  59732. addInPlace(right: DeepImmutable<Color4>): Color4;
  59733. /**
  59734. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59735. * @returns the new array
  59736. */
  59737. asArray(): number[];
  59738. /**
  59739. * Stores from the starting index in the given array the Color4 successive values
  59740. * @param array defines the array where to store the r,g,b components
  59741. * @param index defines an optional index in the target array to define where to start storing values
  59742. * @returns the current Color4 object
  59743. */
  59744. toArray(array: number[], index?: number): Color4;
  59745. /**
  59746. * Determines equality between Color4 objects
  59747. * @param otherColor defines the second operand
  59748. * @returns true if the rgba values are equal to the given ones
  59749. */
  59750. equals(otherColor: DeepImmutable<Color4>): boolean;
  59751. /**
  59752. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59753. * @param right defines the second operand
  59754. * @returns a new Color4 object
  59755. */
  59756. add(right: DeepImmutable<Color4>): Color4;
  59757. /**
  59758. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59759. * @param right defines the second operand
  59760. * @returns a new Color4 object
  59761. */
  59762. subtract(right: DeepImmutable<Color4>): Color4;
  59763. /**
  59764. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59765. * @param right defines the second operand
  59766. * @param result defines the Color4 object where to store the result
  59767. * @returns the current Color4 object
  59768. */
  59769. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59770. /**
  59771. * Creates a new Color4 with the current Color4 values multiplied by scale
  59772. * @param scale defines the scaling factor to apply
  59773. * @returns a new Color4 object
  59774. */
  59775. scale(scale: number): Color4;
  59776. /**
  59777. * Multiplies the current Color4 values by scale and stores the result in "result"
  59778. * @param scale defines the scaling factor to apply
  59779. * @param result defines the Color4 object where to store the result
  59780. * @returns the current unmodified Color4
  59781. */
  59782. scaleToRef(scale: number, result: Color4): Color4;
  59783. /**
  59784. * Scale the current Color4 values by a factor and add the result to a given Color4
  59785. * @param scale defines the scale factor
  59786. * @param result defines the Color4 object where to store the result
  59787. * @returns the unmodified current Color4
  59788. */
  59789. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59790. /**
  59791. * Clamps the rgb values by the min and max values and stores the result into "result"
  59792. * @param min defines minimum clamping value (default is 0)
  59793. * @param max defines maximum clamping value (default is 1)
  59794. * @param result defines color to store the result into.
  59795. * @returns the cuurent Color4
  59796. */
  59797. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59798. /**
  59799. * Multipy an Color4 value by another and return a new Color4 object
  59800. * @param color defines the Color4 value to multiply by
  59801. * @returns a new Color4 object
  59802. */
  59803. multiply(color: Color4): Color4;
  59804. /**
  59805. * Multipy a Color4 value by another and push the result in a reference value
  59806. * @param color defines the Color4 value to multiply by
  59807. * @param result defines the Color4 to fill the result in
  59808. * @returns the result Color4
  59809. */
  59810. multiplyToRef(color: Color4, result: Color4): Color4;
  59811. /**
  59812. * Creates a string with the Color4 current values
  59813. * @returns the string representation of the Color4 object
  59814. */
  59815. toString(): string;
  59816. /**
  59817. * Returns the string "Color4"
  59818. * @returns "Color4"
  59819. */
  59820. getClassName(): string;
  59821. /**
  59822. * Compute the Color4 hash code
  59823. * @returns an unique number that can be used to hash Color4 objects
  59824. */
  59825. getHashCode(): number;
  59826. /**
  59827. * Creates a new Color4 copied from the current one
  59828. * @returns a new Color4 object
  59829. */
  59830. clone(): Color4;
  59831. /**
  59832. * Copies the given Color4 values into the current one
  59833. * @param source defines the source Color4 object
  59834. * @returns the current updated Color4 object
  59835. */
  59836. copyFrom(source: Color4): Color4;
  59837. /**
  59838. * Copies the given float values into the current one
  59839. * @param r defines the red component to read from
  59840. * @param g defines the green component to read from
  59841. * @param b defines the blue component to read from
  59842. * @param a defines the alpha component to read from
  59843. * @returns the current updated Color4 object
  59844. */
  59845. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59846. /**
  59847. * Copies the given float values into the current one
  59848. * @param r defines the red component to read from
  59849. * @param g defines the green component to read from
  59850. * @param b defines the blue component to read from
  59851. * @param a defines the alpha component to read from
  59852. * @returns the current updated Color4 object
  59853. */
  59854. set(r: number, g: number, b: number, a: number): Color4;
  59855. /**
  59856. * Compute the Color4 hexadecimal code as a string
  59857. * @returns a string containing the hexadecimal representation of the Color4 object
  59858. */
  59859. toHexString(): string;
  59860. /**
  59861. * Computes a new Color4 converted from the current one to linear space
  59862. * @returns a new Color4 object
  59863. */
  59864. toLinearSpace(): Color4;
  59865. /**
  59866. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59867. * @param convertedColor defines the Color4 object where to store the linear space version
  59868. * @returns the unmodified Color4
  59869. */
  59870. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59871. /**
  59872. * Computes a new Color4 converted from the current one to gamma space
  59873. * @returns a new Color4 object
  59874. */
  59875. toGammaSpace(): Color4;
  59876. /**
  59877. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59878. * @param convertedColor defines the Color4 object where to store the gamma space version
  59879. * @returns the unmodified Color4
  59880. */
  59881. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59882. /**
  59883. * Creates a new Color4 from the string containing valid hexadecimal values
  59884. * @param hex defines a string containing valid hexadecimal values
  59885. * @returns a new Color4 object
  59886. */
  59887. static FromHexString(hex: string): Color4;
  59888. /**
  59889. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59890. * @param left defines the start value
  59891. * @param right defines the end value
  59892. * @param amount defines the gradient factor
  59893. * @returns a new Color4 object
  59894. */
  59895. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59896. /**
  59897. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59898. * @param left defines the start value
  59899. * @param right defines the end value
  59900. * @param amount defines the gradient factor
  59901. * @param result defines the Color4 object where to store data
  59902. */
  59903. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59904. /**
  59905. * Creates a new Color4 from a Color3 and an alpha value
  59906. * @param color3 defines the source Color3 to read from
  59907. * @param alpha defines the alpha component (1.0 by default)
  59908. * @returns a new Color4 object
  59909. */
  59910. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59911. /**
  59912. * Creates a new Color4 from the starting index element of the given array
  59913. * @param array defines the source array to read from
  59914. * @param offset defines the offset in the source array
  59915. * @returns a new Color4 object
  59916. */
  59917. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59918. /**
  59919. * Creates a new Color3 from integer values (< 256)
  59920. * @param r defines the red component to read from (value between 0 and 255)
  59921. * @param g defines the green component to read from (value between 0 and 255)
  59922. * @param b defines the blue component to read from (value between 0 and 255)
  59923. * @param a defines the alpha component to read from (value between 0 and 255)
  59924. * @returns a new Color3 object
  59925. */
  59926. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59927. /**
  59928. * Check the content of a given array and convert it to an array containing RGBA data
  59929. * If the original array was already containing count * 4 values then it is returned directly
  59930. * @param colors defines the array to check
  59931. * @param count defines the number of RGBA data to expect
  59932. * @returns an array containing count * 4 values (RGBA)
  59933. */
  59934. static CheckColors4(colors: number[], count: number): number[];
  59935. }
  59936. /**
  59937. * Class representing a vector containing 2 coordinates
  59938. */
  59939. export class Vector2 {
  59940. /** defines the first coordinate */
  59941. x: number;
  59942. /** defines the second coordinate */
  59943. y: number;
  59944. /**
  59945. * Creates a new Vector2 from the given x and y coordinates
  59946. * @param x defines the first coordinate
  59947. * @param y defines the second coordinate
  59948. */
  59949. constructor(
  59950. /** defines the first coordinate */
  59951. x?: number,
  59952. /** defines the second coordinate */
  59953. y?: number);
  59954. /**
  59955. * Gets a string with the Vector2 coordinates
  59956. * @returns a string with the Vector2 coordinates
  59957. */
  59958. toString(): string;
  59959. /**
  59960. * Gets class name
  59961. * @returns the string "Vector2"
  59962. */
  59963. getClassName(): string;
  59964. /**
  59965. * Gets current vector hash code
  59966. * @returns the Vector2 hash code as a number
  59967. */
  59968. getHashCode(): number;
  59969. /**
  59970. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59971. * @param array defines the source array
  59972. * @param index defines the offset in source array
  59973. * @returns the current Vector2
  59974. */
  59975. toArray(array: FloatArray, index?: number): Vector2;
  59976. /**
  59977. * Copy the current vector to an array
  59978. * @returns a new array with 2 elements: the Vector2 coordinates.
  59979. */
  59980. asArray(): number[];
  59981. /**
  59982. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59983. * @param source defines the source Vector2
  59984. * @returns the current updated Vector2
  59985. */
  59986. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59987. /**
  59988. * Sets the Vector2 coordinates with the given floats
  59989. * @param x defines the first coordinate
  59990. * @param y defines the second coordinate
  59991. * @returns the current updated Vector2
  59992. */
  59993. copyFromFloats(x: number, y: number): Vector2;
  59994. /**
  59995. * Sets the Vector2 coordinates with the given floats
  59996. * @param x defines the first coordinate
  59997. * @param y defines the second coordinate
  59998. * @returns the current updated Vector2
  59999. */
  60000. set(x: number, y: number): Vector2;
  60001. /**
  60002. * Add another vector with the current one
  60003. * @param otherVector defines the other vector
  60004. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60005. */
  60006. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60007. /**
  60008. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60009. * @param otherVector defines the other vector
  60010. * @param result defines the target vector
  60011. * @returns the unmodified current Vector2
  60012. */
  60013. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60014. /**
  60015. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60016. * @param otherVector defines the other vector
  60017. * @returns the current updated Vector2
  60018. */
  60019. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60020. /**
  60021. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60022. * @param otherVector defines the other vector
  60023. * @returns a new Vector2
  60024. */
  60025. addVector3(otherVector: Vector3): Vector2;
  60026. /**
  60027. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60028. * @param otherVector defines the other vector
  60029. * @returns a new Vector2
  60030. */
  60031. subtract(otherVector: Vector2): Vector2;
  60032. /**
  60033. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60034. * @param otherVector defines the other vector
  60035. * @param result defines the target vector
  60036. * @returns the unmodified current Vector2
  60037. */
  60038. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60039. /**
  60040. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60041. * @param otherVector defines the other vector
  60042. * @returns the current updated Vector2
  60043. */
  60044. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60045. /**
  60046. * Multiplies in place the current Vector2 coordinates by the given ones
  60047. * @param otherVector defines the other vector
  60048. * @returns the current updated Vector2
  60049. */
  60050. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60051. /**
  60052. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60053. * @param otherVector defines the other vector
  60054. * @returns a new Vector2
  60055. */
  60056. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60057. /**
  60058. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60059. * @param otherVector defines the other vector
  60060. * @param result defines the target vector
  60061. * @returns the unmodified current Vector2
  60062. */
  60063. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60064. /**
  60065. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60066. * @param x defines the first coordinate
  60067. * @param y defines the second coordinate
  60068. * @returns a new Vector2
  60069. */
  60070. multiplyByFloats(x: number, y: number): Vector2;
  60071. /**
  60072. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60073. * @param otherVector defines the other vector
  60074. * @returns a new Vector2
  60075. */
  60076. divide(otherVector: Vector2): Vector2;
  60077. /**
  60078. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60079. * @param otherVector defines the other vector
  60080. * @param result defines the target vector
  60081. * @returns the unmodified current Vector2
  60082. */
  60083. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60084. /**
  60085. * Divides the current Vector2 coordinates by the given ones
  60086. * @param otherVector defines the other vector
  60087. * @returns the current updated Vector2
  60088. */
  60089. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60090. /**
  60091. * Gets a new Vector2 with current Vector2 negated coordinates
  60092. * @returns a new Vector2
  60093. */
  60094. negate(): Vector2;
  60095. /**
  60096. * Multiply the Vector2 coordinates by scale
  60097. * @param scale defines the scaling factor
  60098. * @returns the current updated Vector2
  60099. */
  60100. scaleInPlace(scale: number): Vector2;
  60101. /**
  60102. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60103. * @param scale defines the scaling factor
  60104. * @returns a new Vector2
  60105. */
  60106. scale(scale: number): Vector2;
  60107. /**
  60108. * Scale the current Vector2 values by a factor to a given Vector2
  60109. * @param scale defines the scale factor
  60110. * @param result defines the Vector2 object where to store the result
  60111. * @returns the unmodified current Vector2
  60112. */
  60113. scaleToRef(scale: number, result: Vector2): Vector2;
  60114. /**
  60115. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60116. * @param scale defines the scale factor
  60117. * @param result defines the Vector2 object where to store the result
  60118. * @returns the unmodified current Vector2
  60119. */
  60120. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60121. /**
  60122. * Gets a boolean if two vectors are equals
  60123. * @param otherVector defines the other vector
  60124. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60125. */
  60126. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60127. /**
  60128. * Gets a boolean if two vectors are equals (using an epsilon value)
  60129. * @param otherVector defines the other vector
  60130. * @param epsilon defines the minimal distance to consider equality
  60131. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60132. */
  60133. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60134. /**
  60135. * Gets a new Vector2 from current Vector2 floored values
  60136. * @returns a new Vector2
  60137. */
  60138. floor(): Vector2;
  60139. /**
  60140. * Gets a new Vector2 from current Vector2 floored values
  60141. * @returns a new Vector2
  60142. */
  60143. fract(): Vector2;
  60144. /**
  60145. * Gets the length of the vector
  60146. * @returns the vector length (float)
  60147. */
  60148. length(): number;
  60149. /**
  60150. * Gets the vector squared length
  60151. * @returns the vector squared length (float)
  60152. */
  60153. lengthSquared(): number;
  60154. /**
  60155. * Normalize the vector
  60156. * @returns the current updated Vector2
  60157. */
  60158. normalize(): Vector2;
  60159. /**
  60160. * Gets a new Vector2 copied from the Vector2
  60161. * @returns a new Vector2
  60162. */
  60163. clone(): Vector2;
  60164. /**
  60165. * Gets a new Vector2(0, 0)
  60166. * @returns a new Vector2
  60167. */
  60168. static Zero(): Vector2;
  60169. /**
  60170. * Gets a new Vector2(1, 1)
  60171. * @returns a new Vector2
  60172. */
  60173. static One(): Vector2;
  60174. /**
  60175. * Gets a new Vector2 set from the given index element of the given array
  60176. * @param array defines the data source
  60177. * @param offset defines the offset in the data source
  60178. * @returns a new Vector2
  60179. */
  60180. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60181. /**
  60182. * Sets "result" from the given index element of the given array
  60183. * @param array defines the data source
  60184. * @param offset defines the offset in the data source
  60185. * @param result defines the target vector
  60186. */
  60187. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60188. /**
  60189. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60190. * @param value1 defines 1st point of control
  60191. * @param value2 defines 2nd point of control
  60192. * @param value3 defines 3rd point of control
  60193. * @param value4 defines 4th point of control
  60194. * @param amount defines the interpolation factor
  60195. * @returns a new Vector2
  60196. */
  60197. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60198. /**
  60199. * 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".
  60200. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60201. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60202. * @param value defines the value to clamp
  60203. * @param min defines the lower limit
  60204. * @param max defines the upper limit
  60205. * @returns a new Vector2
  60206. */
  60207. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60208. /**
  60209. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60210. * @param value1 defines the 1st control point
  60211. * @param tangent1 defines the outgoing tangent
  60212. * @param value2 defines the 2nd control point
  60213. * @param tangent2 defines the incoming tangent
  60214. * @param amount defines the interpolation factor
  60215. * @returns a new Vector2
  60216. */
  60217. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60218. /**
  60219. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60220. * @param start defines the start vector
  60221. * @param end defines the end vector
  60222. * @param amount defines the interpolation factor
  60223. * @returns a new Vector2
  60224. */
  60225. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60226. /**
  60227. * Gets the dot product of the vector "left" and the vector "right"
  60228. * @param left defines first vector
  60229. * @param right defines second vector
  60230. * @returns the dot product (float)
  60231. */
  60232. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60233. /**
  60234. * Returns a new Vector2 equal to the normalized given vector
  60235. * @param vector defines the vector to normalize
  60236. * @returns a new Vector2
  60237. */
  60238. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60239. /**
  60240. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60241. * @param left defines 1st vector
  60242. * @param right defines 2nd vector
  60243. * @returns a new Vector2
  60244. */
  60245. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60246. /**
  60247. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60248. * @param left defines 1st vector
  60249. * @param right defines 2nd vector
  60250. * @returns a new Vector2
  60251. */
  60252. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60253. /**
  60254. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60255. * @param vector defines the vector to transform
  60256. * @param transformation defines the matrix to apply
  60257. * @returns a new Vector2
  60258. */
  60259. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60260. /**
  60261. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60262. * @param vector defines the vector to transform
  60263. * @param transformation defines the matrix to apply
  60264. * @param result defines the target vector
  60265. */
  60266. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60267. /**
  60268. * Determines if a given vector is included in a triangle
  60269. * @param p defines the vector to test
  60270. * @param p0 defines 1st triangle point
  60271. * @param p1 defines 2nd triangle point
  60272. * @param p2 defines 3rd triangle point
  60273. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60274. */
  60275. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60276. /**
  60277. * Gets the distance between the vectors "value1" and "value2"
  60278. * @param value1 defines first vector
  60279. * @param value2 defines second vector
  60280. * @returns the distance between vectors
  60281. */
  60282. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60283. /**
  60284. * Returns the squared distance between the vectors "value1" and "value2"
  60285. * @param value1 defines first vector
  60286. * @param value2 defines second vector
  60287. * @returns the squared distance between vectors
  60288. */
  60289. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60290. /**
  60291. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60292. * @param value1 defines first vector
  60293. * @param value2 defines second vector
  60294. * @returns a new Vector2
  60295. */
  60296. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60297. /**
  60298. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60299. * @param p defines the middle point
  60300. * @param segA defines one point of the segment
  60301. * @param segB defines the other point of the segment
  60302. * @returns the shortest distance
  60303. */
  60304. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60305. }
  60306. /**
  60307. * Classed used to store (x,y,z) vector representation
  60308. * A Vector3 is the main object used in 3D geometry
  60309. * It can represent etiher the coordinates of a point the space, either a direction
  60310. * Reminder: js uses a left handed forward facing system
  60311. */
  60312. export class Vector3 {
  60313. /**
  60314. * Defines the first coordinates (on X axis)
  60315. */
  60316. x: number;
  60317. /**
  60318. * Defines the second coordinates (on Y axis)
  60319. */
  60320. y: number;
  60321. /**
  60322. * Defines the third coordinates (on Z axis)
  60323. */
  60324. z: number;
  60325. private static _UpReadOnly;
  60326. /**
  60327. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60328. * @param x defines the first coordinates (on X axis)
  60329. * @param y defines the second coordinates (on Y axis)
  60330. * @param z defines the third coordinates (on Z axis)
  60331. */
  60332. constructor(
  60333. /**
  60334. * Defines the first coordinates (on X axis)
  60335. */
  60336. x?: number,
  60337. /**
  60338. * Defines the second coordinates (on Y axis)
  60339. */
  60340. y?: number,
  60341. /**
  60342. * Defines the third coordinates (on Z axis)
  60343. */
  60344. z?: number);
  60345. /**
  60346. * Creates a string representation of the Vector3
  60347. * @returns a string with the Vector3 coordinates.
  60348. */
  60349. toString(): string;
  60350. /**
  60351. * Gets the class name
  60352. * @returns the string "Vector3"
  60353. */
  60354. getClassName(): string;
  60355. /**
  60356. * Creates the Vector3 hash code
  60357. * @returns a number which tends to be unique between Vector3 instances
  60358. */
  60359. getHashCode(): number;
  60360. /**
  60361. * Creates an array containing three elements : the coordinates of the Vector3
  60362. * @returns a new array of numbers
  60363. */
  60364. asArray(): number[];
  60365. /**
  60366. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60367. * @param array defines the destination array
  60368. * @param index defines the offset in the destination array
  60369. * @returns the current Vector3
  60370. */
  60371. toArray(array: FloatArray, index?: number): Vector3;
  60372. /**
  60373. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60374. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60375. */
  60376. toQuaternion(): Quaternion;
  60377. /**
  60378. * Adds the given vector to the current Vector3
  60379. * @param otherVector defines the second operand
  60380. * @returns the current updated Vector3
  60381. */
  60382. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60383. /**
  60384. * Adds the given coordinates to the current Vector3
  60385. * @param x defines the x coordinate of the operand
  60386. * @param y defines the y coordinate of the operand
  60387. * @param z defines the z coordinate of the operand
  60388. * @returns the current updated Vector3
  60389. */
  60390. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60391. /**
  60392. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60393. * @param otherVector defines the second operand
  60394. * @returns the resulting Vector3
  60395. */
  60396. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60397. /**
  60398. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60399. * @param otherVector defines the second operand
  60400. * @param result defines the Vector3 object where to store the result
  60401. * @returns the current Vector3
  60402. */
  60403. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60404. /**
  60405. * Subtract the given vector from the current Vector3
  60406. * @param otherVector defines the second operand
  60407. * @returns the current updated Vector3
  60408. */
  60409. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60410. /**
  60411. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60412. * @param otherVector defines the second operand
  60413. * @returns the resulting Vector3
  60414. */
  60415. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60416. /**
  60417. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60418. * @param otherVector defines the second operand
  60419. * @param result defines the Vector3 object where to store the result
  60420. * @returns the current Vector3
  60421. */
  60422. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60423. /**
  60424. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60425. * @param x defines the x coordinate of the operand
  60426. * @param y defines the y coordinate of the operand
  60427. * @param z defines the z coordinate of the operand
  60428. * @returns the resulting Vector3
  60429. */
  60430. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60431. /**
  60432. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60433. * @param x defines the x coordinate of the operand
  60434. * @param y defines the y coordinate of the operand
  60435. * @param z defines the z coordinate of the operand
  60436. * @param result defines the Vector3 object where to store the result
  60437. * @returns the current Vector3
  60438. */
  60439. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60440. /**
  60441. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60442. * @returns a new Vector3
  60443. */
  60444. negate(): Vector3;
  60445. /**
  60446. * Multiplies the Vector3 coordinates by the float "scale"
  60447. * @param scale defines the multiplier factor
  60448. * @returns the current updated Vector3
  60449. */
  60450. scaleInPlace(scale: number): Vector3;
  60451. /**
  60452. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60453. * @param scale defines the multiplier factor
  60454. * @returns a new Vector3
  60455. */
  60456. scale(scale: number): Vector3;
  60457. /**
  60458. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60459. * @param scale defines the multiplier factor
  60460. * @param result defines the Vector3 object where to store the result
  60461. * @returns the current Vector3
  60462. */
  60463. scaleToRef(scale: number, result: Vector3): Vector3;
  60464. /**
  60465. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60466. * @param scale defines the scale factor
  60467. * @param result defines the Vector3 object where to store the result
  60468. * @returns the unmodified current Vector3
  60469. */
  60470. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60471. /**
  60472. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60473. * @param otherVector defines the second operand
  60474. * @returns true if both vectors are equals
  60475. */
  60476. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60477. /**
  60478. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60479. * @param otherVector defines the second operand
  60480. * @param epsilon defines the minimal distance to define values as equals
  60481. * @returns true if both vectors are distant less than epsilon
  60482. */
  60483. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60484. /**
  60485. * Returns true if the current Vector3 coordinates equals the given floats
  60486. * @param x defines the x coordinate of the operand
  60487. * @param y defines the y coordinate of the operand
  60488. * @param z defines the z coordinate of the operand
  60489. * @returns true if both vectors are equals
  60490. */
  60491. equalsToFloats(x: number, y: number, z: number): boolean;
  60492. /**
  60493. * Multiplies the current Vector3 coordinates by the given ones
  60494. * @param otherVector defines the second operand
  60495. * @returns the current updated Vector3
  60496. */
  60497. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60498. /**
  60499. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60500. * @param otherVector defines the second operand
  60501. * @returns the new Vector3
  60502. */
  60503. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60504. /**
  60505. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60506. * @param otherVector defines the second operand
  60507. * @param result defines the Vector3 object where to store the result
  60508. * @returns the current Vector3
  60509. */
  60510. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60511. /**
  60512. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60513. * @param x defines the x coordinate of the operand
  60514. * @param y defines the y coordinate of the operand
  60515. * @param z defines the z coordinate of the operand
  60516. * @returns the new Vector3
  60517. */
  60518. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60519. /**
  60520. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60521. * @param otherVector defines the second operand
  60522. * @returns the new Vector3
  60523. */
  60524. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60525. /**
  60526. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60527. * @param otherVector defines the second operand
  60528. * @param result defines the Vector3 object where to store the result
  60529. * @returns the current Vector3
  60530. */
  60531. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60532. /**
  60533. * Divides the current Vector3 coordinates by the given ones.
  60534. * @param otherVector defines the second operand
  60535. * @returns the current updated Vector3
  60536. */
  60537. divideInPlace(otherVector: Vector3): Vector3;
  60538. /**
  60539. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60540. * @param other defines the second operand
  60541. * @returns the current updated Vector3
  60542. */
  60543. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60544. /**
  60545. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60546. * @param other defines the second operand
  60547. * @returns the current updated Vector3
  60548. */
  60549. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60550. /**
  60551. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60552. * @param x defines the x coordinate of the operand
  60553. * @param y defines the y coordinate of the operand
  60554. * @param z defines the z coordinate of the operand
  60555. * @returns the current updated Vector3
  60556. */
  60557. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60558. /**
  60559. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60560. * @param x defines the x coordinate of the operand
  60561. * @param y defines the y coordinate of the operand
  60562. * @param z defines the z coordinate of the operand
  60563. * @returns the current updated Vector3
  60564. */
  60565. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60566. /**
  60567. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60568. * Check if is non uniform within a certain amount of decimal places to account for this
  60569. * @param epsilon the amount the values can differ
  60570. * @returns if the the vector is non uniform to a certain number of decimal places
  60571. */
  60572. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60573. /**
  60574. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60575. */
  60576. readonly isNonUniform: boolean;
  60577. /**
  60578. * Gets a new Vector3 from current Vector3 floored values
  60579. * @returns a new Vector3
  60580. */
  60581. floor(): Vector3;
  60582. /**
  60583. * Gets a new Vector3 from current Vector3 floored values
  60584. * @returns a new Vector3
  60585. */
  60586. fract(): Vector3;
  60587. /**
  60588. * Gets the length of the Vector3
  60589. * @returns the length of the Vecto3
  60590. */
  60591. length(): number;
  60592. /**
  60593. * Gets the squared length of the Vector3
  60594. * @returns squared length of the Vector3
  60595. */
  60596. lengthSquared(): number;
  60597. /**
  60598. * Normalize the current Vector3.
  60599. * Please note that this is an in place operation.
  60600. * @returns the current updated Vector3
  60601. */
  60602. normalize(): Vector3;
  60603. /**
  60604. * Reorders the x y z properties of the vector in place
  60605. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60606. * @returns the current updated vector
  60607. */
  60608. reorderInPlace(order: string): this;
  60609. /**
  60610. * Rotates the vector around 0,0,0 by a quaternion
  60611. * @param quaternion the rotation quaternion
  60612. * @param result vector to store the result
  60613. * @returns the resulting vector
  60614. */
  60615. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60616. /**
  60617. * Rotates a vector around a given point
  60618. * @param quaternion the rotation quaternion
  60619. * @param point the point to rotate around
  60620. * @param result vector to store the result
  60621. * @returns the resulting vector
  60622. */
  60623. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60624. /**
  60625. * Normalize the current Vector3 with the given input length.
  60626. * Please note that this is an in place operation.
  60627. * @param len the length of the vector
  60628. * @returns the current updated Vector3
  60629. */
  60630. normalizeFromLength(len: number): Vector3;
  60631. /**
  60632. * Normalize the current Vector3 to a new vector
  60633. * @returns the new Vector3
  60634. */
  60635. normalizeToNew(): Vector3;
  60636. /**
  60637. * Normalize the current Vector3 to the reference
  60638. * @param reference define the Vector3 to update
  60639. * @returns the updated Vector3
  60640. */
  60641. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60642. /**
  60643. * Creates a new Vector3 copied from the current Vector3
  60644. * @returns the new Vector3
  60645. */
  60646. clone(): Vector3;
  60647. /**
  60648. * Copies the given vector coordinates to the current Vector3 ones
  60649. * @param source defines the source Vector3
  60650. * @returns the current updated Vector3
  60651. */
  60652. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60653. /**
  60654. * Copies the given floats to the current Vector3 coordinates
  60655. * @param x defines the x coordinate of the operand
  60656. * @param y defines the y coordinate of the operand
  60657. * @param z defines the z coordinate of the operand
  60658. * @returns the current updated Vector3
  60659. */
  60660. copyFromFloats(x: number, y: number, z: number): Vector3;
  60661. /**
  60662. * Copies the given floats to the current Vector3 coordinates
  60663. * @param x defines the x coordinate of the operand
  60664. * @param y defines the y coordinate of the operand
  60665. * @param z defines the z coordinate of the operand
  60666. * @returns the current updated Vector3
  60667. */
  60668. set(x: number, y: number, z: number): Vector3;
  60669. /**
  60670. * Copies the given float to the current Vector3 coordinates
  60671. * @param v defines the x, y and z coordinates of the operand
  60672. * @returns the current updated Vector3
  60673. */
  60674. setAll(v: number): Vector3;
  60675. /**
  60676. * Get the clip factor between two vectors
  60677. * @param vector0 defines the first operand
  60678. * @param vector1 defines the second operand
  60679. * @param axis defines the axis to use
  60680. * @param size defines the size along the axis
  60681. * @returns the clip factor
  60682. */
  60683. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60684. /**
  60685. * Get angle between two vectors
  60686. * @param vector0 angle between vector0 and vector1
  60687. * @param vector1 angle between vector0 and vector1
  60688. * @param normal direction of the normal
  60689. * @return the angle between vector0 and vector1
  60690. */
  60691. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60692. /**
  60693. * Returns a new Vector3 set from the index "offset" of the given array
  60694. * @param array defines the source array
  60695. * @param offset defines the offset in the source array
  60696. * @returns the new Vector3
  60697. */
  60698. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60699. /**
  60700. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60701. * This function is deprecated. Use FromArray instead
  60702. * @param array defines the source array
  60703. * @param offset defines the offset in the source array
  60704. * @returns the new Vector3
  60705. */
  60706. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60707. /**
  60708. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60709. * @param array defines the source array
  60710. * @param offset defines the offset in the source array
  60711. * @param result defines the Vector3 where to store the result
  60712. */
  60713. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60714. /**
  60715. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60716. * This function is deprecated. Use FromArrayToRef instead.
  60717. * @param array defines the source array
  60718. * @param offset defines the offset in the source array
  60719. * @param result defines the Vector3 where to store the result
  60720. */
  60721. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60722. /**
  60723. * Sets the given vector "result" with the given floats.
  60724. * @param x defines the x coordinate of the source
  60725. * @param y defines the y coordinate of the source
  60726. * @param z defines the z coordinate of the source
  60727. * @param result defines the Vector3 where to store the result
  60728. */
  60729. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60730. /**
  60731. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60732. * @returns a new empty Vector3
  60733. */
  60734. static Zero(): Vector3;
  60735. /**
  60736. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60737. * @returns a new unit Vector3
  60738. */
  60739. static One(): Vector3;
  60740. /**
  60741. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60742. * @returns a new up Vector3
  60743. */
  60744. static Up(): Vector3;
  60745. /**
  60746. * Gets a up Vector3 that must not be updated
  60747. */
  60748. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60749. /**
  60750. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60751. * @returns a new down Vector3
  60752. */
  60753. static Down(): Vector3;
  60754. /**
  60755. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60756. * @returns a new forward Vector3
  60757. */
  60758. static Forward(): Vector3;
  60759. /**
  60760. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60761. * @returns a new forward Vector3
  60762. */
  60763. static Backward(): Vector3;
  60764. /**
  60765. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60766. * @returns a new right Vector3
  60767. */
  60768. static Right(): Vector3;
  60769. /**
  60770. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60771. * @returns a new left Vector3
  60772. */
  60773. static Left(): Vector3;
  60774. /**
  60775. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60776. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60777. * @param vector defines the Vector3 to transform
  60778. * @param transformation defines the transformation matrix
  60779. * @returns the transformed Vector3
  60780. */
  60781. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60782. /**
  60783. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60785. * @param vector defines the Vector3 to transform
  60786. * @param transformation defines the transformation matrix
  60787. * @param result defines the Vector3 where to store the result
  60788. */
  60789. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60790. /**
  60791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60792. * This method computes tranformed coordinates only, not transformed direction vectors
  60793. * @param x define the x coordinate of the source vector
  60794. * @param y define the y coordinate of the source vector
  60795. * @param z define the z coordinate of the source vector
  60796. * @param transformation defines the transformation matrix
  60797. * @param result defines the Vector3 where to store the result
  60798. */
  60799. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60800. /**
  60801. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60802. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60803. * @param vector defines the Vector3 to transform
  60804. * @param transformation defines the transformation matrix
  60805. * @returns the new Vector3
  60806. */
  60807. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60808. /**
  60809. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60811. * @param vector defines the Vector3 to transform
  60812. * @param transformation defines the transformation matrix
  60813. * @param result defines the Vector3 where to store the result
  60814. */
  60815. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60816. /**
  60817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60819. * @param x define the x coordinate of the source vector
  60820. * @param y define the y coordinate of the source vector
  60821. * @param z define the z coordinate of the source vector
  60822. * @param transformation defines the transformation matrix
  60823. * @param result defines the Vector3 where to store the result
  60824. */
  60825. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60826. /**
  60827. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60828. * @param value1 defines the first control point
  60829. * @param value2 defines the second control point
  60830. * @param value3 defines the third control point
  60831. * @param value4 defines the fourth control point
  60832. * @param amount defines the amount on the spline to use
  60833. * @returns the new Vector3
  60834. */
  60835. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60836. /**
  60837. * 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"
  60838. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60839. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60840. * @param value defines the current value
  60841. * @param min defines the lower range value
  60842. * @param max defines the upper range value
  60843. * @returns the new Vector3
  60844. */
  60845. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60846. /**
  60847. * 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"
  60848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60850. * @param value defines the current value
  60851. * @param min defines the lower range value
  60852. * @param max defines the upper range value
  60853. * @param result defines the Vector3 where to store the result
  60854. */
  60855. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60856. /**
  60857. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60858. * @param value1 defines the first control point
  60859. * @param tangent1 defines the first tangent vector
  60860. * @param value2 defines the second control point
  60861. * @param tangent2 defines the second tangent vector
  60862. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60863. * @returns the new Vector3
  60864. */
  60865. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60866. /**
  60867. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60868. * @param start defines the start value
  60869. * @param end defines the end value
  60870. * @param amount max defines amount between both (between 0 and 1)
  60871. * @returns the new Vector3
  60872. */
  60873. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60874. /**
  60875. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60876. * @param start defines the start value
  60877. * @param end defines the end value
  60878. * @param amount max defines amount between both (between 0 and 1)
  60879. * @param result defines the Vector3 where to store the result
  60880. */
  60881. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60882. /**
  60883. * Returns the dot product (float) between the vectors "left" and "right"
  60884. * @param left defines the left operand
  60885. * @param right defines the right operand
  60886. * @returns the dot product
  60887. */
  60888. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60889. /**
  60890. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60891. * The cross product is then orthogonal to both "left" and "right"
  60892. * @param left defines the left operand
  60893. * @param right defines the right operand
  60894. * @returns the cross product
  60895. */
  60896. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60897. /**
  60898. * Sets the given vector "result" with the cross product of "left" and "right"
  60899. * The cross product is then orthogonal to both "left" and "right"
  60900. * @param left defines the left operand
  60901. * @param right defines the right operand
  60902. * @param result defines the Vector3 where to store the result
  60903. */
  60904. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60905. /**
  60906. * Returns a new Vector3 as the normalization of the given vector
  60907. * @param vector defines the Vector3 to normalize
  60908. * @returns the new Vector3
  60909. */
  60910. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60911. /**
  60912. * Sets the given vector "result" with the normalization of the given first vector
  60913. * @param vector defines the Vector3 to normalize
  60914. * @param result defines the Vector3 where to store the result
  60915. */
  60916. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60917. /**
  60918. * Project a Vector3 onto screen space
  60919. * @param vector defines the Vector3 to project
  60920. * @param world defines the world matrix to use
  60921. * @param transform defines the transform (view x projection) matrix to use
  60922. * @param viewport defines the screen viewport to use
  60923. * @returns the new Vector3
  60924. */
  60925. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60926. /** @hidden */
  60927. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60928. /**
  60929. * Unproject from screen space to object space
  60930. * @param source defines the screen space Vector3 to use
  60931. * @param viewportWidth defines the current width of the viewport
  60932. * @param viewportHeight defines the current height of the viewport
  60933. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60934. * @param transform defines the transform (view x projection) matrix to use
  60935. * @returns the new Vector3
  60936. */
  60937. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60938. /**
  60939. * Unproject from screen space to object space
  60940. * @param source defines the screen space Vector3 to use
  60941. * @param viewportWidth defines the current width of the viewport
  60942. * @param viewportHeight defines the current height of the viewport
  60943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60944. * @param view defines the view matrix to use
  60945. * @param projection defines the projection matrix to use
  60946. * @returns the new Vector3
  60947. */
  60948. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60949. /**
  60950. * Unproject from screen space to object space
  60951. * @param source defines the screen space Vector3 to use
  60952. * @param viewportWidth defines the current width of the viewport
  60953. * @param viewportHeight defines the current height of the viewport
  60954. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60955. * @param view defines the view matrix to use
  60956. * @param projection defines the projection matrix to use
  60957. * @param result defines the Vector3 where to store the result
  60958. */
  60959. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60960. /**
  60961. * Unproject from screen space to object space
  60962. * @param sourceX defines the screen space x coordinate to use
  60963. * @param sourceY defines the screen space y coordinate to use
  60964. * @param sourceZ defines the screen space z coordinate to use
  60965. * @param viewportWidth defines the current width of the viewport
  60966. * @param viewportHeight defines the current height of the viewport
  60967. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60968. * @param view defines the view matrix to use
  60969. * @param projection defines the projection matrix to use
  60970. * @param result defines the Vector3 where to store the result
  60971. */
  60972. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60973. /**
  60974. * Gets the minimal coordinate values between two Vector3
  60975. * @param left defines the first operand
  60976. * @param right defines the second operand
  60977. * @returns the new Vector3
  60978. */
  60979. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60980. /**
  60981. * Gets the maximal coordinate values between two Vector3
  60982. * @param left defines the first operand
  60983. * @param right defines the second operand
  60984. * @returns the new Vector3
  60985. */
  60986. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60987. /**
  60988. * Returns the distance between the vectors "value1" and "value2"
  60989. * @param value1 defines the first operand
  60990. * @param value2 defines the second operand
  60991. * @returns the distance
  60992. */
  60993. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60994. /**
  60995. * Returns the squared distance between the vectors "value1" and "value2"
  60996. * @param value1 defines the first operand
  60997. * @param value2 defines the second operand
  60998. * @returns the squared distance
  60999. */
  61000. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61001. /**
  61002. * Returns a new Vector3 located at the center between "value1" and "value2"
  61003. * @param value1 defines the first operand
  61004. * @param value2 defines the second operand
  61005. * @returns the new Vector3
  61006. */
  61007. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61008. /**
  61009. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61010. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61011. * to something in order to rotate it from its local system to the given target system
  61012. * Note: axis1, axis2 and axis3 are normalized during this operation
  61013. * @param axis1 defines the first axis
  61014. * @param axis2 defines the second axis
  61015. * @param axis3 defines the third axis
  61016. * @returns a new Vector3
  61017. */
  61018. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61019. /**
  61020. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61021. * @param axis1 defines the first axis
  61022. * @param axis2 defines the second axis
  61023. * @param axis3 defines the third axis
  61024. * @param ref defines the Vector3 where to store the result
  61025. */
  61026. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61027. }
  61028. /**
  61029. * Vector4 class created for EulerAngle class conversion to Quaternion
  61030. */
  61031. export class Vector4 {
  61032. /** x value of the vector */
  61033. x: number;
  61034. /** y value of the vector */
  61035. y: number;
  61036. /** z value of the vector */
  61037. z: number;
  61038. /** w value of the vector */
  61039. w: number;
  61040. /**
  61041. * Creates a Vector4 object from the given floats.
  61042. * @param x x value of the vector
  61043. * @param y y value of the vector
  61044. * @param z z value of the vector
  61045. * @param w w value of the vector
  61046. */
  61047. constructor(
  61048. /** x value of the vector */
  61049. x: number,
  61050. /** y value of the vector */
  61051. y: number,
  61052. /** z value of the vector */
  61053. z: number,
  61054. /** w value of the vector */
  61055. w: number);
  61056. /**
  61057. * Returns the string with the Vector4 coordinates.
  61058. * @returns a string containing all the vector values
  61059. */
  61060. toString(): string;
  61061. /**
  61062. * Returns the string "Vector4".
  61063. * @returns "Vector4"
  61064. */
  61065. getClassName(): string;
  61066. /**
  61067. * Returns the Vector4 hash code.
  61068. * @returns a unique hash code
  61069. */
  61070. getHashCode(): number;
  61071. /**
  61072. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61073. * @returns the resulting array
  61074. */
  61075. asArray(): number[];
  61076. /**
  61077. * Populates the given array from the given index with the Vector4 coordinates.
  61078. * @param array array to populate
  61079. * @param index index of the array to start at (default: 0)
  61080. * @returns the Vector4.
  61081. */
  61082. toArray(array: FloatArray, index?: number): Vector4;
  61083. /**
  61084. * Adds the given vector to the current Vector4.
  61085. * @param otherVector the vector to add
  61086. * @returns the updated Vector4.
  61087. */
  61088. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61089. /**
  61090. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61091. * @param otherVector the vector to add
  61092. * @returns the resulting vector
  61093. */
  61094. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61095. /**
  61096. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61097. * @param otherVector the vector to add
  61098. * @param result the vector to store the result
  61099. * @returns the current Vector4.
  61100. */
  61101. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61102. /**
  61103. * Subtract in place the given vector from the current Vector4.
  61104. * @param otherVector the vector to subtract
  61105. * @returns the updated Vector4.
  61106. */
  61107. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61108. /**
  61109. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61110. * @param otherVector the vector to add
  61111. * @returns the new vector with the result
  61112. */
  61113. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61114. /**
  61115. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61116. * @param otherVector the vector to subtract
  61117. * @param result the vector to store the result
  61118. * @returns the current Vector4.
  61119. */
  61120. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61121. /**
  61122. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61123. */
  61124. /**
  61125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61126. * @param x value to subtract
  61127. * @param y value to subtract
  61128. * @param z value to subtract
  61129. * @param w value to subtract
  61130. * @returns new vector containing the result
  61131. */
  61132. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61133. /**
  61134. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61135. * @param x value to subtract
  61136. * @param y value to subtract
  61137. * @param z value to subtract
  61138. * @param w value to subtract
  61139. * @param result the vector to store the result in
  61140. * @returns the current Vector4.
  61141. */
  61142. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61143. /**
  61144. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61145. * @returns a new vector with the negated values
  61146. */
  61147. negate(): Vector4;
  61148. /**
  61149. * Multiplies the current Vector4 coordinates by scale (float).
  61150. * @param scale the number to scale with
  61151. * @returns the updated Vector4.
  61152. */
  61153. scaleInPlace(scale: number): Vector4;
  61154. /**
  61155. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61156. * @param scale the number to scale with
  61157. * @returns a new vector with the result
  61158. */
  61159. scale(scale: number): Vector4;
  61160. /**
  61161. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61162. * @param scale the number to scale with
  61163. * @param result a vector to store the result in
  61164. * @returns the current Vector4.
  61165. */
  61166. scaleToRef(scale: number, result: Vector4): Vector4;
  61167. /**
  61168. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61169. * @param scale defines the scale factor
  61170. * @param result defines the Vector4 object where to store the result
  61171. * @returns the unmodified current Vector4
  61172. */
  61173. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61174. /**
  61175. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61176. * @param otherVector the vector to compare against
  61177. * @returns true if they are equal
  61178. */
  61179. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61180. /**
  61181. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61182. * @param otherVector vector to compare against
  61183. * @param epsilon (Default: very small number)
  61184. * @returns true if they are equal
  61185. */
  61186. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61187. /**
  61188. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61189. * @param x x value to compare against
  61190. * @param y y value to compare against
  61191. * @param z z value to compare against
  61192. * @param w w value to compare against
  61193. * @returns true if equal
  61194. */
  61195. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61196. /**
  61197. * Multiplies in place the current Vector4 by the given one.
  61198. * @param otherVector vector to multiple with
  61199. * @returns the updated Vector4.
  61200. */
  61201. multiplyInPlace(otherVector: Vector4): Vector4;
  61202. /**
  61203. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61204. * @param otherVector vector to multiple with
  61205. * @returns resulting new vector
  61206. */
  61207. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61208. /**
  61209. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61210. * @param otherVector vector to multiple with
  61211. * @param result vector to store the result
  61212. * @returns the current Vector4.
  61213. */
  61214. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61215. /**
  61216. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61217. * @param x x value multiply with
  61218. * @param y y value multiply with
  61219. * @param z z value multiply with
  61220. * @param w w value multiply with
  61221. * @returns resulting new vector
  61222. */
  61223. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61224. /**
  61225. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61226. * @param otherVector vector to devide with
  61227. * @returns resulting new vector
  61228. */
  61229. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61230. /**
  61231. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61232. * @param otherVector vector to devide with
  61233. * @param result vector to store the result
  61234. * @returns the current Vector4.
  61235. */
  61236. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61237. /**
  61238. * Divides the current Vector3 coordinates by the given ones.
  61239. * @param otherVector vector to devide with
  61240. * @returns the updated Vector3.
  61241. */
  61242. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61243. /**
  61244. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61245. * @param other defines the second operand
  61246. * @returns the current updated Vector4
  61247. */
  61248. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61249. /**
  61250. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61251. * @param other defines the second operand
  61252. * @returns the current updated Vector4
  61253. */
  61254. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61255. /**
  61256. * Gets a new Vector4 from current Vector4 floored values
  61257. * @returns a new Vector4
  61258. */
  61259. floor(): Vector4;
  61260. /**
  61261. * Gets a new Vector4 from current Vector3 floored values
  61262. * @returns a new Vector4
  61263. */
  61264. fract(): Vector4;
  61265. /**
  61266. * Returns the Vector4 length (float).
  61267. * @returns the length
  61268. */
  61269. length(): number;
  61270. /**
  61271. * Returns the Vector4 squared length (float).
  61272. * @returns the length squared
  61273. */
  61274. lengthSquared(): number;
  61275. /**
  61276. * Normalizes in place the Vector4.
  61277. * @returns the updated Vector4.
  61278. */
  61279. normalize(): Vector4;
  61280. /**
  61281. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61282. * @returns this converted to a new vector3
  61283. */
  61284. toVector3(): Vector3;
  61285. /**
  61286. * Returns a new Vector4 copied from the current one.
  61287. * @returns the new cloned vector
  61288. */
  61289. clone(): Vector4;
  61290. /**
  61291. * Updates the current Vector4 with the given one coordinates.
  61292. * @param source the source vector to copy from
  61293. * @returns the updated Vector4.
  61294. */
  61295. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61296. /**
  61297. * Updates the current Vector4 coordinates with the given floats.
  61298. * @param x float to copy from
  61299. * @param y float to copy from
  61300. * @param z float to copy from
  61301. * @param w float to copy from
  61302. * @returns the updated Vector4.
  61303. */
  61304. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61305. /**
  61306. * Updates the current Vector4 coordinates with the given floats.
  61307. * @param x float to set from
  61308. * @param y float to set from
  61309. * @param z float to set from
  61310. * @param w float to set from
  61311. * @returns the updated Vector4.
  61312. */
  61313. set(x: number, y: number, z: number, w: number): Vector4;
  61314. /**
  61315. * Copies the given float to the current Vector3 coordinates
  61316. * @param v defines the x, y, z and w coordinates of the operand
  61317. * @returns the current updated Vector3
  61318. */
  61319. setAll(v: number): Vector4;
  61320. /**
  61321. * Returns a new Vector4 set from the starting index of the given array.
  61322. * @param array the array to pull values from
  61323. * @param offset the offset into the array to start at
  61324. * @returns the new vector
  61325. */
  61326. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61327. /**
  61328. * Updates the given vector "result" from the starting index of the given array.
  61329. * @param array the array to pull values from
  61330. * @param offset the offset into the array to start at
  61331. * @param result the vector to store the result in
  61332. */
  61333. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61334. /**
  61335. * Updates the given vector "result" from the starting index of the given Float32Array.
  61336. * @param array the array to pull values from
  61337. * @param offset the offset into the array to start at
  61338. * @param result the vector to store the result in
  61339. */
  61340. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61341. /**
  61342. * Updates the given vector "result" coordinates from the given floats.
  61343. * @param x float to set from
  61344. * @param y float to set from
  61345. * @param z float to set from
  61346. * @param w float to set from
  61347. * @param result the vector to the floats in
  61348. */
  61349. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61350. /**
  61351. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61352. * @returns the new vector
  61353. */
  61354. static Zero(): Vector4;
  61355. /**
  61356. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61357. * @returns the new vector
  61358. */
  61359. static One(): Vector4;
  61360. /**
  61361. * Returns a new normalized Vector4 from the given one.
  61362. * @param vector the vector to normalize
  61363. * @returns the vector
  61364. */
  61365. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61366. /**
  61367. * Updates the given vector "result" from the normalization of the given one.
  61368. * @param vector the vector to normalize
  61369. * @param result the vector to store the result in
  61370. */
  61371. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61372. /**
  61373. * Returns a vector with the minimum values from the left and right vectors
  61374. * @param left left vector to minimize
  61375. * @param right right vector to minimize
  61376. * @returns a new vector with the minimum of the left and right vector values
  61377. */
  61378. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61379. /**
  61380. * Returns a vector with the maximum values from the left and right vectors
  61381. * @param left left vector to maximize
  61382. * @param right right vector to maximize
  61383. * @returns a new vector with the maximum of the left and right vector values
  61384. */
  61385. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61386. /**
  61387. * Returns the distance (float) between the vectors "value1" and "value2".
  61388. * @param value1 value to calulate the distance between
  61389. * @param value2 value to calulate the distance between
  61390. * @return the distance between the two vectors
  61391. */
  61392. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61393. /**
  61394. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61395. * @param value1 value to calulate the distance between
  61396. * @param value2 value to calulate the distance between
  61397. * @return the distance between the two vectors squared
  61398. */
  61399. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61400. /**
  61401. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61402. * @param value1 value to calulate the center between
  61403. * @param value2 value to calulate the center between
  61404. * @return the center between the two vectors
  61405. */
  61406. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61407. /**
  61408. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61409. * This methods computes transformed normalized direction vectors only.
  61410. * @param vector the vector to transform
  61411. * @param transformation the transformation matrix to apply
  61412. * @returns the new vector
  61413. */
  61414. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61415. /**
  61416. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61417. * This methods computes transformed normalized direction vectors only.
  61418. * @param vector the vector to transform
  61419. * @param transformation the transformation matrix to apply
  61420. * @param result the vector to store the result in
  61421. */
  61422. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61423. /**
  61424. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61425. * This methods computes transformed normalized direction vectors only.
  61426. * @param x value to transform
  61427. * @param y value to transform
  61428. * @param z value to transform
  61429. * @param w value to transform
  61430. * @param transformation the transformation matrix to apply
  61431. * @param result the vector to store the results in
  61432. */
  61433. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61434. /**
  61435. * Creates a new Vector4 from a Vector3
  61436. * @param source defines the source data
  61437. * @param w defines the 4th component (default is 0)
  61438. * @returns a new Vector4
  61439. */
  61440. static FromVector3(source: Vector3, w?: number): Vector4;
  61441. }
  61442. /**
  61443. * Interface for the size containing width and height
  61444. */
  61445. export interface ISize {
  61446. /**
  61447. * Width
  61448. */
  61449. width: number;
  61450. /**
  61451. * Heighht
  61452. */
  61453. height: number;
  61454. }
  61455. /**
  61456. * Size containing widht and height
  61457. */
  61458. export class Size implements ISize {
  61459. /**
  61460. * Width
  61461. */
  61462. width: number;
  61463. /**
  61464. * Height
  61465. */
  61466. height: number;
  61467. /**
  61468. * Creates a Size object from the given width and height (floats).
  61469. * @param width width of the new size
  61470. * @param height height of the new size
  61471. */
  61472. constructor(width: number, height: number);
  61473. /**
  61474. * Returns a string with the Size width and height
  61475. * @returns a string with the Size width and height
  61476. */
  61477. toString(): string;
  61478. /**
  61479. * "Size"
  61480. * @returns the string "Size"
  61481. */
  61482. getClassName(): string;
  61483. /**
  61484. * Returns the Size hash code.
  61485. * @returns a hash code for a unique width and height
  61486. */
  61487. getHashCode(): number;
  61488. /**
  61489. * Updates the current size from the given one.
  61490. * @param src the given size
  61491. */
  61492. copyFrom(src: Size): void;
  61493. /**
  61494. * Updates in place the current Size from the given floats.
  61495. * @param width width of the new size
  61496. * @param height height of the new size
  61497. * @returns the updated Size.
  61498. */
  61499. copyFromFloats(width: number, height: number): Size;
  61500. /**
  61501. * Updates in place the current Size from the given floats.
  61502. * @param width width to set
  61503. * @param height height to set
  61504. * @returns the updated Size.
  61505. */
  61506. set(width: number, height: number): Size;
  61507. /**
  61508. * Multiplies the width and height by numbers
  61509. * @param w factor to multiple the width by
  61510. * @param h factor to multiple the height by
  61511. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61512. */
  61513. multiplyByFloats(w: number, h: number): Size;
  61514. /**
  61515. * Clones the size
  61516. * @returns a new Size copied from the given one.
  61517. */
  61518. clone(): Size;
  61519. /**
  61520. * True if the current Size and the given one width and height are strictly equal.
  61521. * @param other the other size to compare against
  61522. * @returns True if the current Size and the given one width and height are strictly equal.
  61523. */
  61524. equals(other: Size): boolean;
  61525. /**
  61526. * The surface of the Size : width * height (float).
  61527. */
  61528. readonly surface: number;
  61529. /**
  61530. * Create a new size of zero
  61531. * @returns a new Size set to (0.0, 0.0)
  61532. */
  61533. static Zero(): Size;
  61534. /**
  61535. * Sums the width and height of two sizes
  61536. * @param otherSize size to add to this size
  61537. * @returns a new Size set as the addition result of the current Size and the given one.
  61538. */
  61539. add(otherSize: Size): Size;
  61540. /**
  61541. * Subtracts the width and height of two
  61542. * @param otherSize size to subtract to this size
  61543. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61544. */
  61545. subtract(otherSize: Size): Size;
  61546. /**
  61547. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61548. * @param start starting size to lerp between
  61549. * @param end end size to lerp between
  61550. * @param amount amount to lerp between the start and end values
  61551. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61552. */
  61553. static Lerp(start: Size, end: Size, amount: number): Size;
  61554. }
  61555. /**
  61556. * Class used to store quaternion data
  61557. * @see https://en.wikipedia.org/wiki/Quaternion
  61558. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61559. */
  61560. export class Quaternion {
  61561. /** defines the first component (0 by default) */
  61562. x: number;
  61563. /** defines the second component (0 by default) */
  61564. y: number;
  61565. /** defines the third component (0 by default) */
  61566. z: number;
  61567. /** defines the fourth component (1.0 by default) */
  61568. w: number;
  61569. /**
  61570. * Creates a new Quaternion from the given floats
  61571. * @param x defines the first component (0 by default)
  61572. * @param y defines the second component (0 by default)
  61573. * @param z defines the third component (0 by default)
  61574. * @param w defines the fourth component (1.0 by default)
  61575. */
  61576. constructor(
  61577. /** defines the first component (0 by default) */
  61578. x?: number,
  61579. /** defines the second component (0 by default) */
  61580. y?: number,
  61581. /** defines the third component (0 by default) */
  61582. z?: number,
  61583. /** defines the fourth component (1.0 by default) */
  61584. w?: number);
  61585. /**
  61586. * Gets a string representation for the current quaternion
  61587. * @returns a string with the Quaternion coordinates
  61588. */
  61589. toString(): string;
  61590. /**
  61591. * Gets the class name of the quaternion
  61592. * @returns the string "Quaternion"
  61593. */
  61594. getClassName(): string;
  61595. /**
  61596. * Gets a hash code for this quaternion
  61597. * @returns the quaternion hash code
  61598. */
  61599. getHashCode(): number;
  61600. /**
  61601. * Copy the quaternion to an array
  61602. * @returns a new array populated with 4 elements from the quaternion coordinates
  61603. */
  61604. asArray(): number[];
  61605. /**
  61606. * Check if two quaternions are equals
  61607. * @param otherQuaternion defines the second operand
  61608. * @return true if the current quaternion and the given one coordinates are strictly equals
  61609. */
  61610. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61611. /**
  61612. * Clone the current quaternion
  61613. * @returns a new quaternion copied from the current one
  61614. */
  61615. clone(): Quaternion;
  61616. /**
  61617. * Copy a quaternion to the current one
  61618. * @param other defines the other quaternion
  61619. * @returns the updated current quaternion
  61620. */
  61621. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61622. /**
  61623. * Updates the current quaternion with the given float coordinates
  61624. * @param x defines the x coordinate
  61625. * @param y defines the y coordinate
  61626. * @param z defines the z coordinate
  61627. * @param w defines the w coordinate
  61628. * @returns the updated current quaternion
  61629. */
  61630. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61631. /**
  61632. * Updates the current quaternion from the given float coordinates
  61633. * @param x defines the x coordinate
  61634. * @param y defines the y coordinate
  61635. * @param z defines the z coordinate
  61636. * @param w defines the w coordinate
  61637. * @returns the updated current quaternion
  61638. */
  61639. set(x: number, y: number, z: number, w: number): Quaternion;
  61640. /**
  61641. * Adds two quaternions
  61642. * @param other defines the second operand
  61643. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61644. */
  61645. add(other: DeepImmutable<Quaternion>): Quaternion;
  61646. /**
  61647. * Add a quaternion to the current one
  61648. * @param other defines the quaternion to add
  61649. * @returns the current quaternion
  61650. */
  61651. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61652. /**
  61653. * Subtract two quaternions
  61654. * @param other defines the second operand
  61655. * @returns a new quaternion as the subtraction result of the given one from the current one
  61656. */
  61657. subtract(other: Quaternion): Quaternion;
  61658. /**
  61659. * Multiplies the current quaternion by a scale factor
  61660. * @param value defines the scale factor
  61661. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61662. */
  61663. scale(value: number): Quaternion;
  61664. /**
  61665. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61666. * @param scale defines the scale factor
  61667. * @param result defines the Quaternion object where to store the result
  61668. * @returns the unmodified current quaternion
  61669. */
  61670. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61671. /**
  61672. * Multiplies in place the current quaternion by a scale factor
  61673. * @param value defines the scale factor
  61674. * @returns the current modified quaternion
  61675. */
  61676. scaleInPlace(value: number): Quaternion;
  61677. /**
  61678. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61679. * @param scale defines the scale factor
  61680. * @param result defines the Quaternion object where to store the result
  61681. * @returns the unmodified current quaternion
  61682. */
  61683. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61684. /**
  61685. * Multiplies two quaternions
  61686. * @param q1 defines the second operand
  61687. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61688. */
  61689. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61690. /**
  61691. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61692. * @param q1 defines the second operand
  61693. * @param result defines the target quaternion
  61694. * @returns the current quaternion
  61695. */
  61696. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61697. /**
  61698. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61699. * @param q1 defines the second operand
  61700. * @returns the currentupdated quaternion
  61701. */
  61702. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61703. /**
  61704. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61705. * @param ref defines the target quaternion
  61706. * @returns the current quaternion
  61707. */
  61708. conjugateToRef(ref: Quaternion): Quaternion;
  61709. /**
  61710. * Conjugates in place (1-q) the current quaternion
  61711. * @returns the current updated quaternion
  61712. */
  61713. conjugateInPlace(): Quaternion;
  61714. /**
  61715. * Conjugates in place (1-q) the current quaternion
  61716. * @returns a new quaternion
  61717. */
  61718. conjugate(): Quaternion;
  61719. /**
  61720. * Gets length of current quaternion
  61721. * @returns the quaternion length (float)
  61722. */
  61723. length(): number;
  61724. /**
  61725. * Normalize in place the current quaternion
  61726. * @returns the current updated quaternion
  61727. */
  61728. normalize(): Quaternion;
  61729. /**
  61730. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61731. * @param order is a reserved parameter and is ignore for now
  61732. * @returns a new Vector3 containing the Euler angles
  61733. */
  61734. toEulerAngles(order?: string): Vector3;
  61735. /**
  61736. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61737. * @param result defines the vector which will be filled with the Euler angles
  61738. * @param order is a reserved parameter and is ignore for now
  61739. * @returns the current unchanged quaternion
  61740. */
  61741. toEulerAnglesToRef(result: Vector3): Quaternion;
  61742. /**
  61743. * Updates the given rotation matrix with the current quaternion values
  61744. * @param result defines the target matrix
  61745. * @returns the current unchanged quaternion
  61746. */
  61747. toRotationMatrix(result: Matrix): Quaternion;
  61748. /**
  61749. * Updates the current quaternion from the given rotation matrix values
  61750. * @param matrix defines the source matrix
  61751. * @returns the current updated quaternion
  61752. */
  61753. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61754. /**
  61755. * Creates a new quaternion from a rotation matrix
  61756. * @param matrix defines the source matrix
  61757. * @returns a new quaternion created from the given rotation matrix values
  61758. */
  61759. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61760. /**
  61761. * Updates the given quaternion with the given rotation matrix values
  61762. * @param matrix defines the source matrix
  61763. * @param result defines the target quaternion
  61764. */
  61765. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61766. /**
  61767. * Returns the dot product (float) between the quaternions "left" and "right"
  61768. * @param left defines the left operand
  61769. * @param right defines the right operand
  61770. * @returns the dot product
  61771. */
  61772. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61773. /**
  61774. * Checks if the two quaternions are close to each other
  61775. * @param quat0 defines the first quaternion to check
  61776. * @param quat1 defines the second quaternion to check
  61777. * @returns true if the two quaternions are close to each other
  61778. */
  61779. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61780. /**
  61781. * Creates an empty quaternion
  61782. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61783. */
  61784. static Zero(): Quaternion;
  61785. /**
  61786. * Inverse a given quaternion
  61787. * @param q defines the source quaternion
  61788. * @returns a new quaternion as the inverted current quaternion
  61789. */
  61790. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61791. /**
  61792. * Inverse a given quaternion
  61793. * @param q defines the source quaternion
  61794. * @param result the quaternion the result will be stored in
  61795. * @returns the result quaternion
  61796. */
  61797. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61798. /**
  61799. * Creates an identity quaternion
  61800. * @returns the identity quaternion
  61801. */
  61802. static Identity(): Quaternion;
  61803. /**
  61804. * Gets a boolean indicating if the given quaternion is identity
  61805. * @param quaternion defines the quaternion to check
  61806. * @returns true if the quaternion is identity
  61807. */
  61808. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61809. /**
  61810. * Creates a quaternion from a rotation around an axis
  61811. * @param axis defines the axis to use
  61812. * @param angle defines the angle to use
  61813. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61814. */
  61815. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61816. /**
  61817. * Creates a rotation around an axis and stores it into the given quaternion
  61818. * @param axis defines the axis to use
  61819. * @param angle defines the angle to use
  61820. * @param result defines the target quaternion
  61821. * @returns the target quaternion
  61822. */
  61823. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61824. /**
  61825. * Creates a new quaternion from data stored into an array
  61826. * @param array defines the data source
  61827. * @param offset defines the offset in the source array where the data starts
  61828. * @returns a new quaternion
  61829. */
  61830. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61831. /**
  61832. * Create a quaternion from Euler rotation angles
  61833. * @param x Pitch
  61834. * @param y Yaw
  61835. * @param z Roll
  61836. * @returns the new Quaternion
  61837. */
  61838. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61839. /**
  61840. * Updates a quaternion from Euler rotation angles
  61841. * @param x Pitch
  61842. * @param y Yaw
  61843. * @param z Roll
  61844. * @param result the quaternion to store the result
  61845. * @returns the updated quaternion
  61846. */
  61847. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61848. /**
  61849. * Create a quaternion from Euler rotation vector
  61850. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61851. * @returns the new Quaternion
  61852. */
  61853. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61854. /**
  61855. * Updates a quaternion from Euler rotation vector
  61856. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61857. * @param result the quaternion to store the result
  61858. * @returns the updated quaternion
  61859. */
  61860. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61861. /**
  61862. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61863. * @param yaw defines the rotation around Y axis
  61864. * @param pitch defines the rotation around X axis
  61865. * @param roll defines the rotation around Z axis
  61866. * @returns the new quaternion
  61867. */
  61868. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61869. /**
  61870. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61871. * @param yaw defines the rotation around Y axis
  61872. * @param pitch defines the rotation around X axis
  61873. * @param roll defines the rotation around Z axis
  61874. * @param result defines the target quaternion
  61875. */
  61876. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61877. /**
  61878. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61879. * @param alpha defines the rotation around first axis
  61880. * @param beta defines the rotation around second axis
  61881. * @param gamma defines the rotation around third axis
  61882. * @returns the new quaternion
  61883. */
  61884. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61885. /**
  61886. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61887. * @param alpha defines the rotation around first axis
  61888. * @param beta defines the rotation around second axis
  61889. * @param gamma defines the rotation around third axis
  61890. * @param result defines the target quaternion
  61891. */
  61892. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61893. /**
  61894. * 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)
  61895. * @param axis1 defines the first axis
  61896. * @param axis2 defines the second axis
  61897. * @param axis3 defines the third axis
  61898. * @returns the new quaternion
  61899. */
  61900. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61901. /**
  61902. * 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
  61903. * @param axis1 defines the first axis
  61904. * @param axis2 defines the second axis
  61905. * @param axis3 defines the third axis
  61906. * @param ref defines the target quaternion
  61907. */
  61908. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61909. /**
  61910. * Interpolates between two quaternions
  61911. * @param left defines first quaternion
  61912. * @param right defines second quaternion
  61913. * @param amount defines the gradient to use
  61914. * @returns the new interpolated quaternion
  61915. */
  61916. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61917. /**
  61918. * Interpolates between two quaternions and stores it into a target quaternion
  61919. * @param left defines first quaternion
  61920. * @param right defines second quaternion
  61921. * @param amount defines the gradient to use
  61922. * @param result defines the target quaternion
  61923. */
  61924. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61925. /**
  61926. * Interpolate between two quaternions using Hermite interpolation
  61927. * @param value1 defines first quaternion
  61928. * @param tangent1 defines the incoming tangent
  61929. * @param value2 defines second quaternion
  61930. * @param tangent2 defines the outgoing tangent
  61931. * @param amount defines the target quaternion
  61932. * @returns the new interpolated quaternion
  61933. */
  61934. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61935. }
  61936. /**
  61937. * Class used to store matrix data (4x4)
  61938. */
  61939. export class Matrix {
  61940. private static _updateFlagSeed;
  61941. private static _identityReadOnly;
  61942. private _isIdentity;
  61943. private _isIdentityDirty;
  61944. private _isIdentity3x2;
  61945. private _isIdentity3x2Dirty;
  61946. /**
  61947. * Gets the update flag of the matrix which is an unique number for the matrix.
  61948. * It will be incremented every time the matrix data change.
  61949. * You can use it to speed the comparison between two versions of the same matrix.
  61950. */
  61951. updateFlag: number;
  61952. private readonly _m;
  61953. /**
  61954. * Gets the internal data of the matrix
  61955. */
  61956. readonly m: DeepImmutable<Float32Array>;
  61957. /** @hidden */
  61958. _markAsUpdated(): void;
  61959. /** @hidden */
  61960. private _updateIdentityStatus;
  61961. /**
  61962. * Creates an empty matrix (filled with zeros)
  61963. */
  61964. constructor();
  61965. /**
  61966. * Check if the current matrix is identity
  61967. * @returns true is the matrix is the identity matrix
  61968. */
  61969. isIdentity(): boolean;
  61970. /**
  61971. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61972. * @returns true is the matrix is the identity matrix
  61973. */
  61974. isIdentityAs3x2(): boolean;
  61975. /**
  61976. * Gets the determinant of the matrix
  61977. * @returns the matrix determinant
  61978. */
  61979. determinant(): number;
  61980. /**
  61981. * Returns the matrix as a Float32Array
  61982. * @returns the matrix underlying array
  61983. */
  61984. toArray(): DeepImmutable<Float32Array>;
  61985. /**
  61986. * Returns the matrix as a Float32Array
  61987. * @returns the matrix underlying array.
  61988. */
  61989. asArray(): DeepImmutable<Float32Array>;
  61990. /**
  61991. * Inverts the current matrix in place
  61992. * @returns the current inverted matrix
  61993. */
  61994. invert(): Matrix;
  61995. /**
  61996. * Sets all the matrix elements to zero
  61997. * @returns the current matrix
  61998. */
  61999. reset(): Matrix;
  62000. /**
  62001. * Adds the current matrix with a second one
  62002. * @param other defines the matrix to add
  62003. * @returns a new matrix as the addition of the current matrix and the given one
  62004. */
  62005. add(other: DeepImmutable<Matrix>): Matrix;
  62006. /**
  62007. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62008. * @param other defines the matrix to add
  62009. * @param result defines the target matrix
  62010. * @returns the current matrix
  62011. */
  62012. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62013. /**
  62014. * Adds in place the given matrix to the current matrix
  62015. * @param other defines the second operand
  62016. * @returns the current updated matrix
  62017. */
  62018. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62019. /**
  62020. * Sets the given matrix to the current inverted Matrix
  62021. * @param other defines the target matrix
  62022. * @returns the unmodified current matrix
  62023. */
  62024. invertToRef(other: Matrix): Matrix;
  62025. /**
  62026. * add a value at the specified position in the current Matrix
  62027. * @param index the index of the value within the matrix. between 0 and 15.
  62028. * @param value the value to be added
  62029. * @returns the current updated matrix
  62030. */
  62031. addAtIndex(index: number, value: number): Matrix;
  62032. /**
  62033. * mutiply the specified position in the current Matrix by a value
  62034. * @param index the index of the value within the matrix. between 0 and 15.
  62035. * @param value the value to be added
  62036. * @returns the current updated matrix
  62037. */
  62038. multiplyAtIndex(index: number, value: number): Matrix;
  62039. /**
  62040. * Inserts the translation vector (using 3 floats) in the current matrix
  62041. * @param x defines the 1st component of the translation
  62042. * @param y defines the 2nd component of the translation
  62043. * @param z defines the 3rd component of the translation
  62044. * @returns the current updated matrix
  62045. */
  62046. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62047. /**
  62048. * Inserts the translation vector in the current matrix
  62049. * @param vector3 defines the translation to insert
  62050. * @returns the current updated matrix
  62051. */
  62052. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62053. /**
  62054. * Gets the translation value of the current matrix
  62055. * @returns a new Vector3 as the extracted translation from the matrix
  62056. */
  62057. getTranslation(): Vector3;
  62058. /**
  62059. * Fill a Vector3 with the extracted translation from the matrix
  62060. * @param result defines the Vector3 where to store the translation
  62061. * @returns the current matrix
  62062. */
  62063. getTranslationToRef(result: Vector3): Matrix;
  62064. /**
  62065. * Remove rotation and scaling part from the matrix
  62066. * @returns the updated matrix
  62067. */
  62068. removeRotationAndScaling(): Matrix;
  62069. /**
  62070. * Multiply two matrices
  62071. * @param other defines the second operand
  62072. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62073. */
  62074. multiply(other: DeepImmutable<Matrix>): Matrix;
  62075. /**
  62076. * Copy the current matrix from the given one
  62077. * @param other defines the source matrix
  62078. * @returns the current updated matrix
  62079. */
  62080. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62081. /**
  62082. * Populates the given array from the starting index with the current matrix values
  62083. * @param array defines the target array
  62084. * @param offset defines the offset in the target array where to start storing values
  62085. * @returns the current matrix
  62086. */
  62087. copyToArray(array: Float32Array, offset?: number): Matrix;
  62088. /**
  62089. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62090. * @param other defines the second operand
  62091. * @param result defines the matrix where to store the multiplication
  62092. * @returns the current matrix
  62093. */
  62094. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62095. /**
  62096. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62097. * @param other defines the second operand
  62098. * @param result defines the array where to store the multiplication
  62099. * @param offset defines the offset in the target array where to start storing values
  62100. * @returns the current matrix
  62101. */
  62102. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62103. /**
  62104. * Check equality between this matrix and a second one
  62105. * @param value defines the second matrix to compare
  62106. * @returns true is the current matrix and the given one values are strictly equal
  62107. */
  62108. equals(value: DeepImmutable<Matrix>): boolean;
  62109. /**
  62110. * Clone the current matrix
  62111. * @returns a new matrix from the current matrix
  62112. */
  62113. clone(): Matrix;
  62114. /**
  62115. * Returns the name of the current matrix class
  62116. * @returns the string "Matrix"
  62117. */
  62118. getClassName(): string;
  62119. /**
  62120. * Gets the hash code of the current matrix
  62121. * @returns the hash code
  62122. */
  62123. getHashCode(): number;
  62124. /**
  62125. * Decomposes the current Matrix into a translation, rotation and scaling components
  62126. * @param scale defines the scale vector3 given as a reference to update
  62127. * @param rotation defines the rotation quaternion given as a reference to update
  62128. * @param translation defines the translation vector3 given as a reference to update
  62129. * @returns true if operation was successful
  62130. */
  62131. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62132. /**
  62133. * Gets specific row of the matrix
  62134. * @param index defines the number of the row to get
  62135. * @returns the index-th row of the current matrix as a new Vector4
  62136. */
  62137. getRow(index: number): Nullable<Vector4>;
  62138. /**
  62139. * Sets the index-th row of the current matrix to the vector4 values
  62140. * @param index defines the number of the row to set
  62141. * @param row defines the target vector4
  62142. * @returns the updated current matrix
  62143. */
  62144. setRow(index: number, row: Vector4): Matrix;
  62145. /**
  62146. * Compute the transpose of the matrix
  62147. * @returns the new transposed matrix
  62148. */
  62149. transpose(): Matrix;
  62150. /**
  62151. * Compute the transpose of the matrix and store it in a given matrix
  62152. * @param result defines the target matrix
  62153. * @returns the current matrix
  62154. */
  62155. transposeToRef(result: Matrix): Matrix;
  62156. /**
  62157. * Sets the index-th row of the current matrix with the given 4 x float values
  62158. * @param index defines the row index
  62159. * @param x defines the x component to set
  62160. * @param y defines the y component to set
  62161. * @param z defines the z component to set
  62162. * @param w defines the w component to set
  62163. * @returns the updated current matrix
  62164. */
  62165. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62166. /**
  62167. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62168. * @param scale defines the scale factor
  62169. * @returns a new matrix
  62170. */
  62171. scale(scale: number): Matrix;
  62172. /**
  62173. * Scale the current matrix values by a factor to a given result matrix
  62174. * @param scale defines the scale factor
  62175. * @param result defines the matrix to store the result
  62176. * @returns the current matrix
  62177. */
  62178. scaleToRef(scale: number, result: Matrix): Matrix;
  62179. /**
  62180. * Scale the current matrix values by a factor and add the result to a given matrix
  62181. * @param scale defines the scale factor
  62182. * @param result defines the Matrix to store the result
  62183. * @returns the current matrix
  62184. */
  62185. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62186. /**
  62187. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62188. * @param ref matrix to store the result
  62189. */
  62190. toNormalMatrix(ref: Matrix): void;
  62191. /**
  62192. * Gets only rotation part of the current matrix
  62193. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62194. */
  62195. getRotationMatrix(): Matrix;
  62196. /**
  62197. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62198. * @param result defines the target matrix to store data to
  62199. * @returns the current matrix
  62200. */
  62201. getRotationMatrixToRef(result: Matrix): Matrix;
  62202. /**
  62203. * Toggles model matrix from being right handed to left handed in place and vice versa
  62204. */
  62205. toggleModelMatrixHandInPlace(): void;
  62206. /**
  62207. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62208. */
  62209. toggleProjectionMatrixHandInPlace(): void;
  62210. /**
  62211. * Creates a matrix from an array
  62212. * @param array defines the source array
  62213. * @param offset defines an offset in the source array
  62214. * @returns a new Matrix set from the starting index of the given array
  62215. */
  62216. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62217. /**
  62218. * Copy the content of an array into a given matrix
  62219. * @param array defines the source array
  62220. * @param offset defines an offset in the source array
  62221. * @param result defines the target matrix
  62222. */
  62223. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62224. /**
  62225. * Stores an array into a matrix after having multiplied each component by a given factor
  62226. * @param array defines the source array
  62227. * @param offset defines the offset in the source array
  62228. * @param scale defines the scaling factor
  62229. * @param result defines the target matrix
  62230. */
  62231. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62232. /**
  62233. * Gets an identity matrix that must not be updated
  62234. */
  62235. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62236. /**
  62237. * Stores a list of values (16) inside a given matrix
  62238. * @param initialM11 defines 1st value of 1st row
  62239. * @param initialM12 defines 2nd value of 1st row
  62240. * @param initialM13 defines 3rd value of 1st row
  62241. * @param initialM14 defines 4th value of 1st row
  62242. * @param initialM21 defines 1st value of 2nd row
  62243. * @param initialM22 defines 2nd value of 2nd row
  62244. * @param initialM23 defines 3rd value of 2nd row
  62245. * @param initialM24 defines 4th value of 2nd row
  62246. * @param initialM31 defines 1st value of 3rd row
  62247. * @param initialM32 defines 2nd value of 3rd row
  62248. * @param initialM33 defines 3rd value of 3rd row
  62249. * @param initialM34 defines 4th value of 3rd row
  62250. * @param initialM41 defines 1st value of 4th row
  62251. * @param initialM42 defines 2nd value of 4th row
  62252. * @param initialM43 defines 3rd value of 4th row
  62253. * @param initialM44 defines 4th value of 4th row
  62254. * @param result defines the target matrix
  62255. */
  62256. 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;
  62257. /**
  62258. * Creates new matrix from a list of values (16)
  62259. * @param initialM11 defines 1st value of 1st row
  62260. * @param initialM12 defines 2nd value of 1st row
  62261. * @param initialM13 defines 3rd value of 1st row
  62262. * @param initialM14 defines 4th value of 1st row
  62263. * @param initialM21 defines 1st value of 2nd row
  62264. * @param initialM22 defines 2nd value of 2nd row
  62265. * @param initialM23 defines 3rd value of 2nd row
  62266. * @param initialM24 defines 4th value of 2nd row
  62267. * @param initialM31 defines 1st value of 3rd row
  62268. * @param initialM32 defines 2nd value of 3rd row
  62269. * @param initialM33 defines 3rd value of 3rd row
  62270. * @param initialM34 defines 4th value of 3rd row
  62271. * @param initialM41 defines 1st value of 4th row
  62272. * @param initialM42 defines 2nd value of 4th row
  62273. * @param initialM43 defines 3rd value of 4th row
  62274. * @param initialM44 defines 4th value of 4th row
  62275. * @returns the new matrix
  62276. */
  62277. 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;
  62278. /**
  62279. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62280. * @param scale defines the scale vector3
  62281. * @param rotation defines the rotation quaternion
  62282. * @param translation defines the translation vector3
  62283. * @returns a new matrix
  62284. */
  62285. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62286. /**
  62287. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62288. * @param scale defines the scale vector3
  62289. * @param rotation defines the rotation quaternion
  62290. * @param translation defines the translation vector3
  62291. * @param result defines the target matrix
  62292. */
  62293. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62294. /**
  62295. * Creates a new identity matrix
  62296. * @returns a new identity matrix
  62297. */
  62298. static Identity(): Matrix;
  62299. /**
  62300. * Creates a new identity matrix and stores the result in a given matrix
  62301. * @param result defines the target matrix
  62302. */
  62303. static IdentityToRef(result: Matrix): void;
  62304. /**
  62305. * Creates a new zero matrix
  62306. * @returns a new zero matrix
  62307. */
  62308. static Zero(): Matrix;
  62309. /**
  62310. * Creates a new rotation matrix for "angle" radians around the X axis
  62311. * @param angle defines the angle (in radians) to use
  62312. * @return the new matrix
  62313. */
  62314. static RotationX(angle: number): Matrix;
  62315. /**
  62316. * Creates a new matrix as the invert of a given matrix
  62317. * @param source defines the source matrix
  62318. * @returns the new matrix
  62319. */
  62320. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62321. /**
  62322. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62323. * @param angle defines the angle (in radians) to use
  62324. * @param result defines the target matrix
  62325. */
  62326. static RotationXToRef(angle: number, result: Matrix): void;
  62327. /**
  62328. * Creates a new rotation matrix for "angle" radians around the Y axis
  62329. * @param angle defines the angle (in radians) to use
  62330. * @return the new matrix
  62331. */
  62332. static RotationY(angle: number): Matrix;
  62333. /**
  62334. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62335. * @param angle defines the angle (in radians) to use
  62336. * @param result defines the target matrix
  62337. */
  62338. static RotationYToRef(angle: number, result: Matrix): void;
  62339. /**
  62340. * Creates a new rotation matrix for "angle" radians around the Z axis
  62341. * @param angle defines the angle (in radians) to use
  62342. * @return the new matrix
  62343. */
  62344. static RotationZ(angle: number): Matrix;
  62345. /**
  62346. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62347. * @param angle defines the angle (in radians) to use
  62348. * @param result defines the target matrix
  62349. */
  62350. static RotationZToRef(angle: number, result: Matrix): void;
  62351. /**
  62352. * Creates a new rotation matrix for "angle" radians around the given axis
  62353. * @param axis defines the axis to use
  62354. * @param angle defines the angle (in radians) to use
  62355. * @return the new matrix
  62356. */
  62357. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62358. /**
  62359. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62360. * @param axis defines the axis to use
  62361. * @param angle defines the angle (in radians) to use
  62362. * @param result defines the target matrix
  62363. */
  62364. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62365. /**
  62366. * Creates a rotation matrix
  62367. * @param yaw defines the yaw angle in radians (Y axis)
  62368. * @param pitch defines the pitch angle in radians (X axis)
  62369. * @param roll defines the roll angle in radians (X axis)
  62370. * @returns the new rotation matrix
  62371. */
  62372. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62373. /**
  62374. * Creates a rotation matrix and stores it in a given matrix
  62375. * @param yaw defines the yaw angle in radians (Y axis)
  62376. * @param pitch defines the pitch angle in radians (X axis)
  62377. * @param roll defines the roll angle in radians (X axis)
  62378. * @param result defines the target matrix
  62379. */
  62380. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62381. /**
  62382. * Creates a scaling matrix
  62383. * @param x defines the scale factor on X axis
  62384. * @param y defines the scale factor on Y axis
  62385. * @param z defines the scale factor on Z axis
  62386. * @returns the new matrix
  62387. */
  62388. static Scaling(x: number, y: number, z: number): Matrix;
  62389. /**
  62390. * Creates a scaling matrix and stores it in a given matrix
  62391. * @param x defines the scale factor on X axis
  62392. * @param y defines the scale factor on Y axis
  62393. * @param z defines the scale factor on Z axis
  62394. * @param result defines the target matrix
  62395. */
  62396. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62397. /**
  62398. * Creates a translation matrix
  62399. * @param x defines the translation on X axis
  62400. * @param y defines the translation on Y axis
  62401. * @param z defines the translationon Z axis
  62402. * @returns the new matrix
  62403. */
  62404. static Translation(x: number, y: number, z: number): Matrix;
  62405. /**
  62406. * Creates a translation matrix and stores it in a given matrix
  62407. * @param x defines the translation on X axis
  62408. * @param y defines the translation on Y axis
  62409. * @param z defines the translationon Z axis
  62410. * @param result defines the target matrix
  62411. */
  62412. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62413. /**
  62414. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62415. * @param startValue defines the start value
  62416. * @param endValue defines the end value
  62417. * @param gradient defines the gradient factor
  62418. * @returns the new matrix
  62419. */
  62420. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62421. /**
  62422. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62423. * @param startValue defines the start value
  62424. * @param endValue defines the end value
  62425. * @param gradient defines the gradient factor
  62426. * @param result defines the Matrix object where to store data
  62427. */
  62428. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62429. /**
  62430. * Builds a new matrix whose values are computed by:
  62431. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62432. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62433. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62434. * @param startValue defines the first matrix
  62435. * @param endValue defines the second matrix
  62436. * @param gradient defines the gradient between the two matrices
  62437. * @returns the new matrix
  62438. */
  62439. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62440. /**
  62441. * Update a matrix to values which are computed by:
  62442. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62443. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62444. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62445. * @param startValue defines the first matrix
  62446. * @param endValue defines the second matrix
  62447. * @param gradient defines the gradient between the two matrices
  62448. * @param result defines the target matrix
  62449. */
  62450. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62451. /**
  62452. * 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"
  62453. * This function works in left handed mode
  62454. * @param eye defines the final position of the entity
  62455. * @param target defines where the entity should look at
  62456. * @param up defines the up vector for the entity
  62457. * @returns the new matrix
  62458. */
  62459. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62460. /**
  62461. * 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".
  62462. * This function works in left handed mode
  62463. * @param eye defines the final position of the entity
  62464. * @param target defines where the entity should look at
  62465. * @param up defines the up vector for the entity
  62466. * @param result defines the target matrix
  62467. */
  62468. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62469. /**
  62470. * 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"
  62471. * This function works in right handed mode
  62472. * @param eye defines the final position of the entity
  62473. * @param target defines where the entity should look at
  62474. * @param up defines the up vector for the entity
  62475. * @returns the new matrix
  62476. */
  62477. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62478. /**
  62479. * 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".
  62480. * This function works in right handed mode
  62481. * @param eye defines the final position of the entity
  62482. * @param target defines where the entity should look at
  62483. * @param up defines the up vector for the entity
  62484. * @param result defines the target matrix
  62485. */
  62486. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62487. /**
  62488. * Create a left-handed orthographic projection matrix
  62489. * @param width defines the viewport width
  62490. * @param height defines the viewport height
  62491. * @param znear defines the near clip plane
  62492. * @param zfar defines the far clip plane
  62493. * @returns a new matrix as a left-handed orthographic projection matrix
  62494. */
  62495. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62496. /**
  62497. * Store a left-handed orthographic projection to a given matrix
  62498. * @param width defines the viewport width
  62499. * @param height defines the viewport height
  62500. * @param znear defines the near clip plane
  62501. * @param zfar defines the far clip plane
  62502. * @param result defines the target matrix
  62503. */
  62504. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62505. /**
  62506. * Create a left-handed orthographic projection matrix
  62507. * @param left defines the viewport left coordinate
  62508. * @param right defines the viewport right coordinate
  62509. * @param bottom defines the viewport bottom coordinate
  62510. * @param top defines the viewport top coordinate
  62511. * @param znear defines the near clip plane
  62512. * @param zfar defines the far clip plane
  62513. * @returns a new matrix as a left-handed orthographic projection matrix
  62514. */
  62515. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62516. /**
  62517. * Stores a left-handed orthographic projection into a given matrix
  62518. * @param left defines the viewport left coordinate
  62519. * @param right defines the viewport right coordinate
  62520. * @param bottom defines the viewport bottom coordinate
  62521. * @param top defines the viewport top coordinate
  62522. * @param znear defines the near clip plane
  62523. * @param zfar defines the far clip plane
  62524. * @param result defines the target matrix
  62525. */
  62526. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62527. /**
  62528. * Creates a right-handed orthographic projection matrix
  62529. * @param left defines the viewport left coordinate
  62530. * @param right defines the viewport right coordinate
  62531. * @param bottom defines the viewport bottom coordinate
  62532. * @param top defines the viewport top coordinate
  62533. * @param znear defines the near clip plane
  62534. * @param zfar defines the far clip plane
  62535. * @returns a new matrix as a right-handed orthographic projection matrix
  62536. */
  62537. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62538. /**
  62539. * Stores a right-handed orthographic projection into a given matrix
  62540. * @param left defines the viewport left coordinate
  62541. * @param right defines the viewport right coordinate
  62542. * @param bottom defines the viewport bottom coordinate
  62543. * @param top defines the viewport top coordinate
  62544. * @param znear defines the near clip plane
  62545. * @param zfar defines the far clip plane
  62546. * @param result defines the target matrix
  62547. */
  62548. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62549. /**
  62550. * Creates a left-handed perspective projection matrix
  62551. * @param width defines the viewport width
  62552. * @param height defines the viewport height
  62553. * @param znear defines the near clip plane
  62554. * @param zfar defines the far clip plane
  62555. * @returns a new matrix as a left-handed perspective projection matrix
  62556. */
  62557. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62558. /**
  62559. * Creates a left-handed perspective projection matrix
  62560. * @param fov defines the horizontal field of view
  62561. * @param aspect defines the aspect ratio
  62562. * @param znear defines the near clip plane
  62563. * @param zfar defines the far clip plane
  62564. * @returns a new matrix as a left-handed perspective projection matrix
  62565. */
  62566. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62567. /**
  62568. * Stores a left-handed perspective projection into a given matrix
  62569. * @param fov defines the horizontal field of view
  62570. * @param aspect defines the aspect ratio
  62571. * @param znear defines the near clip plane
  62572. * @param zfar defines the far clip plane
  62573. * @param result defines the target matrix
  62574. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62575. */
  62576. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62577. /**
  62578. * Creates a right-handed perspective projection matrix
  62579. * @param fov defines the horizontal field of view
  62580. * @param aspect defines the aspect ratio
  62581. * @param znear defines the near clip plane
  62582. * @param zfar defines the far clip plane
  62583. * @returns a new matrix as a right-handed perspective projection matrix
  62584. */
  62585. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62586. /**
  62587. * Stores a right-handed perspective projection into a given matrix
  62588. * @param fov defines the horizontal field of view
  62589. * @param aspect defines the aspect ratio
  62590. * @param znear defines the near clip plane
  62591. * @param zfar defines the far clip plane
  62592. * @param result defines the target matrix
  62593. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62594. */
  62595. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62596. /**
  62597. * Stores a perspective projection for WebVR info a given matrix
  62598. * @param fov defines the field of view
  62599. * @param znear defines the near clip plane
  62600. * @param zfar defines the far clip plane
  62601. * @param result defines the target matrix
  62602. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62603. */
  62604. static PerspectiveFovWebVRToRef(fov: {
  62605. upDegrees: number;
  62606. downDegrees: number;
  62607. leftDegrees: number;
  62608. rightDegrees: number;
  62609. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62610. /**
  62611. * Computes a complete transformation matrix
  62612. * @param viewport defines the viewport to use
  62613. * @param world defines the world matrix
  62614. * @param view defines the view matrix
  62615. * @param projection defines the projection matrix
  62616. * @param zmin defines the near clip plane
  62617. * @param zmax defines the far clip plane
  62618. * @returns the transformation matrix
  62619. */
  62620. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62621. /**
  62622. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62623. * @param matrix defines the matrix to use
  62624. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62625. */
  62626. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62627. /**
  62628. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62629. * @param matrix defines the matrix to use
  62630. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62631. */
  62632. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62633. /**
  62634. * Compute the transpose of a given matrix
  62635. * @param matrix defines the matrix to transpose
  62636. * @returns the new matrix
  62637. */
  62638. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62639. /**
  62640. * Compute the transpose of a matrix and store it in a target matrix
  62641. * @param matrix defines the matrix to transpose
  62642. * @param result defines the target matrix
  62643. */
  62644. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62645. /**
  62646. * Computes a reflection matrix from a plane
  62647. * @param plane defines the reflection plane
  62648. * @returns a new matrix
  62649. */
  62650. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62651. /**
  62652. * Computes a reflection matrix from a plane
  62653. * @param plane defines the reflection plane
  62654. * @param result defines the target matrix
  62655. */
  62656. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62657. /**
  62658. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62659. * @param xaxis defines the value of the 1st axis
  62660. * @param yaxis defines the value of the 2nd axis
  62661. * @param zaxis defines the value of the 3rd axis
  62662. * @param result defines the target matrix
  62663. */
  62664. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62665. /**
  62666. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62667. * @param quat defines the quaternion to use
  62668. * @param result defines the target matrix
  62669. */
  62670. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62671. }
  62672. /**
  62673. * Represens a plane by the equation ax + by + cz + d = 0
  62674. */
  62675. export class Plane {
  62676. /**
  62677. * Normal of the plane (a,b,c)
  62678. */
  62679. normal: Vector3;
  62680. /**
  62681. * d component of the plane
  62682. */
  62683. d: number;
  62684. /**
  62685. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62686. * @param a a component of the plane
  62687. * @param b b component of the plane
  62688. * @param c c component of the plane
  62689. * @param d d component of the plane
  62690. */
  62691. constructor(a: number, b: number, c: number, d: number);
  62692. /**
  62693. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62694. */
  62695. asArray(): number[];
  62696. /**
  62697. * @returns a new plane copied from the current Plane.
  62698. */
  62699. clone(): Plane;
  62700. /**
  62701. * @returns the string "Plane".
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * @returns the Plane hash code.
  62706. */
  62707. getHashCode(): number;
  62708. /**
  62709. * Normalize the current Plane in place.
  62710. * @returns the updated Plane.
  62711. */
  62712. normalize(): Plane;
  62713. /**
  62714. * Applies a transformation the plane and returns the result
  62715. * @param transformation the transformation matrix to be applied to the plane
  62716. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62717. */
  62718. transform(transformation: DeepImmutable<Matrix>): Plane;
  62719. /**
  62720. * Calcualtte the dot product between the point and the plane normal
  62721. * @param point point to calculate the dot product with
  62722. * @returns the dot product (float) of the point coordinates and the plane normal.
  62723. */
  62724. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62725. /**
  62726. * Updates the current Plane from the plane defined by the three given points.
  62727. * @param point1 one of the points used to contruct the plane
  62728. * @param point2 one of the points used to contruct the plane
  62729. * @param point3 one of the points used to contruct the plane
  62730. * @returns the updated Plane.
  62731. */
  62732. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62733. /**
  62734. * Checks if the plane is facing a given direction
  62735. * @param direction the direction to check if the plane is facing
  62736. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62737. * @returns True is the vector "direction" is the same side than the plane normal.
  62738. */
  62739. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62740. /**
  62741. * Calculates the distance to a point
  62742. * @param point point to calculate distance to
  62743. * @returns the signed distance (float) from the given point to the Plane.
  62744. */
  62745. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62746. /**
  62747. * Creates a plane from an array
  62748. * @param array the array to create a plane from
  62749. * @returns a new Plane from the given array.
  62750. */
  62751. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62752. /**
  62753. * Creates a plane from three points
  62754. * @param point1 point used to create the plane
  62755. * @param point2 point used to create the plane
  62756. * @param point3 point used to create the plane
  62757. * @returns a new Plane defined by the three given points.
  62758. */
  62759. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62760. /**
  62761. * Creates a plane from an origin point and a normal
  62762. * @param origin origin of the plane to be constructed
  62763. * @param normal normal of the plane to be constructed
  62764. * @returns a new Plane the normal vector to this plane at the given origin point.
  62765. * Note : the vector "normal" is updated because normalized.
  62766. */
  62767. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62768. /**
  62769. * Calculates the distance from a plane and a point
  62770. * @param origin origin of the plane to be constructed
  62771. * @param normal normal of the plane to be constructed
  62772. * @param point point to calculate distance to
  62773. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62774. */
  62775. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62776. }
  62777. /**
  62778. * Class used to represent a viewport on screen
  62779. */
  62780. export class Viewport {
  62781. /** viewport left coordinate */
  62782. x: number;
  62783. /** viewport top coordinate */
  62784. y: number;
  62785. /**viewport width */
  62786. width: number;
  62787. /** viewport height */
  62788. height: number;
  62789. /**
  62790. * Creates a Viewport object located at (x, y) and sized (width, height)
  62791. * @param x defines viewport left coordinate
  62792. * @param y defines viewport top coordinate
  62793. * @param width defines the viewport width
  62794. * @param height defines the viewport height
  62795. */
  62796. constructor(
  62797. /** viewport left coordinate */
  62798. x: number,
  62799. /** viewport top coordinate */
  62800. y: number,
  62801. /**viewport width */
  62802. width: number,
  62803. /** viewport height */
  62804. height: number);
  62805. /**
  62806. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62807. * @param renderWidth defines the rendering width
  62808. * @param renderHeight defines the rendering height
  62809. * @returns a new Viewport
  62810. */
  62811. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62812. /**
  62813. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62814. * @param renderWidth defines the rendering width
  62815. * @param renderHeight defines the rendering height
  62816. * @param ref defines the target viewport
  62817. * @returns the current viewport
  62818. */
  62819. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62820. /**
  62821. * Returns a new Viewport copied from the current one
  62822. * @returns a new Viewport
  62823. */
  62824. clone(): Viewport;
  62825. }
  62826. /**
  62827. * Reprasents a camera frustum
  62828. */
  62829. export class Frustum {
  62830. /**
  62831. * Gets the planes representing the frustum
  62832. * @param transform matrix to be applied to the returned planes
  62833. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62834. */
  62835. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62836. /**
  62837. * Gets the near frustum plane transformed by the transform matrix
  62838. * @param transform transformation matrix to be applied to the resulting frustum plane
  62839. * @param frustumPlane the resuling frustum plane
  62840. */
  62841. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62842. /**
  62843. * Gets the far frustum plane transformed by the transform matrix
  62844. * @param transform transformation matrix to be applied to the resulting frustum plane
  62845. * @param frustumPlane the resuling frustum plane
  62846. */
  62847. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62848. /**
  62849. * Gets the left frustum plane transformed by the transform matrix
  62850. * @param transform transformation matrix to be applied to the resulting frustum plane
  62851. * @param frustumPlane the resuling frustum plane
  62852. */
  62853. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62854. /**
  62855. * Gets the right frustum plane transformed by the transform matrix
  62856. * @param transform transformation matrix to be applied to the resulting frustum plane
  62857. * @param frustumPlane the resuling frustum plane
  62858. */
  62859. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62860. /**
  62861. * Gets the top frustum plane transformed by the transform matrix
  62862. * @param transform transformation matrix to be applied to the resulting frustum plane
  62863. * @param frustumPlane the resuling frustum plane
  62864. */
  62865. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62866. /**
  62867. * Gets the bottom frustum plane transformed by the transform matrix
  62868. * @param transform transformation matrix to be applied to the resulting frustum plane
  62869. * @param frustumPlane the resuling frustum plane
  62870. */
  62871. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62872. /**
  62873. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62874. * @param transform transformation matrix to be applied to the resulting frustum planes
  62875. * @param frustumPlanes the resuling frustum planes
  62876. */
  62877. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62878. }
  62879. /** Defines supported spaces */
  62880. export enum Space {
  62881. /** Local (object) space */
  62882. LOCAL = 0,
  62883. /** World space */
  62884. WORLD = 1,
  62885. /** Bone space */
  62886. BONE = 2
  62887. }
  62888. /** Defines the 3 main axes */
  62889. export class Axis {
  62890. /** X axis */
  62891. static X: Vector3;
  62892. /** Y axis */
  62893. static Y: Vector3;
  62894. /** Z axis */
  62895. static Z: Vector3;
  62896. }
  62897. /** Class used to represent a Bezier curve */
  62898. export class BezierCurve {
  62899. /**
  62900. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62901. * @param t defines the time
  62902. * @param x1 defines the left coordinate on X axis
  62903. * @param y1 defines the left coordinate on Y axis
  62904. * @param x2 defines the right coordinate on X axis
  62905. * @param y2 defines the right coordinate on Y axis
  62906. * @returns the interpolated value
  62907. */
  62908. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62909. }
  62910. /**
  62911. * Defines potential orientation for back face culling
  62912. */
  62913. export enum Orientation {
  62914. /**
  62915. * Clockwise
  62916. */
  62917. CW = 0,
  62918. /** Counter clockwise */
  62919. CCW = 1
  62920. }
  62921. /**
  62922. * Defines angle representation
  62923. */
  62924. export class Angle {
  62925. private _radians;
  62926. /**
  62927. * Creates an Angle object of "radians" radians (float).
  62928. * @param radians the angle in radians
  62929. */
  62930. constructor(radians: number);
  62931. /**
  62932. * Get value in degrees
  62933. * @returns the Angle value in degrees (float)
  62934. */
  62935. degrees(): number;
  62936. /**
  62937. * Get value in radians
  62938. * @returns the Angle value in radians (float)
  62939. */
  62940. radians(): number;
  62941. /**
  62942. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62943. * @param a defines first vector
  62944. * @param b defines second vector
  62945. * @returns a new Angle
  62946. */
  62947. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62948. /**
  62949. * Gets a new Angle object from the given float in radians
  62950. * @param radians defines the angle value in radians
  62951. * @returns a new Angle
  62952. */
  62953. static FromRadians(radians: number): Angle;
  62954. /**
  62955. * Gets a new Angle object from the given float in degrees
  62956. * @param degrees defines the angle value in degrees
  62957. * @returns a new Angle
  62958. */
  62959. static FromDegrees(degrees: number): Angle;
  62960. }
  62961. /**
  62962. * This represents an arc in a 2d space.
  62963. */
  62964. export class Arc2 {
  62965. /** Defines the start point of the arc */
  62966. startPoint: Vector2;
  62967. /** Defines the mid point of the arc */
  62968. midPoint: Vector2;
  62969. /** Defines the end point of the arc */
  62970. endPoint: Vector2;
  62971. /**
  62972. * Defines the center point of the arc.
  62973. */
  62974. centerPoint: Vector2;
  62975. /**
  62976. * Defines the radius of the arc.
  62977. */
  62978. radius: number;
  62979. /**
  62980. * Defines the angle of the arc (from mid point to end point).
  62981. */
  62982. angle: Angle;
  62983. /**
  62984. * Defines the start angle of the arc (from start point to middle point).
  62985. */
  62986. startAngle: Angle;
  62987. /**
  62988. * Defines the orientation of the arc (clock wise/counter clock wise).
  62989. */
  62990. orientation: Orientation;
  62991. /**
  62992. * Creates an Arc object from the three given points : start, middle and end.
  62993. * @param startPoint Defines the start point of the arc
  62994. * @param midPoint Defines the midlle point of the arc
  62995. * @param endPoint Defines the end point of the arc
  62996. */
  62997. constructor(
  62998. /** Defines the start point of the arc */
  62999. startPoint: Vector2,
  63000. /** Defines the mid point of the arc */
  63001. midPoint: Vector2,
  63002. /** Defines the end point of the arc */
  63003. endPoint: Vector2);
  63004. }
  63005. /**
  63006. * Represents a 2D path made up of multiple 2D points
  63007. */
  63008. export class Path2 {
  63009. private _points;
  63010. private _length;
  63011. /**
  63012. * If the path start and end point are the same
  63013. */
  63014. closed: boolean;
  63015. /**
  63016. * Creates a Path2 object from the starting 2D coordinates x and y.
  63017. * @param x the starting points x value
  63018. * @param y the starting points y value
  63019. */
  63020. constructor(x: number, y: number);
  63021. /**
  63022. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63023. * @param x the added points x value
  63024. * @param y the added points y value
  63025. * @returns the updated Path2.
  63026. */
  63027. addLineTo(x: number, y: number): Path2;
  63028. /**
  63029. * 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.
  63030. * @param midX middle point x value
  63031. * @param midY middle point y value
  63032. * @param endX end point x value
  63033. * @param endY end point y value
  63034. * @param numberOfSegments (default: 36)
  63035. * @returns the updated Path2.
  63036. */
  63037. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63038. /**
  63039. * Closes the Path2.
  63040. * @returns the Path2.
  63041. */
  63042. close(): Path2;
  63043. /**
  63044. * Gets the sum of the distance between each sequential point in the path
  63045. * @returns the Path2 total length (float).
  63046. */
  63047. length(): number;
  63048. /**
  63049. * Gets the points which construct the path
  63050. * @returns the Path2 internal array of points.
  63051. */
  63052. getPoints(): Vector2[];
  63053. /**
  63054. * Retreives the point at the distance aways from the starting point
  63055. * @param normalizedLengthPosition the length along the path to retreive the point from
  63056. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63057. */
  63058. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63059. /**
  63060. * Creates a new path starting from an x and y position
  63061. * @param x starting x value
  63062. * @param y starting y value
  63063. * @returns a new Path2 starting at the coordinates (x, y).
  63064. */
  63065. static StartingAt(x: number, y: number): Path2;
  63066. }
  63067. /**
  63068. * Represents a 3D path made up of multiple 3D points
  63069. */
  63070. export class Path3D {
  63071. /**
  63072. * an array of Vector3, the curve axis of the Path3D
  63073. */
  63074. path: Vector3[];
  63075. private _curve;
  63076. private _distances;
  63077. private _tangents;
  63078. private _normals;
  63079. private _binormals;
  63080. private _raw;
  63081. /**
  63082. * new Path3D(path, normal, raw)
  63083. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63084. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63085. * @param path an array of Vector3, the curve axis of the Path3D
  63086. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63087. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63088. */
  63089. constructor(
  63090. /**
  63091. * an array of Vector3, the curve axis of the Path3D
  63092. */
  63093. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63094. /**
  63095. * Returns the Path3D array of successive Vector3 designing its curve.
  63096. * @returns the Path3D array of successive Vector3 designing its curve.
  63097. */
  63098. getCurve(): Vector3[];
  63099. /**
  63100. * Returns an array populated with tangent vectors on each Path3D curve point.
  63101. * @returns an array populated with tangent vectors on each Path3D curve point.
  63102. */
  63103. getTangents(): Vector3[];
  63104. /**
  63105. * Returns an array populated with normal vectors on each Path3D curve point.
  63106. * @returns an array populated with normal vectors on each Path3D curve point.
  63107. */
  63108. getNormals(): Vector3[];
  63109. /**
  63110. * Returns an array populated with binormal vectors on each Path3D curve point.
  63111. * @returns an array populated with binormal vectors on each Path3D curve point.
  63112. */
  63113. getBinormals(): Vector3[];
  63114. /**
  63115. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63116. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63117. */
  63118. getDistances(): number[];
  63119. /**
  63120. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63121. * @param path path which all values are copied into the curves points
  63122. * @param firstNormal which should be projected onto the curve
  63123. * @returns the same object updated.
  63124. */
  63125. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63126. private _compute;
  63127. private _getFirstNonNullVector;
  63128. private _getLastNonNullVector;
  63129. private _normalVector;
  63130. }
  63131. /**
  63132. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63133. * A Curve3 is designed from a series of successive Vector3.
  63134. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63135. */
  63136. export class Curve3 {
  63137. private _points;
  63138. private _length;
  63139. /**
  63140. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63141. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63142. * @param v1 (Vector3) the control point
  63143. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63144. * @param nbPoints (integer) the wanted number of points in the curve
  63145. * @returns the created Curve3
  63146. */
  63147. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63148. /**
  63149. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63150. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63151. * @param v1 (Vector3) the first control point
  63152. * @param v2 (Vector3) the second control point
  63153. * @param v3 (Vector3) the end point of the Cubic Bezier
  63154. * @param nbPoints (integer) the wanted number of points in the curve
  63155. * @returns the created Curve3
  63156. */
  63157. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63158. /**
  63159. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63160. * @param p1 (Vector3) the origin point of the Hermite Spline
  63161. * @param t1 (Vector3) the tangent vector at the origin point
  63162. * @param p2 (Vector3) the end point of the Hermite Spline
  63163. * @param t2 (Vector3) the tangent vector at the end point
  63164. * @param nbPoints (integer) the wanted number of points in the curve
  63165. * @returns the created Curve3
  63166. */
  63167. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63168. /**
  63169. * Returns a Curve3 object along a CatmullRom Spline curve :
  63170. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63171. * @param nbPoints (integer) the wanted number of points between each curve control points
  63172. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63173. * @returns the created Curve3
  63174. */
  63175. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63176. /**
  63177. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63178. * A Curve3 is designed from a series of successive Vector3.
  63179. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63180. * @param points points which make up the curve
  63181. */
  63182. constructor(points: Vector3[]);
  63183. /**
  63184. * @returns the Curve3 stored array of successive Vector3
  63185. */
  63186. getPoints(): Vector3[];
  63187. /**
  63188. * @returns the computed length (float) of the curve.
  63189. */
  63190. length(): number;
  63191. /**
  63192. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63193. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63194. * curveA and curveB keep unchanged.
  63195. * @param curve the curve to continue from this curve
  63196. * @returns the newly constructed curve
  63197. */
  63198. continue(curve: DeepImmutable<Curve3>): Curve3;
  63199. private _computeLength;
  63200. }
  63201. /**
  63202. * Contains position and normal vectors for a vertex
  63203. */
  63204. export class PositionNormalVertex {
  63205. /** the position of the vertex (defaut: 0,0,0) */
  63206. position: Vector3;
  63207. /** the normal of the vertex (defaut: 0,1,0) */
  63208. normal: Vector3;
  63209. /**
  63210. * Creates a PositionNormalVertex
  63211. * @param position the position of the vertex (defaut: 0,0,0)
  63212. * @param normal the normal of the vertex (defaut: 0,1,0)
  63213. */
  63214. constructor(
  63215. /** the position of the vertex (defaut: 0,0,0) */
  63216. position?: Vector3,
  63217. /** the normal of the vertex (defaut: 0,1,0) */
  63218. normal?: Vector3);
  63219. /**
  63220. * Clones the PositionNormalVertex
  63221. * @returns the cloned PositionNormalVertex
  63222. */
  63223. clone(): PositionNormalVertex;
  63224. }
  63225. /**
  63226. * Contains position, normal and uv vectors for a vertex
  63227. */
  63228. export class PositionNormalTextureVertex {
  63229. /** the position of the vertex (defaut: 0,0,0) */
  63230. position: Vector3;
  63231. /** the normal of the vertex (defaut: 0,1,0) */
  63232. normal: Vector3;
  63233. /** the uv of the vertex (default: 0,0) */
  63234. uv: Vector2;
  63235. /**
  63236. * Creates a PositionNormalTextureVertex
  63237. * @param position the position of the vertex (defaut: 0,0,0)
  63238. * @param normal the normal of the vertex (defaut: 0,1,0)
  63239. * @param uv the uv of the vertex (default: 0,0)
  63240. */
  63241. constructor(
  63242. /** the position of the vertex (defaut: 0,0,0) */
  63243. position?: Vector3,
  63244. /** the normal of the vertex (defaut: 0,1,0) */
  63245. normal?: Vector3,
  63246. /** the uv of the vertex (default: 0,0) */
  63247. uv?: Vector2);
  63248. /**
  63249. * Clones the PositionNormalTextureVertex
  63250. * @returns the cloned PositionNormalTextureVertex
  63251. */
  63252. clone(): PositionNormalTextureVertex;
  63253. }
  63254. /**
  63255. * @hidden
  63256. */
  63257. export class Tmp {
  63258. static Color3: Color3[];
  63259. static Color4: Color4[];
  63260. static Vector2: Vector2[];
  63261. static Vector3: Vector3[];
  63262. static Vector4: Vector4[];
  63263. static Quaternion: Quaternion[];
  63264. static Matrix: Matrix[];
  63265. }
  63266. }
  63267. declare module BABYLON {
  63268. /**
  63269. * Class used to enable access to offline support
  63270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63271. */
  63272. export interface IOfflineProvider {
  63273. /**
  63274. * Gets a boolean indicating if scene must be saved in the database
  63275. */
  63276. enableSceneOffline: boolean;
  63277. /**
  63278. * Gets a boolean indicating if textures must be saved in the database
  63279. */
  63280. enableTexturesOffline: boolean;
  63281. /**
  63282. * Open the offline support and make it available
  63283. * @param successCallback defines the callback to call on success
  63284. * @param errorCallback defines the callback to call on error
  63285. */
  63286. open(successCallback: () => void, errorCallback: () => void): void;
  63287. /**
  63288. * Loads an image from the offline support
  63289. * @param url defines the url to load from
  63290. * @param image defines the target DOM image
  63291. */
  63292. loadImage(url: string, image: HTMLImageElement): void;
  63293. /**
  63294. * Loads a file from offline support
  63295. * @param url defines the URL to load from
  63296. * @param sceneLoaded defines a callback to call on success
  63297. * @param progressCallBack defines a callback to call when progress changed
  63298. * @param errorCallback defines a callback to call on error
  63299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63300. */
  63301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63302. }
  63303. }
  63304. declare module BABYLON {
  63305. /**
  63306. * A class serves as a medium between the observable and its observers
  63307. */
  63308. export class EventState {
  63309. /**
  63310. * Create a new EventState
  63311. * @param mask defines the mask associated with this state
  63312. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63313. * @param target defines the original target of the state
  63314. * @param currentTarget defines the current target of the state
  63315. */
  63316. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63317. /**
  63318. * Initialize the current event state
  63319. * @param mask defines the mask associated with this state
  63320. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63321. * @param target defines the original target of the state
  63322. * @param currentTarget defines the current target of the state
  63323. * @returns the current event state
  63324. */
  63325. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63326. /**
  63327. * An Observer can set this property to true to prevent subsequent observers of being notified
  63328. */
  63329. skipNextObservers: boolean;
  63330. /**
  63331. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63332. */
  63333. mask: number;
  63334. /**
  63335. * The object that originally notified the event
  63336. */
  63337. target?: any;
  63338. /**
  63339. * The current object in the bubbling phase
  63340. */
  63341. currentTarget?: any;
  63342. /**
  63343. * This will be populated with the return value of the last function that was executed.
  63344. * If it is the first function in the callback chain it will be the event data.
  63345. */
  63346. lastReturnValue?: any;
  63347. }
  63348. /**
  63349. * Represent an Observer registered to a given Observable object.
  63350. */
  63351. export class Observer<T> {
  63352. /**
  63353. * Defines the callback to call when the observer is notified
  63354. */
  63355. callback: (eventData: T, eventState: EventState) => void;
  63356. /**
  63357. * Defines the mask of the observer (used to filter notifications)
  63358. */
  63359. mask: number;
  63360. /**
  63361. * Defines the current scope used to restore the JS context
  63362. */
  63363. scope: any;
  63364. /** @hidden */
  63365. _willBeUnregistered: boolean;
  63366. /**
  63367. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63368. */
  63369. unregisterOnNextCall: boolean;
  63370. /**
  63371. * Creates a new observer
  63372. * @param callback defines the callback to call when the observer is notified
  63373. * @param mask defines the mask of the observer (used to filter notifications)
  63374. * @param scope defines the current scope used to restore the JS context
  63375. */
  63376. constructor(
  63377. /**
  63378. * Defines the callback to call when the observer is notified
  63379. */
  63380. callback: (eventData: T, eventState: EventState) => void,
  63381. /**
  63382. * Defines the mask of the observer (used to filter notifications)
  63383. */
  63384. mask: number,
  63385. /**
  63386. * Defines the current scope used to restore the JS context
  63387. */
  63388. scope?: any);
  63389. }
  63390. /**
  63391. * Represent a list of observers registered to multiple Observables object.
  63392. */
  63393. export class MultiObserver<T> {
  63394. private _observers;
  63395. private _observables;
  63396. /**
  63397. * Release associated resources
  63398. */
  63399. dispose(): void;
  63400. /**
  63401. * Raise a callback when one of the observable will notify
  63402. * @param observables defines a list of observables to watch
  63403. * @param callback defines the callback to call on notification
  63404. * @param mask defines the mask used to filter notifications
  63405. * @param scope defines the current scope used to restore the JS context
  63406. * @returns the new MultiObserver
  63407. */
  63408. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63409. }
  63410. /**
  63411. * The Observable class is a simple implementation of the Observable pattern.
  63412. *
  63413. * 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.
  63414. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63415. * 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).
  63416. * 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.
  63417. */
  63418. export class Observable<T> {
  63419. private _observers;
  63420. private _eventState;
  63421. private _onObserverAdded;
  63422. /**
  63423. * Creates a new observable
  63424. * @param onObserverAdded defines a callback to call when a new observer is added
  63425. */
  63426. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63427. /**
  63428. * Create a new Observer with the specified callback
  63429. * @param callback the callback that will be executed for that Observer
  63430. * @param mask the mask used to filter observers
  63431. * @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.
  63432. * @param scope optional scope for the callback to be called from
  63433. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63434. * @returns the new observer created for the callback
  63435. */
  63436. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63437. /**
  63438. * Create a new Observer with the specified callback and unregisters after the next notification
  63439. * @param callback the callback that will be executed for that Observer
  63440. * @returns the new observer created for the callback
  63441. */
  63442. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63443. /**
  63444. * Remove an Observer from the Observable object
  63445. * @param observer the instance of the Observer to remove
  63446. * @returns false if it doesn't belong to this Observable
  63447. */
  63448. remove(observer: Nullable<Observer<T>>): boolean;
  63449. /**
  63450. * Remove a callback from the Observable object
  63451. * @param callback the callback to remove
  63452. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63453. * @returns false if it doesn't belong to this Observable
  63454. */
  63455. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63456. private _deferUnregister;
  63457. private _remove;
  63458. /**
  63459. * Moves the observable to the top of the observer list making it get called first when notified
  63460. * @param observer the observer to move
  63461. */
  63462. makeObserverTopPriority(observer: Observer<T>): void;
  63463. /**
  63464. * Moves the observable to the bottom of the observer list making it get called last when notified
  63465. * @param observer the observer to move
  63466. */
  63467. makeObserverBottomPriority(observer: Observer<T>): void;
  63468. /**
  63469. * Notify all Observers by calling their respective callback with the given data
  63470. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63471. * @param eventData defines the data to send to all observers
  63472. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63473. * @param target defines the original target of the state
  63474. * @param currentTarget defines the current target of the state
  63475. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63476. */
  63477. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63478. /**
  63479. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63480. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63481. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63482. * and it is crucial that all callbacks will be executed.
  63483. * The order of the callbacks is kept, callbacks are not executed parallel.
  63484. *
  63485. * @param eventData The data to be sent to each callback
  63486. * @param mask is used to filter observers defaults to -1
  63487. * @param target defines the callback target (see EventState)
  63488. * @param currentTarget defines he current object in the bubbling phase
  63489. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63490. */
  63491. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63492. /**
  63493. * Notify a specific observer
  63494. * @param observer defines the observer to notify
  63495. * @param eventData defines the data to be sent to each callback
  63496. * @param mask is used to filter observers defaults to -1
  63497. */
  63498. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63499. /**
  63500. * Gets a boolean indicating if the observable has at least one observer
  63501. * @returns true is the Observable has at least one Observer registered
  63502. */
  63503. hasObservers(): boolean;
  63504. /**
  63505. * Clear the list of observers
  63506. */
  63507. clear(): void;
  63508. /**
  63509. * Clone the current observable
  63510. * @returns a new observable
  63511. */
  63512. clone(): Observable<T>;
  63513. /**
  63514. * Does this observable handles observer registered with a given mask
  63515. * @param mask defines the mask to be tested
  63516. * @return whether or not one observer registered with the given mask is handeled
  63517. **/
  63518. hasSpecificMask(mask?: number): boolean;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * Class used to help managing file picking and drag'n'drop
  63524. * File Storage
  63525. */
  63526. export class FilesInputStore {
  63527. /**
  63528. * List of files ready to be loaded
  63529. */
  63530. static FilesToLoad: {
  63531. [key: string]: File;
  63532. };
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /** Defines the cross module used constants to avoid circular dependncies */
  63537. export class Constants {
  63538. /** Defines that alpha blending is disabled */
  63539. static readonly ALPHA_DISABLE: number;
  63540. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63541. static readonly ALPHA_ADD: number;
  63542. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63543. static readonly ALPHA_COMBINE: number;
  63544. /** Defines that alpha blending to DEST - SRC * DEST */
  63545. static readonly ALPHA_SUBTRACT: number;
  63546. /** Defines that alpha blending to SRC * DEST */
  63547. static readonly ALPHA_MULTIPLY: number;
  63548. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63549. static readonly ALPHA_MAXIMIZED: number;
  63550. /** Defines that alpha blending to SRC + DEST */
  63551. static readonly ALPHA_ONEONE: number;
  63552. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63553. static readonly ALPHA_PREMULTIPLIED: number;
  63554. /**
  63555. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63556. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63557. */
  63558. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63559. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63560. static readonly ALPHA_INTERPOLATE: number;
  63561. /**
  63562. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63563. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63564. */
  63565. static readonly ALPHA_SCREENMODE: number;
  63566. /** Defines that the ressource is not delayed*/
  63567. static readonly DELAYLOADSTATE_NONE: number;
  63568. /** Defines that the ressource was successfully delay loaded */
  63569. static readonly DELAYLOADSTATE_LOADED: number;
  63570. /** Defines that the ressource is currently delay loading */
  63571. static readonly DELAYLOADSTATE_LOADING: number;
  63572. /** Defines that the ressource is delayed and has not started loading */
  63573. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63574. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63575. static readonly NEVER: number;
  63576. /** 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 */
  63577. static readonly ALWAYS: number;
  63578. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63579. static readonly LESS: number;
  63580. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63581. static readonly EQUAL: number;
  63582. /** 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 */
  63583. static readonly LEQUAL: number;
  63584. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63585. static readonly GREATER: number;
  63586. /** 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 */
  63587. static readonly GEQUAL: number;
  63588. /** 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 */
  63589. static readonly NOTEQUAL: number;
  63590. /** Passed to stencilOperation to specify that stencil value must be kept */
  63591. static readonly KEEP: number;
  63592. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63593. static readonly REPLACE: number;
  63594. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63595. static readonly INCR: number;
  63596. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63597. static readonly DECR: number;
  63598. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63599. static readonly INVERT: number;
  63600. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63601. static readonly INCR_WRAP: number;
  63602. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63603. static readonly DECR_WRAP: number;
  63604. /** Texture is not repeating outside of 0..1 UVs */
  63605. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63606. /** Texture is repeating outside of 0..1 UVs */
  63607. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63608. /** Texture is repeating and mirrored */
  63609. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63610. /** ALPHA */
  63611. static readonly TEXTUREFORMAT_ALPHA: number;
  63612. /** LUMINANCE */
  63613. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63614. /** LUMINANCE_ALPHA */
  63615. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63616. /** RGB */
  63617. static readonly TEXTUREFORMAT_RGB: number;
  63618. /** RGBA */
  63619. static readonly TEXTUREFORMAT_RGBA: number;
  63620. /** RED */
  63621. static readonly TEXTUREFORMAT_RED: number;
  63622. /** RED (2nd reference) */
  63623. static readonly TEXTUREFORMAT_R: number;
  63624. /** RG */
  63625. static readonly TEXTUREFORMAT_RG: number;
  63626. /** RED_INTEGER */
  63627. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63628. /** RED_INTEGER (2nd reference) */
  63629. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63630. /** RG_INTEGER */
  63631. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63632. /** RGB_INTEGER */
  63633. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63634. /** RGBA_INTEGER */
  63635. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63636. /** UNSIGNED_BYTE */
  63637. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63638. /** UNSIGNED_BYTE (2nd reference) */
  63639. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63640. /** FLOAT */
  63641. static readonly TEXTURETYPE_FLOAT: number;
  63642. /** HALF_FLOAT */
  63643. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63644. /** BYTE */
  63645. static readonly TEXTURETYPE_BYTE: number;
  63646. /** SHORT */
  63647. static readonly TEXTURETYPE_SHORT: number;
  63648. /** UNSIGNED_SHORT */
  63649. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63650. /** INT */
  63651. static readonly TEXTURETYPE_INT: number;
  63652. /** UNSIGNED_INT */
  63653. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63654. /** UNSIGNED_SHORT_4_4_4_4 */
  63655. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63656. /** UNSIGNED_SHORT_5_5_5_1 */
  63657. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63658. /** UNSIGNED_SHORT_5_6_5 */
  63659. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63660. /** UNSIGNED_INT_2_10_10_10_REV */
  63661. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63662. /** UNSIGNED_INT_24_8 */
  63663. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63664. /** UNSIGNED_INT_10F_11F_11F_REV */
  63665. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63666. /** UNSIGNED_INT_5_9_9_9_REV */
  63667. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63668. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63669. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63670. /** nearest is mag = nearest and min = nearest and mip = linear */
  63671. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63672. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63673. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63674. /** Trilinear is mag = linear and min = linear and mip = linear */
  63675. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63676. /** nearest is mag = nearest and min = nearest and mip = linear */
  63677. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63678. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63679. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63680. /** Trilinear is mag = linear and min = linear and mip = linear */
  63681. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63682. /** mag = nearest and min = nearest and mip = nearest */
  63683. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63684. /** mag = nearest and min = linear and mip = nearest */
  63685. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63686. /** mag = nearest and min = linear and mip = linear */
  63687. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63688. /** mag = nearest and min = linear and mip = none */
  63689. static readonly TEXTURE_NEAREST_LINEAR: number;
  63690. /** mag = nearest and min = nearest and mip = none */
  63691. static readonly TEXTURE_NEAREST_NEAREST: number;
  63692. /** mag = linear and min = nearest and mip = nearest */
  63693. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63694. /** mag = linear and min = nearest and mip = linear */
  63695. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63696. /** mag = linear and min = linear and mip = none */
  63697. static readonly TEXTURE_LINEAR_LINEAR: number;
  63698. /** mag = linear and min = nearest and mip = none */
  63699. static readonly TEXTURE_LINEAR_NEAREST: number;
  63700. /** Explicit coordinates mode */
  63701. static readonly TEXTURE_EXPLICIT_MODE: number;
  63702. /** Spherical coordinates mode */
  63703. static readonly TEXTURE_SPHERICAL_MODE: number;
  63704. /** Planar coordinates mode */
  63705. static readonly TEXTURE_PLANAR_MODE: number;
  63706. /** Cubic coordinates mode */
  63707. static readonly TEXTURE_CUBIC_MODE: number;
  63708. /** Projection coordinates mode */
  63709. static readonly TEXTURE_PROJECTION_MODE: number;
  63710. /** Skybox coordinates mode */
  63711. static readonly TEXTURE_SKYBOX_MODE: number;
  63712. /** Inverse Cubic coordinates mode */
  63713. static readonly TEXTURE_INVCUBIC_MODE: number;
  63714. /** Equirectangular coordinates mode */
  63715. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63716. /** Equirectangular Fixed coordinates mode */
  63717. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63718. /** Equirectangular Fixed Mirrored coordinates mode */
  63719. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63720. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63721. static readonly SCALEMODE_FLOOR: number;
  63722. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63723. static readonly SCALEMODE_NEAREST: number;
  63724. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63725. static readonly SCALEMODE_CEILING: number;
  63726. /**
  63727. * The dirty texture flag value
  63728. */
  63729. static readonly MATERIAL_TextureDirtyFlag: number;
  63730. /**
  63731. * The dirty light flag value
  63732. */
  63733. static readonly MATERIAL_LightDirtyFlag: number;
  63734. /**
  63735. * The dirty fresnel flag value
  63736. */
  63737. static readonly MATERIAL_FresnelDirtyFlag: number;
  63738. /**
  63739. * The dirty attribute flag value
  63740. */
  63741. static readonly MATERIAL_AttributesDirtyFlag: number;
  63742. /**
  63743. * The dirty misc flag value
  63744. */
  63745. static readonly MATERIAL_MiscDirtyFlag: number;
  63746. /**
  63747. * The all dirty flag value
  63748. */
  63749. static readonly MATERIAL_AllDirtyFlag: number;
  63750. /**
  63751. * Returns the triangle fill mode
  63752. */
  63753. static readonly MATERIAL_TriangleFillMode: number;
  63754. /**
  63755. * Returns the wireframe mode
  63756. */
  63757. static readonly MATERIAL_WireFrameFillMode: number;
  63758. /**
  63759. * Returns the point fill mode
  63760. */
  63761. static readonly MATERIAL_PointFillMode: number;
  63762. /**
  63763. * Returns the point list draw mode
  63764. */
  63765. static readonly MATERIAL_PointListDrawMode: number;
  63766. /**
  63767. * Returns the line list draw mode
  63768. */
  63769. static readonly MATERIAL_LineListDrawMode: number;
  63770. /**
  63771. * Returns the line loop draw mode
  63772. */
  63773. static readonly MATERIAL_LineLoopDrawMode: number;
  63774. /**
  63775. * Returns the line strip draw mode
  63776. */
  63777. static readonly MATERIAL_LineStripDrawMode: number;
  63778. /**
  63779. * Returns the triangle strip draw mode
  63780. */
  63781. static readonly MATERIAL_TriangleStripDrawMode: number;
  63782. /**
  63783. * Returns the triangle fan draw mode
  63784. */
  63785. static readonly MATERIAL_TriangleFanDrawMode: number;
  63786. /**
  63787. * Stores the clock-wise side orientation
  63788. */
  63789. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63790. /**
  63791. * Stores the counter clock-wise side orientation
  63792. */
  63793. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63794. /**
  63795. * Nothing
  63796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63797. */
  63798. static readonly ACTION_NothingTrigger: number;
  63799. /**
  63800. * On pick
  63801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63802. */
  63803. static readonly ACTION_OnPickTrigger: number;
  63804. /**
  63805. * On left pick
  63806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63807. */
  63808. static readonly ACTION_OnLeftPickTrigger: number;
  63809. /**
  63810. * On right pick
  63811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63812. */
  63813. static readonly ACTION_OnRightPickTrigger: number;
  63814. /**
  63815. * On center pick
  63816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63817. */
  63818. static readonly ACTION_OnCenterPickTrigger: number;
  63819. /**
  63820. * On pick down
  63821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63822. */
  63823. static readonly ACTION_OnPickDownTrigger: number;
  63824. /**
  63825. * On double pick
  63826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63827. */
  63828. static readonly ACTION_OnDoublePickTrigger: number;
  63829. /**
  63830. * On pick up
  63831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63832. */
  63833. static readonly ACTION_OnPickUpTrigger: number;
  63834. /**
  63835. * On pick out.
  63836. * This trigger will only be raised if you also declared a OnPickDown
  63837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63838. */
  63839. static readonly ACTION_OnPickOutTrigger: number;
  63840. /**
  63841. * On long press
  63842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63843. */
  63844. static readonly ACTION_OnLongPressTrigger: number;
  63845. /**
  63846. * On pointer over
  63847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63848. */
  63849. static readonly ACTION_OnPointerOverTrigger: number;
  63850. /**
  63851. * On pointer out
  63852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63853. */
  63854. static readonly ACTION_OnPointerOutTrigger: number;
  63855. /**
  63856. * On every frame
  63857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63858. */
  63859. static readonly ACTION_OnEveryFrameTrigger: number;
  63860. /**
  63861. * On intersection enter
  63862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63863. */
  63864. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63865. /**
  63866. * On intersection exit
  63867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63868. */
  63869. static readonly ACTION_OnIntersectionExitTrigger: number;
  63870. /**
  63871. * On key down
  63872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63873. */
  63874. static readonly ACTION_OnKeyDownTrigger: number;
  63875. /**
  63876. * On key up
  63877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63878. */
  63879. static readonly ACTION_OnKeyUpTrigger: number;
  63880. /**
  63881. * Billboard mode will only apply to Y axis
  63882. */
  63883. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63884. /**
  63885. * Billboard mode will apply to all axes
  63886. */
  63887. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63888. /**
  63889. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63890. */
  63891. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63892. /**
  63893. * Gets or sets base Assets URL
  63894. */
  63895. static readonly PARTICLES_BaseAssetsUrl: string;
  63896. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63897. * Test order :
  63898. * Is the bounding sphere outside the frustum ?
  63899. * If not, are the bounding box vertices outside the frustum ?
  63900. * It not, then the cullable object is in the frustum.
  63901. */
  63902. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63903. /** Culling strategy : Bounding Sphere Only.
  63904. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63905. * It's also less accurate than the standard because some not visible objects can still be selected.
  63906. * Test : is the bounding sphere outside the frustum ?
  63907. * If not, then the cullable object is in the frustum.
  63908. */
  63909. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63910. /** Culling strategy : Optimistic Inclusion.
  63911. * This in an inclusion test first, then the standard exclusion test.
  63912. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63913. * 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.
  63914. * Anyway, it's as accurate as the standard strategy.
  63915. * Test :
  63916. * Is the cullable object bounding sphere center in the frustum ?
  63917. * If not, apply the default culling strategy.
  63918. */
  63919. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63920. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63921. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63922. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63923. * 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.
  63924. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63925. * Test :
  63926. * Is the cullable object bounding sphere center in the frustum ?
  63927. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63928. */
  63929. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63930. /**
  63931. * No logging while loading
  63932. */
  63933. static readonly SCENELOADER_NO_LOGGING: number;
  63934. /**
  63935. * Minimal logging while loading
  63936. */
  63937. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63938. /**
  63939. * Summary logging while loading
  63940. */
  63941. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63942. /**
  63943. * Detailled logging while loading
  63944. */
  63945. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63946. }
  63947. }
  63948. declare module BABYLON {
  63949. /**
  63950. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63951. * Babylon.js
  63952. */
  63953. export class DomManagement {
  63954. /**
  63955. * Checks if the window object exists
  63956. * @returns true if the window object exists
  63957. */
  63958. static IsWindowObjectExist(): boolean;
  63959. /**
  63960. * Extracts text content from a DOM element hierarchy
  63961. * @param element defines the root element
  63962. * @returns a string
  63963. */
  63964. static GetDOMTextContent(element: HTMLElement): string;
  63965. }
  63966. }
  63967. declare module BABYLON {
  63968. /**
  63969. * Logger used througouht the application to allow configuration of
  63970. * the log level required for the messages.
  63971. */
  63972. export class Logger {
  63973. /**
  63974. * No log
  63975. */
  63976. static readonly NoneLogLevel: number;
  63977. /**
  63978. * Only message logs
  63979. */
  63980. static readonly MessageLogLevel: number;
  63981. /**
  63982. * Only warning logs
  63983. */
  63984. static readonly WarningLogLevel: number;
  63985. /**
  63986. * Only error logs
  63987. */
  63988. static readonly ErrorLogLevel: number;
  63989. /**
  63990. * All logs
  63991. */
  63992. static readonly AllLogLevel: number;
  63993. private static _LogCache;
  63994. /**
  63995. * Gets a value indicating the number of loading errors
  63996. * @ignorenaming
  63997. */
  63998. static errorsCount: number;
  63999. /**
  64000. * Callback called when a new log is added
  64001. */
  64002. static OnNewCacheEntry: (entry: string) => void;
  64003. private static _AddLogEntry;
  64004. private static _FormatMessage;
  64005. private static _LogDisabled;
  64006. private static _LogEnabled;
  64007. private static _WarnDisabled;
  64008. private static _WarnEnabled;
  64009. private static _ErrorDisabled;
  64010. private static _ErrorEnabled;
  64011. /**
  64012. * Log a message to the console
  64013. */
  64014. static Log: (message: string) => void;
  64015. /**
  64016. * Write a warning message to the console
  64017. */
  64018. static Warn: (message: string) => void;
  64019. /**
  64020. * Write an error message to the console
  64021. */
  64022. static Error: (message: string) => void;
  64023. /**
  64024. * Gets current log cache (list of logs)
  64025. */
  64026. static readonly LogCache: string;
  64027. /**
  64028. * Clears the log cache
  64029. */
  64030. static ClearLogCache(): void;
  64031. /**
  64032. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64033. */
  64034. static LogLevels: number;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /** @hidden */
  64039. export class _TypeStore {
  64040. /** @hidden */
  64041. static RegisteredTypes: {
  64042. [key: string]: Object;
  64043. };
  64044. /** @hidden */
  64045. static GetClass(fqdn: string): any;
  64046. }
  64047. }
  64048. declare module BABYLON {
  64049. /**
  64050. * Class containing a set of static utilities functions for deep copy.
  64051. */
  64052. export class DeepCopier {
  64053. /**
  64054. * Tries to copy an object by duplicating every property
  64055. * @param source defines the source object
  64056. * @param destination defines the target object
  64057. * @param doNotCopyList defines a list of properties to avoid
  64058. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64059. */
  64060. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64061. }
  64062. }
  64063. declare module BABYLON {
  64064. /**
  64065. * Class containing a set of static utilities functions for precision date
  64066. */
  64067. export class PrecisionDate {
  64068. /**
  64069. * Gets either window.performance.now() if supported or Date.now() else
  64070. */
  64071. static readonly Now: number;
  64072. }
  64073. }
  64074. declare module BABYLON {
  64075. /** @hidden */
  64076. export class _DevTools {
  64077. static WarnImport(name: string): string;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /**
  64082. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64083. */
  64084. export class WebRequest {
  64085. private _xhr;
  64086. /**
  64087. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64088. * i.e. when loading files, where the server/service expects an Authorization header
  64089. */
  64090. static CustomRequestHeaders: {
  64091. [key: string]: string;
  64092. };
  64093. /**
  64094. * Add callback functions in this array to update all the requests before they get sent to the network
  64095. */
  64096. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64097. private _injectCustomRequestHeaders;
  64098. /**
  64099. * Gets or sets a function to be called when loading progress changes
  64100. */
  64101. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64102. /**
  64103. * Returns client's state
  64104. */
  64105. readonly readyState: number;
  64106. /**
  64107. * Returns client's status
  64108. */
  64109. readonly status: number;
  64110. /**
  64111. * Returns client's status as a text
  64112. */
  64113. readonly statusText: string;
  64114. /**
  64115. * Returns client's response
  64116. */
  64117. readonly response: any;
  64118. /**
  64119. * Returns client's response url
  64120. */
  64121. readonly responseURL: string;
  64122. /**
  64123. * Returns client's response as text
  64124. */
  64125. readonly responseText: string;
  64126. /**
  64127. * Gets or sets the expected response type
  64128. */
  64129. responseType: XMLHttpRequestResponseType;
  64130. /** @hidden */
  64131. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64132. /** @hidden */
  64133. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64134. /**
  64135. * Cancels any network activity
  64136. */
  64137. abort(): void;
  64138. /**
  64139. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64140. * @param body defines an optional request body
  64141. */
  64142. send(body?: Document | BodyInit | null): void;
  64143. /**
  64144. * Sets the request method, request URL
  64145. * @param method defines the method to use (GET, POST, etc..)
  64146. * @param url defines the url to connect with
  64147. */
  64148. open(method: string, url: string): void;
  64149. }
  64150. }
  64151. declare module BABYLON {
  64152. /**
  64153. * Class used to evalaute queries containing `and` and `or` operators
  64154. */
  64155. export class AndOrNotEvaluator {
  64156. /**
  64157. * Evaluate a query
  64158. * @param query defines the query to evaluate
  64159. * @param evaluateCallback defines the callback used to filter result
  64160. * @returns true if the query matches
  64161. */
  64162. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64163. private static _HandleParenthesisContent;
  64164. private static _SimplifyNegation;
  64165. }
  64166. }
  64167. declare module BABYLON {
  64168. /**
  64169. * Class used to store custom tags
  64170. */
  64171. export class Tags {
  64172. /**
  64173. * Adds support for tags on the given object
  64174. * @param obj defines the object to use
  64175. */
  64176. static EnableFor(obj: any): void;
  64177. /**
  64178. * Removes tags support
  64179. * @param obj defines the object to use
  64180. */
  64181. static DisableFor(obj: any): void;
  64182. /**
  64183. * Gets a boolean indicating if the given object has tags
  64184. * @param obj defines the object to use
  64185. * @returns a boolean
  64186. */
  64187. static HasTags(obj: any): boolean;
  64188. /**
  64189. * Gets the tags available on a given object
  64190. * @param obj defines the object to use
  64191. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64192. * @returns the tags
  64193. */
  64194. static GetTags(obj: any, asString?: boolean): any;
  64195. /**
  64196. * Adds tags to an object
  64197. * @param obj defines the object to use
  64198. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64199. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64200. */
  64201. static AddTagsTo(obj: any, tagsString: string): void;
  64202. /**
  64203. * @hidden
  64204. */
  64205. static _AddTagTo(obj: any, tag: string): void;
  64206. /**
  64207. * Removes specific tags from a specific object
  64208. * @param obj defines the object to use
  64209. * @param tagsString defines the tags to remove
  64210. */
  64211. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64212. /**
  64213. * @hidden
  64214. */
  64215. static _RemoveTagFrom(obj: any, tag: string): void;
  64216. /**
  64217. * Defines if tags hosted on an object match a given query
  64218. * @param obj defines the object to use
  64219. * @param tagsQuery defines the tag query
  64220. * @returns a boolean
  64221. */
  64222. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * Manages the defines for the Material
  64228. */
  64229. export class MaterialDefines {
  64230. private _keys;
  64231. private _isDirty;
  64232. /** @hidden */
  64233. _renderId: number;
  64234. /** @hidden */
  64235. _areLightsDirty: boolean;
  64236. /** @hidden */
  64237. _areAttributesDirty: boolean;
  64238. /** @hidden */
  64239. _areTexturesDirty: boolean;
  64240. /** @hidden */
  64241. _areFresnelDirty: boolean;
  64242. /** @hidden */
  64243. _areMiscDirty: boolean;
  64244. /** @hidden */
  64245. _areImageProcessingDirty: boolean;
  64246. /** @hidden */
  64247. _normals: boolean;
  64248. /** @hidden */
  64249. _uvs: boolean;
  64250. /** @hidden */
  64251. _needNormals: boolean;
  64252. /** @hidden */
  64253. _needUVs: boolean;
  64254. /**
  64255. * Specifies if the material needs to be re-calculated
  64256. */
  64257. readonly isDirty: boolean;
  64258. /**
  64259. * Marks the material to indicate that it has been re-calculated
  64260. */
  64261. markAsProcessed(): void;
  64262. /**
  64263. * Marks the material to indicate that it needs to be re-calculated
  64264. */
  64265. markAsUnprocessed(): void;
  64266. /**
  64267. * Marks the material to indicate all of its defines need to be re-calculated
  64268. */
  64269. markAllAsDirty(): void;
  64270. /**
  64271. * Marks the material to indicate that image processing needs to be re-calculated
  64272. */
  64273. markAsImageProcessingDirty(): void;
  64274. /**
  64275. * Marks the material to indicate the lights need to be re-calculated
  64276. */
  64277. markAsLightDirty(): void;
  64278. /**
  64279. * Marks the attribute state as changed
  64280. */
  64281. markAsAttributesDirty(): void;
  64282. /**
  64283. * Marks the texture state as changed
  64284. */
  64285. markAsTexturesDirty(): void;
  64286. /**
  64287. * Marks the fresnel state as changed
  64288. */
  64289. markAsFresnelDirty(): void;
  64290. /**
  64291. * Marks the misc state as changed
  64292. */
  64293. markAsMiscDirty(): void;
  64294. /**
  64295. * Rebuilds the material defines
  64296. */
  64297. rebuild(): void;
  64298. /**
  64299. * Specifies if two material defines are equal
  64300. * @param other - A material define instance to compare to
  64301. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64302. */
  64303. isEqual(other: MaterialDefines): boolean;
  64304. /**
  64305. * Clones this instance's defines to another instance
  64306. * @param other - material defines to clone values to
  64307. */
  64308. cloneTo(other: MaterialDefines): void;
  64309. /**
  64310. * Resets the material define values
  64311. */
  64312. reset(): void;
  64313. /**
  64314. * Converts the material define values to a string
  64315. * @returns - String of material define information
  64316. */
  64317. toString(): string;
  64318. }
  64319. }
  64320. declare module BABYLON {
  64321. /**
  64322. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64323. */
  64324. export class PerformanceMonitor {
  64325. private _enabled;
  64326. private _rollingFrameTime;
  64327. private _lastFrameTimeMs;
  64328. /**
  64329. * constructor
  64330. * @param frameSampleSize The number of samples required to saturate the sliding window
  64331. */
  64332. constructor(frameSampleSize?: number);
  64333. /**
  64334. * Samples current frame
  64335. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64336. */
  64337. sampleFrame(timeMs?: number): void;
  64338. /**
  64339. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64340. */
  64341. readonly averageFrameTime: number;
  64342. /**
  64343. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64344. */
  64345. readonly averageFrameTimeVariance: number;
  64346. /**
  64347. * Returns the frame time of the most recent frame
  64348. */
  64349. readonly instantaneousFrameTime: number;
  64350. /**
  64351. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64352. */
  64353. readonly averageFPS: number;
  64354. /**
  64355. * Returns the average framerate in frames per second using the most recent frame time
  64356. */
  64357. readonly instantaneousFPS: number;
  64358. /**
  64359. * Returns true if enough samples have been taken to completely fill the sliding window
  64360. */
  64361. readonly isSaturated: boolean;
  64362. /**
  64363. * Enables contributions to the sliding window sample set
  64364. */
  64365. enable(): void;
  64366. /**
  64367. * Disables contributions to the sliding window sample set
  64368. * Samples will not be interpolated over the disabled period
  64369. */
  64370. disable(): void;
  64371. /**
  64372. * Returns true if sampling is enabled
  64373. */
  64374. readonly isEnabled: boolean;
  64375. /**
  64376. * Resets performance monitor
  64377. */
  64378. reset(): void;
  64379. }
  64380. /**
  64381. * RollingAverage
  64382. *
  64383. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64384. */
  64385. export class RollingAverage {
  64386. /**
  64387. * Current average
  64388. */
  64389. average: number;
  64390. /**
  64391. * Current variance
  64392. */
  64393. variance: number;
  64394. protected _samples: Array<number>;
  64395. protected _sampleCount: number;
  64396. protected _pos: number;
  64397. protected _m2: number;
  64398. /**
  64399. * constructor
  64400. * @param length The number of samples required to saturate the sliding window
  64401. */
  64402. constructor(length: number);
  64403. /**
  64404. * Adds a sample to the sample set
  64405. * @param v The sample value
  64406. */
  64407. add(v: number): void;
  64408. /**
  64409. * Returns previously added values or null if outside of history or outside the sliding window domain
  64410. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64411. * @return Value previously recorded with add() or null if outside of range
  64412. */
  64413. history(i: number): number;
  64414. /**
  64415. * Returns true if enough samples have been taken to completely fill the sliding window
  64416. * @return true if sample-set saturated
  64417. */
  64418. isSaturated(): boolean;
  64419. /**
  64420. * Resets the rolling average (equivalent to 0 samples taken so far)
  64421. */
  64422. reset(): void;
  64423. /**
  64424. * Wraps a value around the sample range boundaries
  64425. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64426. * @return Wrapped position in sample range
  64427. */
  64428. protected _wrapPosition(i: number): number;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64434. * The underlying implementation relies on an associative array to ensure the best performances.
  64435. * The value can be anything including 'null' but except 'undefined'
  64436. */
  64437. export class StringDictionary<T> {
  64438. /**
  64439. * This will clear this dictionary and copy the content from the 'source' one.
  64440. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64441. * @param source the dictionary to take the content from and copy to this dictionary
  64442. */
  64443. copyFrom(source: StringDictionary<T>): void;
  64444. /**
  64445. * Get a value based from its key
  64446. * @param key the given key to get the matching value from
  64447. * @return the value if found, otherwise undefined is returned
  64448. */
  64449. get(key: string): T | undefined;
  64450. /**
  64451. * Get a value from its key or add it if it doesn't exist.
  64452. * This method will ensure you that a given key/data will be present in the dictionary.
  64453. * @param key the given key to get the matching value from
  64454. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64455. * The factory will only be invoked if there's no data for the given key.
  64456. * @return the value corresponding to the key.
  64457. */
  64458. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64459. /**
  64460. * Get a value from its key if present in the dictionary otherwise add it
  64461. * @param key the key to get the value from
  64462. * @param val if there's no such key/value pair in the dictionary add it with this value
  64463. * @return the value corresponding to the key
  64464. */
  64465. getOrAdd(key: string, val: T): T;
  64466. /**
  64467. * Check if there's a given key in the dictionary
  64468. * @param key the key to check for
  64469. * @return true if the key is present, false otherwise
  64470. */
  64471. contains(key: string): boolean;
  64472. /**
  64473. * Add a new key and its corresponding value
  64474. * @param key the key to add
  64475. * @param value the value corresponding to the key
  64476. * @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
  64477. */
  64478. add(key: string, value: T): boolean;
  64479. /**
  64480. * Update a specific value associated to a key
  64481. * @param key defines the key to use
  64482. * @param value defines the value to store
  64483. * @returns true if the value was updated (or false if the key was not found)
  64484. */
  64485. set(key: string, value: T): boolean;
  64486. /**
  64487. * Get the element of the given key and remove it from the dictionary
  64488. * @param key defines the key to search
  64489. * @returns the value associated with the key or null if not found
  64490. */
  64491. getAndRemove(key: string): Nullable<T>;
  64492. /**
  64493. * Remove a key/value from the dictionary.
  64494. * @param key the key to remove
  64495. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64496. */
  64497. remove(key: string): boolean;
  64498. /**
  64499. * Clear the whole content of the dictionary
  64500. */
  64501. clear(): void;
  64502. /**
  64503. * Gets the current count
  64504. */
  64505. readonly count: number;
  64506. /**
  64507. * Execute a callback on each key/val of the dictionary.
  64508. * Note that you can remove any element in this dictionary in the callback implementation
  64509. * @param callback the callback to execute on a given key/value pair
  64510. */
  64511. forEach(callback: (key: string, val: T) => void): void;
  64512. /**
  64513. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64514. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64515. * Note that you can remove any element in this dictionary in the callback implementation
  64516. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64517. * @returns the first item
  64518. */
  64519. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64520. private _count;
  64521. private _data;
  64522. }
  64523. }
  64524. declare module BABYLON {
  64525. /**
  64526. * Helper class that provides a small promise polyfill
  64527. */
  64528. export class PromisePolyfill {
  64529. /**
  64530. * Static function used to check if the polyfill is required
  64531. * If this is the case then the function will inject the polyfill to window.Promise
  64532. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64533. */
  64534. static Apply(force?: boolean): void;
  64535. }
  64536. }
  64537. declare module BABYLON {
  64538. /**
  64539. * Class used to store data that will be store in GPU memory
  64540. */
  64541. export class Buffer {
  64542. private _engine;
  64543. private _buffer;
  64544. /** @hidden */
  64545. _data: Nullable<DataArray>;
  64546. private _updatable;
  64547. private _instanced;
  64548. /**
  64549. * Gets the byte stride.
  64550. */
  64551. readonly byteStride: number;
  64552. /**
  64553. * Constructor
  64554. * @param engine the engine
  64555. * @param data the data to use for this buffer
  64556. * @param updatable whether the data is updatable
  64557. * @param stride the stride (optional)
  64558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64559. * @param instanced whether the buffer is instanced (optional)
  64560. * @param useBytes set to true if the stride in in bytes (optional)
  64561. */
  64562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64563. /**
  64564. * Create a new VertexBuffer based on the current buffer
  64565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64566. * @param offset defines offset in the buffer (0 by default)
  64567. * @param size defines the size in floats of attributes (position is 3 for instance)
  64568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64569. * @param instanced defines if the vertex buffer contains indexed data
  64570. * @param useBytes defines if the offset and stride are in bytes
  64571. * @returns the new vertex buffer
  64572. */
  64573. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64574. /**
  64575. * Gets a boolean indicating if the Buffer is updatable?
  64576. * @returns true if the buffer is updatable
  64577. */
  64578. isUpdatable(): boolean;
  64579. /**
  64580. * Gets current buffer's data
  64581. * @returns a DataArray or null
  64582. */
  64583. getData(): Nullable<DataArray>;
  64584. /**
  64585. * Gets underlying native buffer
  64586. * @returns underlying native buffer
  64587. */
  64588. getBuffer(): Nullable<WebGLBuffer>;
  64589. /**
  64590. * Gets the stride in float32 units (i.e. byte stride / 4).
  64591. * May not be an integer if the byte stride is not divisible by 4.
  64592. * DEPRECATED. Use byteStride instead.
  64593. * @returns the stride in float32 units
  64594. */
  64595. getStrideSize(): number;
  64596. /**
  64597. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64598. * @param data defines the data to store
  64599. */
  64600. create(data?: Nullable<DataArray>): void;
  64601. /** @hidden */
  64602. _rebuild(): void;
  64603. /**
  64604. * Update current buffer data
  64605. * @param data defines the data to store
  64606. */
  64607. update(data: DataArray): void;
  64608. /**
  64609. * Updates the data directly.
  64610. * @param data the new data
  64611. * @param offset the new offset
  64612. * @param vertexCount the vertex count (optional)
  64613. * @param useBytes set to true if the offset is in bytes
  64614. */
  64615. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64616. /**
  64617. * Release all resources
  64618. */
  64619. dispose(): void;
  64620. }
  64621. /**
  64622. * Specialized buffer used to store vertex data
  64623. */
  64624. export class VertexBuffer {
  64625. /** @hidden */
  64626. _buffer: Buffer;
  64627. private _kind;
  64628. private _size;
  64629. private _ownsBuffer;
  64630. private _instanced;
  64631. private _instanceDivisor;
  64632. /**
  64633. * The byte type.
  64634. */
  64635. static readonly BYTE: number;
  64636. /**
  64637. * The unsigned byte type.
  64638. */
  64639. static readonly UNSIGNED_BYTE: number;
  64640. /**
  64641. * The short type.
  64642. */
  64643. static readonly SHORT: number;
  64644. /**
  64645. * The unsigned short type.
  64646. */
  64647. static readonly UNSIGNED_SHORT: number;
  64648. /**
  64649. * The integer type.
  64650. */
  64651. static readonly INT: number;
  64652. /**
  64653. * The unsigned integer type.
  64654. */
  64655. static readonly UNSIGNED_INT: number;
  64656. /**
  64657. * The float type.
  64658. */
  64659. static readonly FLOAT: number;
  64660. /**
  64661. * Gets or sets the instance divisor when in instanced mode
  64662. */
  64663. instanceDivisor: number;
  64664. /**
  64665. * Gets the byte stride.
  64666. */
  64667. readonly byteStride: number;
  64668. /**
  64669. * Gets the byte offset.
  64670. */
  64671. readonly byteOffset: number;
  64672. /**
  64673. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64674. */
  64675. readonly normalized: boolean;
  64676. /**
  64677. * Gets the data type of each component in the array.
  64678. */
  64679. readonly type: number;
  64680. /**
  64681. * Constructor
  64682. * @param engine the engine
  64683. * @param data the data to use for this vertex buffer
  64684. * @param kind the vertex buffer kind
  64685. * @param updatable whether the data is updatable
  64686. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64687. * @param stride the stride (optional)
  64688. * @param instanced whether the buffer is instanced (optional)
  64689. * @param offset the offset of the data (optional)
  64690. * @param size the number of components (optional)
  64691. * @param type the type of the component (optional)
  64692. * @param normalized whether the data contains normalized data (optional)
  64693. * @param useBytes set to true if stride and offset are in bytes (optional)
  64694. */
  64695. 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);
  64696. /** @hidden */
  64697. _rebuild(): void;
  64698. /**
  64699. * Returns the kind of the VertexBuffer (string)
  64700. * @returns a string
  64701. */
  64702. getKind(): string;
  64703. /**
  64704. * Gets a boolean indicating if the VertexBuffer is updatable?
  64705. * @returns true if the buffer is updatable
  64706. */
  64707. isUpdatable(): boolean;
  64708. /**
  64709. * Gets current buffer's data
  64710. * @returns a DataArray or null
  64711. */
  64712. getData(): Nullable<DataArray>;
  64713. /**
  64714. * Gets underlying native buffer
  64715. * @returns underlying native buffer
  64716. */
  64717. getBuffer(): Nullable<WebGLBuffer>;
  64718. /**
  64719. * Gets the stride in float32 units (i.e. byte stride / 4).
  64720. * May not be an integer if the byte stride is not divisible by 4.
  64721. * DEPRECATED. Use byteStride instead.
  64722. * @returns the stride in float32 units
  64723. */
  64724. getStrideSize(): number;
  64725. /**
  64726. * Returns the offset as a multiple of the type byte length.
  64727. * DEPRECATED. Use byteOffset instead.
  64728. * @returns the offset in bytes
  64729. */
  64730. getOffset(): number;
  64731. /**
  64732. * Returns the number of components per vertex attribute (integer)
  64733. * @returns the size in float
  64734. */
  64735. getSize(): number;
  64736. /**
  64737. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64738. * @returns true if this buffer is instanced
  64739. */
  64740. getIsInstanced(): boolean;
  64741. /**
  64742. * Returns the instancing divisor, zero for non-instanced (integer).
  64743. * @returns a number
  64744. */
  64745. getInstanceDivisor(): number;
  64746. /**
  64747. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64748. * @param data defines the data to store
  64749. */
  64750. create(data?: DataArray): void;
  64751. /**
  64752. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64753. * This function will create a new buffer if the current one is not updatable
  64754. * @param data defines the data to store
  64755. */
  64756. update(data: DataArray): void;
  64757. /**
  64758. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64759. * Returns the directly updated WebGLBuffer.
  64760. * @param data the new data
  64761. * @param offset the new offset
  64762. * @param useBytes set to true if the offset is in bytes
  64763. */
  64764. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64765. /**
  64766. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64767. */
  64768. dispose(): void;
  64769. /**
  64770. * Enumerates each value of this vertex buffer as numbers.
  64771. * @param count the number of values to enumerate
  64772. * @param callback the callback function called for each value
  64773. */
  64774. forEach(count: number, callback: (value: number, index: number) => void): void;
  64775. /**
  64776. * Positions
  64777. */
  64778. static readonly PositionKind: string;
  64779. /**
  64780. * Normals
  64781. */
  64782. static readonly NormalKind: string;
  64783. /**
  64784. * Tangents
  64785. */
  64786. static readonly TangentKind: string;
  64787. /**
  64788. * Texture coordinates
  64789. */
  64790. static readonly UVKind: string;
  64791. /**
  64792. * Texture coordinates 2
  64793. */
  64794. static readonly UV2Kind: string;
  64795. /**
  64796. * Texture coordinates 3
  64797. */
  64798. static readonly UV3Kind: string;
  64799. /**
  64800. * Texture coordinates 4
  64801. */
  64802. static readonly UV4Kind: string;
  64803. /**
  64804. * Texture coordinates 5
  64805. */
  64806. static readonly UV5Kind: string;
  64807. /**
  64808. * Texture coordinates 6
  64809. */
  64810. static readonly UV6Kind: string;
  64811. /**
  64812. * Colors
  64813. */
  64814. static readonly ColorKind: string;
  64815. /**
  64816. * Matrix indices (for bones)
  64817. */
  64818. static readonly MatricesIndicesKind: string;
  64819. /**
  64820. * Matrix weights (for bones)
  64821. */
  64822. static readonly MatricesWeightsKind: string;
  64823. /**
  64824. * Additional matrix indices (for bones)
  64825. */
  64826. static readonly MatricesIndicesExtraKind: string;
  64827. /**
  64828. * Additional matrix weights (for bones)
  64829. */
  64830. static readonly MatricesWeightsExtraKind: string;
  64831. /**
  64832. * Deduces the stride given a kind.
  64833. * @param kind The kind string to deduce
  64834. * @returns The deduced stride
  64835. */
  64836. static DeduceStride(kind: string): number;
  64837. /**
  64838. * Gets the byte length of the given type.
  64839. * @param type the type
  64840. * @returns the number of bytes
  64841. */
  64842. static GetTypeByteLength(type: number): number;
  64843. /**
  64844. * Enumerates each value of the given parameters as numbers.
  64845. * @param data the data to enumerate
  64846. * @param byteOffset the byte offset of the data
  64847. * @param byteStride the byte stride of the data
  64848. * @param componentCount the number of components per element
  64849. * @param componentType the type of the component
  64850. * @param count the total number of components
  64851. * @param normalized whether the data is normalized
  64852. * @param callback the callback function called for each value
  64853. */
  64854. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64855. private static _GetFloatValue;
  64856. }
  64857. }
  64858. declare module BABYLON {
  64859. /**
  64860. * Class representing spherical polynomial coefficients to the 3rd degree
  64861. */
  64862. export class SphericalPolynomial {
  64863. /**
  64864. * The x coefficients of the spherical polynomial
  64865. */
  64866. x: Vector3;
  64867. /**
  64868. * The y coefficients of the spherical polynomial
  64869. */
  64870. y: Vector3;
  64871. /**
  64872. * The z coefficients of the spherical polynomial
  64873. */
  64874. z: Vector3;
  64875. /**
  64876. * The xx coefficients of the spherical polynomial
  64877. */
  64878. xx: Vector3;
  64879. /**
  64880. * The yy coefficients of the spherical polynomial
  64881. */
  64882. yy: Vector3;
  64883. /**
  64884. * The zz coefficients of the spherical polynomial
  64885. */
  64886. zz: Vector3;
  64887. /**
  64888. * The xy coefficients of the spherical polynomial
  64889. */
  64890. xy: Vector3;
  64891. /**
  64892. * The yz coefficients of the spherical polynomial
  64893. */
  64894. yz: Vector3;
  64895. /**
  64896. * The zx coefficients of the spherical polynomial
  64897. */
  64898. zx: Vector3;
  64899. /**
  64900. * Adds an ambient color to the spherical polynomial
  64901. * @param color the color to add
  64902. */
  64903. addAmbient(color: Color3): void;
  64904. /**
  64905. * Scales the spherical polynomial by the given amount
  64906. * @param scale the amount to scale
  64907. */
  64908. scale(scale: number): void;
  64909. /**
  64910. * Gets the spherical polynomial from harmonics
  64911. * @param harmonics the spherical harmonics
  64912. * @returns the spherical polynomial
  64913. */
  64914. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64915. /**
  64916. * Constructs a spherical polynomial from an array.
  64917. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64918. * @returns the spherical polynomial
  64919. */
  64920. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64921. }
  64922. /**
  64923. * Class representing spherical harmonics coefficients to the 3rd degree
  64924. */
  64925. export class SphericalHarmonics {
  64926. /**
  64927. * The l0,0 coefficients of the spherical harmonics
  64928. */
  64929. l00: Vector3;
  64930. /**
  64931. * The l1,-1 coefficients of the spherical harmonics
  64932. */
  64933. l1_1: Vector3;
  64934. /**
  64935. * The l1,0 coefficients of the spherical harmonics
  64936. */
  64937. l10: Vector3;
  64938. /**
  64939. * The l1,1 coefficients of the spherical harmonics
  64940. */
  64941. l11: Vector3;
  64942. /**
  64943. * The l2,-2 coefficients of the spherical harmonics
  64944. */
  64945. l2_2: Vector3;
  64946. /**
  64947. * The l2,-1 coefficients of the spherical harmonics
  64948. */
  64949. l2_1: Vector3;
  64950. /**
  64951. * The l2,0 coefficients of the spherical harmonics
  64952. */
  64953. l20: Vector3;
  64954. /**
  64955. * The l2,1 coefficients of the spherical harmonics
  64956. */
  64957. l21: Vector3;
  64958. /**
  64959. * The l2,2 coefficients of the spherical harmonics
  64960. */
  64961. lL22: Vector3;
  64962. /**
  64963. * Adds a light to the spherical harmonics
  64964. * @param direction the direction of the light
  64965. * @param color the color of the light
  64966. * @param deltaSolidAngle the delta solid angle of the light
  64967. */
  64968. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64969. /**
  64970. * Scales the spherical harmonics by the given amount
  64971. * @param scale the amount to scale
  64972. */
  64973. scale(scale: number): void;
  64974. /**
  64975. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64976. *
  64977. * ```
  64978. * E_lm = A_l * L_lm
  64979. * ```
  64980. *
  64981. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64982. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64983. * the scaling factors are given in equation 9.
  64984. */
  64985. convertIncidentRadianceToIrradiance(): void;
  64986. /**
  64987. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64988. *
  64989. * ```
  64990. * L = (1/pi) * E * rho
  64991. * ```
  64992. *
  64993. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64994. */
  64995. convertIrradianceToLambertianRadiance(): void;
  64996. /**
  64997. * Gets the spherical harmonics from polynomial
  64998. * @param polynomial the spherical polynomial
  64999. * @returns the spherical harmonics
  65000. */
  65001. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65002. /**
  65003. * Constructs a spherical harmonics from an array.
  65004. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65005. * @returns the spherical harmonics
  65006. */
  65007. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65008. }
  65009. }
  65010. declare module BABYLON {
  65011. /**
  65012. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65013. */
  65014. export interface CubeMapInfo {
  65015. /**
  65016. * The pixel array for the front face.
  65017. * This is stored in format, left to right, up to down format.
  65018. */
  65019. front: Nullable<ArrayBufferView>;
  65020. /**
  65021. * The pixel array for the back face.
  65022. * This is stored in format, left to right, up to down format.
  65023. */
  65024. back: Nullable<ArrayBufferView>;
  65025. /**
  65026. * The pixel array for the left face.
  65027. * This is stored in format, left to right, up to down format.
  65028. */
  65029. left: Nullable<ArrayBufferView>;
  65030. /**
  65031. * The pixel array for the right face.
  65032. * This is stored in format, left to right, up to down format.
  65033. */
  65034. right: Nullable<ArrayBufferView>;
  65035. /**
  65036. * The pixel array for the up face.
  65037. * This is stored in format, left to right, up to down format.
  65038. */
  65039. up: Nullable<ArrayBufferView>;
  65040. /**
  65041. * The pixel array for the down face.
  65042. * This is stored in format, left to right, up to down format.
  65043. */
  65044. down: Nullable<ArrayBufferView>;
  65045. /**
  65046. * The size of the cubemap stored.
  65047. *
  65048. * Each faces will be size * size pixels.
  65049. */
  65050. size: number;
  65051. /**
  65052. * The format of the texture.
  65053. *
  65054. * RGBA, RGB.
  65055. */
  65056. format: number;
  65057. /**
  65058. * The type of the texture data.
  65059. *
  65060. * UNSIGNED_INT, FLOAT.
  65061. */
  65062. type: number;
  65063. /**
  65064. * Specifies whether the texture is in gamma space.
  65065. */
  65066. gammaSpace: boolean;
  65067. }
  65068. /**
  65069. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65070. */
  65071. export class PanoramaToCubeMapTools {
  65072. private static FACE_FRONT;
  65073. private static FACE_BACK;
  65074. private static FACE_RIGHT;
  65075. private static FACE_LEFT;
  65076. private static FACE_DOWN;
  65077. private static FACE_UP;
  65078. /**
  65079. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65080. *
  65081. * @param float32Array The source data.
  65082. * @param inputWidth The width of the input panorama.
  65083. * @param inputHeight The height of the input panorama.
  65084. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65085. * @return The cubemap data
  65086. */
  65087. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65088. private static CreateCubemapTexture;
  65089. private static CalcProjectionSpherical;
  65090. }
  65091. }
  65092. declare module BABYLON {
  65093. /**
  65094. * Helper class dealing with the extraction of spherical polynomial dataArray
  65095. * from a cube map.
  65096. */
  65097. export class CubeMapToSphericalPolynomialTools {
  65098. private static FileFaces;
  65099. /**
  65100. * Converts a texture to the according Spherical Polynomial data.
  65101. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65102. *
  65103. * @param texture The texture to extract the information from.
  65104. * @return The Spherical Polynomial data.
  65105. */
  65106. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65107. /**
  65108. * Converts a cubemap to the according Spherical Polynomial data.
  65109. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65110. *
  65111. * @param cubeInfo The Cube map to extract the information from.
  65112. * @return The Spherical Polynomial data.
  65113. */
  65114. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65115. }
  65116. }
  65117. declare module BABYLON {
  65118. /**
  65119. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65120. * during the life time of the application.
  65121. */
  65122. export class EngineStore {
  65123. /** Gets the list of created engines */
  65124. static Instances: Engine[];
  65125. /**
  65126. * Gets the latest created engine
  65127. */
  65128. static readonly LastCreatedEngine: Nullable<Engine>;
  65129. /**
  65130. * Gets the latest created scene
  65131. */
  65132. static readonly LastCreatedScene: Nullable<Scene>;
  65133. }
  65134. }
  65135. declare module BABYLON {
  65136. /**
  65137. * Define options used to create a render target texture
  65138. */
  65139. export class RenderTargetCreationOptions {
  65140. /**
  65141. * Specifies is mipmaps must be generated
  65142. */
  65143. generateMipMaps?: boolean;
  65144. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65145. generateDepthBuffer?: boolean;
  65146. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65147. generateStencilBuffer?: boolean;
  65148. /** Defines texture type (int by default) */
  65149. type?: number;
  65150. /** Defines sampling mode (trilinear by default) */
  65151. samplingMode?: number;
  65152. /** Defines format (RGBA by default) */
  65153. format?: number;
  65154. }
  65155. }
  65156. declare module BABYLON {
  65157. /**
  65158. * @hidden
  65159. **/
  65160. export class _AlphaState {
  65161. private _isAlphaBlendDirty;
  65162. private _isBlendFunctionParametersDirty;
  65163. private _isBlendEquationParametersDirty;
  65164. private _isBlendConstantsDirty;
  65165. private _alphaBlend;
  65166. private _blendFunctionParameters;
  65167. private _blendEquationParameters;
  65168. private _blendConstants;
  65169. /**
  65170. * Initializes the state.
  65171. */
  65172. constructor();
  65173. readonly isDirty: boolean;
  65174. alphaBlend: boolean;
  65175. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65176. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65177. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65178. reset(): void;
  65179. apply(gl: WebGLRenderingContext): void;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /**
  65184. * @hidden
  65185. **/
  65186. export class _DepthCullingState {
  65187. private _isDepthTestDirty;
  65188. private _isDepthMaskDirty;
  65189. private _isDepthFuncDirty;
  65190. private _isCullFaceDirty;
  65191. private _isCullDirty;
  65192. private _isZOffsetDirty;
  65193. private _isFrontFaceDirty;
  65194. private _depthTest;
  65195. private _depthMask;
  65196. private _depthFunc;
  65197. private _cull;
  65198. private _cullFace;
  65199. private _zOffset;
  65200. private _frontFace;
  65201. /**
  65202. * Initializes the state.
  65203. */
  65204. constructor();
  65205. readonly isDirty: boolean;
  65206. zOffset: number;
  65207. cullFace: Nullable<number>;
  65208. cull: Nullable<boolean>;
  65209. depthFunc: Nullable<number>;
  65210. depthMask: boolean;
  65211. depthTest: boolean;
  65212. frontFace: Nullable<number>;
  65213. reset(): void;
  65214. apply(gl: WebGLRenderingContext): void;
  65215. }
  65216. }
  65217. declare module BABYLON {
  65218. /**
  65219. * @hidden
  65220. **/
  65221. export class _StencilState {
  65222. /** 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 */
  65223. static readonly ALWAYS: number;
  65224. /** Passed to stencilOperation to specify that stencil value must be kept */
  65225. static readonly KEEP: number;
  65226. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65227. static readonly REPLACE: number;
  65228. private _isStencilTestDirty;
  65229. private _isStencilMaskDirty;
  65230. private _isStencilFuncDirty;
  65231. private _isStencilOpDirty;
  65232. private _stencilTest;
  65233. private _stencilMask;
  65234. private _stencilFunc;
  65235. private _stencilFuncRef;
  65236. private _stencilFuncMask;
  65237. private _stencilOpStencilFail;
  65238. private _stencilOpDepthFail;
  65239. private _stencilOpStencilDepthPass;
  65240. readonly isDirty: boolean;
  65241. stencilFunc: number;
  65242. stencilFuncRef: number;
  65243. stencilFuncMask: number;
  65244. stencilOpStencilFail: number;
  65245. stencilOpDepthFail: number;
  65246. stencilOpStencilDepthPass: number;
  65247. stencilMask: number;
  65248. stencilTest: boolean;
  65249. constructor();
  65250. reset(): void;
  65251. apply(gl: WebGLRenderingContext): void;
  65252. }
  65253. }
  65254. declare module BABYLON {
  65255. /**
  65256. * @hidden
  65257. **/
  65258. export class _TimeToken {
  65259. _startTimeQuery: Nullable<WebGLQuery>;
  65260. _endTimeQuery: Nullable<WebGLQuery>;
  65261. _timeElapsedQuery: Nullable<WebGLQuery>;
  65262. _timeElapsedQueryEnded: boolean;
  65263. }
  65264. }
  65265. declare module BABYLON {
  65266. /**
  65267. * Internal interface used to track InternalTexture already bound to the GL context
  65268. */
  65269. export interface IInternalTextureTracker {
  65270. /**
  65271. * Gets or set the previous tracker in the list
  65272. */
  65273. previous: Nullable<IInternalTextureTracker>;
  65274. /**
  65275. * Gets or set the next tracker in the list
  65276. */
  65277. next: Nullable<IInternalTextureTracker>;
  65278. }
  65279. /**
  65280. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  65281. */
  65282. export class DummyInternalTextureTracker {
  65283. /**
  65284. * Gets or set the previous tracker in the list
  65285. */
  65286. previous: Nullable<IInternalTextureTracker>;
  65287. /**
  65288. * Gets or set the next tracker in the list
  65289. */
  65290. next: Nullable<IInternalTextureTracker>;
  65291. }
  65292. }
  65293. declare module BABYLON {
  65294. /**
  65295. * Class used to store data associated with WebGL texture data for the engine
  65296. * This class should not be used directly
  65297. */
  65298. export class InternalTexture implements IInternalTextureTracker {
  65299. /** hidden */
  65300. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65301. /**
  65302. * The source of the texture data is unknown
  65303. */
  65304. static DATASOURCE_UNKNOWN: number;
  65305. /**
  65306. * Texture data comes from an URL
  65307. */
  65308. static DATASOURCE_URL: number;
  65309. /**
  65310. * Texture data is only used for temporary storage
  65311. */
  65312. static DATASOURCE_TEMP: number;
  65313. /**
  65314. * Texture data comes from raw data (ArrayBuffer)
  65315. */
  65316. static DATASOURCE_RAW: number;
  65317. /**
  65318. * Texture content is dynamic (video or dynamic texture)
  65319. */
  65320. static DATASOURCE_DYNAMIC: number;
  65321. /**
  65322. * Texture content is generated by rendering to it
  65323. */
  65324. static DATASOURCE_RENDERTARGET: number;
  65325. /**
  65326. * Texture content is part of a multi render target process
  65327. */
  65328. static DATASOURCE_MULTIRENDERTARGET: number;
  65329. /**
  65330. * Texture data comes from a cube data file
  65331. */
  65332. static DATASOURCE_CUBE: number;
  65333. /**
  65334. * Texture data comes from a raw cube data
  65335. */
  65336. static DATASOURCE_CUBERAW: number;
  65337. /**
  65338. * Texture data come from a prefiltered cube data file
  65339. */
  65340. static DATASOURCE_CUBEPREFILTERED: number;
  65341. /**
  65342. * Texture content is raw 3D data
  65343. */
  65344. static DATASOURCE_RAW3D: number;
  65345. /**
  65346. * Texture content is a depth texture
  65347. */
  65348. static DATASOURCE_DEPTHTEXTURE: number;
  65349. /**
  65350. * Texture data comes from a raw cube data encoded with RGBD
  65351. */
  65352. static DATASOURCE_CUBERAW_RGBD: number;
  65353. /**
  65354. * Defines if the texture is ready
  65355. */
  65356. isReady: boolean;
  65357. /**
  65358. * Defines if the texture is a cube texture
  65359. */
  65360. isCube: boolean;
  65361. /**
  65362. * Defines if the texture contains 3D data
  65363. */
  65364. is3D: boolean;
  65365. /**
  65366. * Defines if the texture contains multiview data
  65367. */
  65368. isMultiview: boolean;
  65369. /**
  65370. * Gets the URL used to load this texture
  65371. */
  65372. url: string;
  65373. /**
  65374. * Gets the sampling mode of the texture
  65375. */
  65376. samplingMode: number;
  65377. /**
  65378. * Gets a boolean indicating if the texture needs mipmaps generation
  65379. */
  65380. generateMipMaps: boolean;
  65381. /**
  65382. * Gets the number of samples used by the texture (WebGL2+ only)
  65383. */
  65384. samples: number;
  65385. /**
  65386. * Gets the type of the texture (int, float...)
  65387. */
  65388. type: number;
  65389. /**
  65390. * Gets the format of the texture (RGB, RGBA...)
  65391. */
  65392. format: number;
  65393. /**
  65394. * Observable called when the texture is loaded
  65395. */
  65396. onLoadedObservable: Observable<InternalTexture>;
  65397. /**
  65398. * Gets the width of the texture
  65399. */
  65400. width: number;
  65401. /**
  65402. * Gets the height of the texture
  65403. */
  65404. height: number;
  65405. /**
  65406. * Gets the depth of the texture
  65407. */
  65408. depth: number;
  65409. /**
  65410. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65411. */
  65412. baseWidth: number;
  65413. /**
  65414. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65415. */
  65416. baseHeight: number;
  65417. /**
  65418. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65419. */
  65420. baseDepth: number;
  65421. /**
  65422. * Gets a boolean indicating if the texture is inverted on Y axis
  65423. */
  65424. invertY: boolean;
  65425. /**
  65426. * Gets or set the previous tracker in the list
  65427. */
  65428. previous: Nullable<IInternalTextureTracker>;
  65429. /**
  65430. * Gets or set the next tracker in the list
  65431. */
  65432. next: Nullable<IInternalTextureTracker>;
  65433. /** @hidden */
  65434. _invertVScale: boolean;
  65435. /** @hidden */
  65436. _initialSlot: number;
  65437. /** @hidden */
  65438. _designatedSlot: number;
  65439. /** @hidden */
  65440. _dataSource: number;
  65441. /** @hidden */
  65442. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65443. /** @hidden */
  65444. _bufferView: Nullable<ArrayBufferView>;
  65445. /** @hidden */
  65446. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65447. /** @hidden */
  65448. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65449. /** @hidden */
  65450. _size: number;
  65451. /** @hidden */
  65452. _extension: string;
  65453. /** @hidden */
  65454. _files: Nullable<string[]>;
  65455. /** @hidden */
  65456. _workingCanvas: HTMLCanvasElement;
  65457. /** @hidden */
  65458. _workingContext: CanvasRenderingContext2D;
  65459. /** @hidden */
  65460. _framebuffer: Nullable<WebGLFramebuffer>;
  65461. /** @hidden */
  65462. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65463. /** @hidden */
  65464. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65465. /** @hidden */
  65466. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65467. /** @hidden */
  65468. _attachments: Nullable<number[]>;
  65469. /** @hidden */
  65470. _cachedCoordinatesMode: Nullable<number>;
  65471. /** @hidden */
  65472. _cachedWrapU: Nullable<number>;
  65473. /** @hidden */
  65474. _cachedWrapV: Nullable<number>;
  65475. /** @hidden */
  65476. _cachedWrapR: Nullable<number>;
  65477. /** @hidden */
  65478. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65479. /** @hidden */
  65480. _isDisabled: boolean;
  65481. /** @hidden */
  65482. _compression: Nullable<string>;
  65483. /** @hidden */
  65484. _generateStencilBuffer: boolean;
  65485. /** @hidden */
  65486. _generateDepthBuffer: boolean;
  65487. /** @hidden */
  65488. _comparisonFunction: number;
  65489. /** @hidden */
  65490. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65491. /** @hidden */
  65492. _lodGenerationScale: number;
  65493. /** @hidden */
  65494. _lodGenerationOffset: number;
  65495. /** @hidden */
  65496. _colorTextureArray: Nullable<WebGLTexture>;
  65497. /** @hidden */
  65498. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65499. /** @hidden */
  65500. _lodTextureHigh: BaseTexture;
  65501. /** @hidden */
  65502. _lodTextureMid: BaseTexture;
  65503. /** @hidden */
  65504. _lodTextureLow: BaseTexture;
  65505. /** @hidden */
  65506. _isRGBD: boolean;
  65507. /** @hidden */
  65508. _webGLTexture: Nullable<WebGLTexture>;
  65509. /** @hidden */
  65510. _references: number;
  65511. private _engine;
  65512. /**
  65513. * Gets the Engine the texture belongs to.
  65514. * @returns The babylon engine
  65515. */
  65516. getEngine(): Engine;
  65517. /**
  65518. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65519. */
  65520. readonly dataSource: number;
  65521. /**
  65522. * Creates a new InternalTexture
  65523. * @param engine defines the engine to use
  65524. * @param dataSource defines the type of data that will be used
  65525. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65526. */
  65527. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65528. /**
  65529. * Increments the number of references (ie. the number of Texture that point to it)
  65530. */
  65531. incrementReferences(): void;
  65532. /**
  65533. * Change the size of the texture (not the size of the content)
  65534. * @param width defines the new width
  65535. * @param height defines the new height
  65536. * @param depth defines the new depth (1 by default)
  65537. */
  65538. updateSize(width: int, height: int, depth?: int): void;
  65539. /** @hidden */
  65540. _rebuild(): void;
  65541. /** @hidden */
  65542. _swapAndDie(target: InternalTexture): void;
  65543. /**
  65544. * Dispose the current allocated resources
  65545. */
  65546. dispose(): void;
  65547. }
  65548. }
  65549. declare module BABYLON {
  65550. /**
  65551. * This represents the main contract an easing function should follow.
  65552. * Easing functions are used throughout the animation system.
  65553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65554. */
  65555. export interface IEasingFunction {
  65556. /**
  65557. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65558. * of the easing function.
  65559. * The link below provides some of the most common examples of easing functions.
  65560. * @see https://easings.net/
  65561. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65562. * @returns the corresponding value on the curve defined by the easing function
  65563. */
  65564. ease(gradient: number): number;
  65565. }
  65566. /**
  65567. * Base class used for every default easing function.
  65568. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65569. */
  65570. export class EasingFunction implements IEasingFunction {
  65571. /**
  65572. * Interpolation follows the mathematical formula associated with the easing function.
  65573. */
  65574. static readonly EASINGMODE_EASEIN: number;
  65575. /**
  65576. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65577. */
  65578. static readonly EASINGMODE_EASEOUT: number;
  65579. /**
  65580. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65581. */
  65582. static readonly EASINGMODE_EASEINOUT: number;
  65583. private _easingMode;
  65584. /**
  65585. * Sets the easing mode of the current function.
  65586. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65587. */
  65588. setEasingMode(easingMode: number): void;
  65589. /**
  65590. * Gets the current easing mode.
  65591. * @returns the easing mode
  65592. */
  65593. getEasingMode(): number;
  65594. /**
  65595. * @hidden
  65596. */
  65597. easeInCore(gradient: number): number;
  65598. /**
  65599. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65600. * of the easing function.
  65601. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65602. * @returns the corresponding value on the curve defined by the easing function
  65603. */
  65604. ease(gradient: number): number;
  65605. }
  65606. /**
  65607. * Easing function with a circle shape (see link below).
  65608. * @see https://easings.net/#easeInCirc
  65609. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65610. */
  65611. export class CircleEase extends EasingFunction implements IEasingFunction {
  65612. /** @hidden */
  65613. easeInCore(gradient: number): number;
  65614. }
  65615. /**
  65616. * Easing function with a ease back shape (see link below).
  65617. * @see https://easings.net/#easeInBack
  65618. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65619. */
  65620. export class BackEase extends EasingFunction implements IEasingFunction {
  65621. /** Defines the amplitude of the function */
  65622. amplitude: number;
  65623. /**
  65624. * Instantiates a back ease easing
  65625. * @see https://easings.net/#easeInBack
  65626. * @param amplitude Defines the amplitude of the function
  65627. */
  65628. constructor(
  65629. /** Defines the amplitude of the function */
  65630. amplitude?: number);
  65631. /** @hidden */
  65632. easeInCore(gradient: number): number;
  65633. }
  65634. /**
  65635. * Easing function with a bouncing shape (see link below).
  65636. * @see https://easings.net/#easeInBounce
  65637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65638. */
  65639. export class BounceEase extends EasingFunction implements IEasingFunction {
  65640. /** Defines the number of bounces */
  65641. bounces: number;
  65642. /** Defines the amplitude of the bounce */
  65643. bounciness: number;
  65644. /**
  65645. * Instantiates a bounce easing
  65646. * @see https://easings.net/#easeInBounce
  65647. * @param bounces Defines the number of bounces
  65648. * @param bounciness Defines the amplitude of the bounce
  65649. */
  65650. constructor(
  65651. /** Defines the number of bounces */
  65652. bounces?: number,
  65653. /** Defines the amplitude of the bounce */
  65654. bounciness?: number);
  65655. /** @hidden */
  65656. easeInCore(gradient: number): number;
  65657. }
  65658. /**
  65659. * Easing function with a power of 3 shape (see link below).
  65660. * @see https://easings.net/#easeInCubic
  65661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65662. */
  65663. export class CubicEase extends EasingFunction implements IEasingFunction {
  65664. /** @hidden */
  65665. easeInCore(gradient: number): number;
  65666. }
  65667. /**
  65668. * Easing function with an elastic shape (see link below).
  65669. * @see https://easings.net/#easeInElastic
  65670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65671. */
  65672. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65673. /** Defines the number of oscillations*/
  65674. oscillations: number;
  65675. /** Defines the amplitude of the oscillations*/
  65676. springiness: number;
  65677. /**
  65678. * Instantiates an elastic easing function
  65679. * @see https://easings.net/#easeInElastic
  65680. * @param oscillations Defines the number of oscillations
  65681. * @param springiness Defines the amplitude of the oscillations
  65682. */
  65683. constructor(
  65684. /** Defines the number of oscillations*/
  65685. oscillations?: number,
  65686. /** Defines the amplitude of the oscillations*/
  65687. springiness?: number);
  65688. /** @hidden */
  65689. easeInCore(gradient: number): number;
  65690. }
  65691. /**
  65692. * Easing function with an exponential shape (see link below).
  65693. * @see https://easings.net/#easeInExpo
  65694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65695. */
  65696. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65697. /** Defines the exponent of the function */
  65698. exponent: number;
  65699. /**
  65700. * Instantiates an exponential easing function
  65701. * @see https://easings.net/#easeInExpo
  65702. * @param exponent Defines the exponent of the function
  65703. */
  65704. constructor(
  65705. /** Defines the exponent of the function */
  65706. exponent?: number);
  65707. /** @hidden */
  65708. easeInCore(gradient: number): number;
  65709. }
  65710. /**
  65711. * Easing function with a power shape (see link below).
  65712. * @see https://easings.net/#easeInQuad
  65713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65714. */
  65715. export class PowerEase extends EasingFunction implements IEasingFunction {
  65716. /** Defines the power of the function */
  65717. power: number;
  65718. /**
  65719. * Instantiates an power base easing function
  65720. * @see https://easings.net/#easeInQuad
  65721. * @param power Defines the power of the function
  65722. */
  65723. constructor(
  65724. /** Defines the power of the function */
  65725. power?: number);
  65726. /** @hidden */
  65727. easeInCore(gradient: number): number;
  65728. }
  65729. /**
  65730. * Easing function with a power of 2 shape (see link below).
  65731. * @see https://easings.net/#easeInQuad
  65732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65733. */
  65734. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65735. /** @hidden */
  65736. easeInCore(gradient: number): number;
  65737. }
  65738. /**
  65739. * Easing function with a power of 4 shape (see link below).
  65740. * @see https://easings.net/#easeInQuart
  65741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65742. */
  65743. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65744. /** @hidden */
  65745. easeInCore(gradient: number): number;
  65746. }
  65747. /**
  65748. * Easing function with a power of 5 shape (see link below).
  65749. * @see https://easings.net/#easeInQuint
  65750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65751. */
  65752. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65753. /** @hidden */
  65754. easeInCore(gradient: number): number;
  65755. }
  65756. /**
  65757. * Easing function with a sin shape (see link below).
  65758. * @see https://easings.net/#easeInSine
  65759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65760. */
  65761. export class SineEase extends EasingFunction implements IEasingFunction {
  65762. /** @hidden */
  65763. easeInCore(gradient: number): number;
  65764. }
  65765. /**
  65766. * Easing function with a bezier shape (see link below).
  65767. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65769. */
  65770. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65771. /** Defines the x component of the start tangent in the bezier curve */
  65772. x1: number;
  65773. /** Defines the y component of the start tangent in the bezier curve */
  65774. y1: number;
  65775. /** Defines the x component of the end tangent in the bezier curve */
  65776. x2: number;
  65777. /** Defines the y component of the end tangent in the bezier curve */
  65778. y2: number;
  65779. /**
  65780. * Instantiates a bezier function
  65781. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65782. * @param x1 Defines the x component of the start tangent in the bezier curve
  65783. * @param y1 Defines the y component of the start tangent in the bezier curve
  65784. * @param x2 Defines the x component of the end tangent in the bezier curve
  65785. * @param y2 Defines the y component of the end tangent in the bezier curve
  65786. */
  65787. constructor(
  65788. /** Defines the x component of the start tangent in the bezier curve */
  65789. x1?: number,
  65790. /** Defines the y component of the start tangent in the bezier curve */
  65791. y1?: number,
  65792. /** Defines the x component of the end tangent in the bezier curve */
  65793. x2?: number,
  65794. /** Defines the y component of the end tangent in the bezier curve */
  65795. y2?: number);
  65796. /** @hidden */
  65797. easeInCore(gradient: number): number;
  65798. }
  65799. }
  65800. declare module BABYLON {
  65801. /**
  65802. * Defines an interface which represents an animation key frame
  65803. */
  65804. export interface IAnimationKey {
  65805. /**
  65806. * Frame of the key frame
  65807. */
  65808. frame: number;
  65809. /**
  65810. * Value at the specifies key frame
  65811. */
  65812. value: any;
  65813. /**
  65814. * The input tangent for the cubic hermite spline
  65815. */
  65816. inTangent?: any;
  65817. /**
  65818. * The output tangent for the cubic hermite spline
  65819. */
  65820. outTangent?: any;
  65821. /**
  65822. * The animation interpolation type
  65823. */
  65824. interpolation?: AnimationKeyInterpolation;
  65825. }
  65826. /**
  65827. * Enum for the animation key frame interpolation type
  65828. */
  65829. export enum AnimationKeyInterpolation {
  65830. /**
  65831. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65832. */
  65833. STEP = 1
  65834. }
  65835. }
  65836. declare module BABYLON {
  65837. /**
  65838. * Represents the range of an animation
  65839. */
  65840. export class AnimationRange {
  65841. /**The name of the animation range**/
  65842. name: string;
  65843. /**The starting frame of the animation */
  65844. from: number;
  65845. /**The ending frame of the animation*/
  65846. to: number;
  65847. /**
  65848. * Initializes the range of an animation
  65849. * @param name The name of the animation range
  65850. * @param from The starting frame of the animation
  65851. * @param to The ending frame of the animation
  65852. */
  65853. constructor(
  65854. /**The name of the animation range**/
  65855. name: string,
  65856. /**The starting frame of the animation */
  65857. from: number,
  65858. /**The ending frame of the animation*/
  65859. to: number);
  65860. /**
  65861. * Makes a copy of the animation range
  65862. * @returns A copy of the animation range
  65863. */
  65864. clone(): AnimationRange;
  65865. }
  65866. }
  65867. declare module BABYLON {
  65868. /**
  65869. * Composed of a frame, and an action function
  65870. */
  65871. export class AnimationEvent {
  65872. /** The frame for which the event is triggered **/
  65873. frame: number;
  65874. /** The event to perform when triggered **/
  65875. action: (currentFrame: number) => void;
  65876. /** Specifies if the event should be triggered only once**/
  65877. onlyOnce?: boolean | undefined;
  65878. /**
  65879. * Specifies if the animation event is done
  65880. */
  65881. isDone: boolean;
  65882. /**
  65883. * Initializes the animation event
  65884. * @param frame The frame for which the event is triggered
  65885. * @param action The event to perform when triggered
  65886. * @param onlyOnce Specifies if the event should be triggered only once
  65887. */
  65888. constructor(
  65889. /** The frame for which the event is triggered **/
  65890. frame: number,
  65891. /** The event to perform when triggered **/
  65892. action: (currentFrame: number) => void,
  65893. /** Specifies if the event should be triggered only once**/
  65894. onlyOnce?: boolean | undefined);
  65895. /** @hidden */
  65896. _clone(): AnimationEvent;
  65897. }
  65898. }
  65899. declare module BABYLON {
  65900. /**
  65901. * Interface used to define a behavior
  65902. */
  65903. export interface Behavior<T> {
  65904. /** gets or sets behavior's name */
  65905. name: string;
  65906. /**
  65907. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65908. */
  65909. init(): void;
  65910. /**
  65911. * Called when the behavior is attached to a target
  65912. * @param target defines the target where the behavior is attached to
  65913. */
  65914. attach(target: T): void;
  65915. /**
  65916. * Called when the behavior is detached from its target
  65917. */
  65918. detach(): void;
  65919. }
  65920. /**
  65921. * Interface implemented by classes supporting behaviors
  65922. */
  65923. export interface IBehaviorAware<T> {
  65924. /**
  65925. * Attach a behavior
  65926. * @param behavior defines the behavior to attach
  65927. * @returns the current host
  65928. */
  65929. addBehavior(behavior: Behavior<T>): T;
  65930. /**
  65931. * Remove a behavior from the current object
  65932. * @param behavior defines the behavior to detach
  65933. * @returns the current host
  65934. */
  65935. removeBehavior(behavior: Behavior<T>): T;
  65936. /**
  65937. * Gets a behavior using its name to search
  65938. * @param name defines the name to search
  65939. * @returns the behavior or null if not found
  65940. */
  65941. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65942. }
  65943. }
  65944. declare module BABYLON {
  65945. /**
  65946. * @hidden
  65947. */
  65948. export class IntersectionInfo {
  65949. bu: Nullable<number>;
  65950. bv: Nullable<number>;
  65951. distance: number;
  65952. faceId: number;
  65953. subMeshId: number;
  65954. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65955. }
  65956. }
  65957. declare module BABYLON {
  65958. /**
  65959. * Class used to store bounding sphere information
  65960. */
  65961. export class BoundingSphere {
  65962. /**
  65963. * Gets the center of the bounding sphere in local space
  65964. */
  65965. readonly center: Vector3;
  65966. /**
  65967. * Radius of the bounding sphere in local space
  65968. */
  65969. radius: number;
  65970. /**
  65971. * Gets the center of the bounding sphere in world space
  65972. */
  65973. readonly centerWorld: Vector3;
  65974. /**
  65975. * Radius of the bounding sphere in world space
  65976. */
  65977. radiusWorld: number;
  65978. /**
  65979. * Gets the minimum vector in local space
  65980. */
  65981. readonly minimum: Vector3;
  65982. /**
  65983. * Gets the maximum vector in local space
  65984. */
  65985. readonly maximum: Vector3;
  65986. private _worldMatrix;
  65987. private static readonly TmpVector3;
  65988. /**
  65989. * Creates a new bounding sphere
  65990. * @param min defines the minimum vector (in local space)
  65991. * @param max defines the maximum vector (in local space)
  65992. * @param worldMatrix defines the new world matrix
  65993. */
  65994. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65995. /**
  65996. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65997. * @param min defines the new minimum vector (in local space)
  65998. * @param max defines the new maximum vector (in local space)
  65999. * @param worldMatrix defines the new world matrix
  66000. */
  66001. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66002. /**
  66003. * Scale the current bounding sphere by applying a scale factor
  66004. * @param factor defines the scale factor to apply
  66005. * @returns the current bounding box
  66006. */
  66007. scale(factor: number): BoundingSphere;
  66008. /**
  66009. * Gets the world matrix of the bounding box
  66010. * @returns a matrix
  66011. */
  66012. getWorldMatrix(): DeepImmutable<Matrix>;
  66013. /** @hidden */
  66014. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66015. /**
  66016. * Tests if the bounding sphere is intersecting the frustum planes
  66017. * @param frustumPlanes defines the frustum planes to test
  66018. * @returns true if there is an intersection
  66019. */
  66020. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66021. /**
  66022. * Tests if the bounding sphere center is in between the frustum planes.
  66023. * Used for optimistic fast inclusion.
  66024. * @param frustumPlanes defines the frustum planes to test
  66025. * @returns true if the sphere center is in between the frustum planes
  66026. */
  66027. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66028. /**
  66029. * Tests if a point is inside the bounding sphere
  66030. * @param point defines the point to test
  66031. * @returns true if the point is inside the bounding sphere
  66032. */
  66033. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66034. /**
  66035. * Checks if two sphere intersct
  66036. * @param sphere0 sphere 0
  66037. * @param sphere1 sphere 1
  66038. * @returns true if the speres intersect
  66039. */
  66040. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66041. }
  66042. }
  66043. declare module BABYLON {
  66044. /**
  66045. * Class used to store bounding box information
  66046. */
  66047. export class BoundingBox implements ICullable {
  66048. /**
  66049. * Gets the 8 vectors representing the bounding box in local space
  66050. */
  66051. readonly vectors: Vector3[];
  66052. /**
  66053. * Gets the center of the bounding box in local space
  66054. */
  66055. readonly center: Vector3;
  66056. /**
  66057. * Gets the center of the bounding box in world space
  66058. */
  66059. readonly centerWorld: Vector3;
  66060. /**
  66061. * Gets the extend size in local space
  66062. */
  66063. readonly extendSize: Vector3;
  66064. /**
  66065. * Gets the extend size in world space
  66066. */
  66067. readonly extendSizeWorld: Vector3;
  66068. /**
  66069. * Gets the OBB (object bounding box) directions
  66070. */
  66071. readonly directions: Vector3[];
  66072. /**
  66073. * Gets the 8 vectors representing the bounding box in world space
  66074. */
  66075. readonly vectorsWorld: Vector3[];
  66076. /**
  66077. * Gets the minimum vector in world space
  66078. */
  66079. readonly minimumWorld: Vector3;
  66080. /**
  66081. * Gets the maximum vector in world space
  66082. */
  66083. readonly maximumWorld: Vector3;
  66084. /**
  66085. * Gets the minimum vector in local space
  66086. */
  66087. readonly minimum: Vector3;
  66088. /**
  66089. * Gets the maximum vector in local space
  66090. */
  66091. readonly maximum: Vector3;
  66092. private _worldMatrix;
  66093. private static readonly TmpVector3;
  66094. /**
  66095. * @hidden
  66096. */
  66097. _tag: number;
  66098. /**
  66099. * Creates a new bounding box
  66100. * @param min defines the minimum vector (in local space)
  66101. * @param max defines the maximum vector (in local space)
  66102. * @param worldMatrix defines the new world matrix
  66103. */
  66104. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66105. /**
  66106. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66107. * @param min defines the new minimum vector (in local space)
  66108. * @param max defines the new maximum vector (in local space)
  66109. * @param worldMatrix defines the new world matrix
  66110. */
  66111. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66112. /**
  66113. * Scale the current bounding box by applying a scale factor
  66114. * @param factor defines the scale factor to apply
  66115. * @returns the current bounding box
  66116. */
  66117. scale(factor: number): BoundingBox;
  66118. /**
  66119. * Gets the world matrix of the bounding box
  66120. * @returns a matrix
  66121. */
  66122. getWorldMatrix(): DeepImmutable<Matrix>;
  66123. /** @hidden */
  66124. _update(world: DeepImmutable<Matrix>): void;
  66125. /**
  66126. * Tests if the bounding box is intersecting the frustum planes
  66127. * @param frustumPlanes defines the frustum planes to test
  66128. * @returns true if there is an intersection
  66129. */
  66130. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66131. /**
  66132. * Tests if the bounding box is entirely inside the frustum planes
  66133. * @param frustumPlanes defines the frustum planes to test
  66134. * @returns true if there is an inclusion
  66135. */
  66136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66137. /**
  66138. * Tests if a point is inside the bounding box
  66139. * @param point defines the point to test
  66140. * @returns true if the point is inside the bounding box
  66141. */
  66142. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66143. /**
  66144. * Tests if the bounding box intersects with a bounding sphere
  66145. * @param sphere defines the sphere to test
  66146. * @returns true if there is an intersection
  66147. */
  66148. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66149. /**
  66150. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66151. * @param min defines the min vector to use
  66152. * @param max defines the max vector to use
  66153. * @returns true if there is an intersection
  66154. */
  66155. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66156. /**
  66157. * Tests if two bounding boxes are intersections
  66158. * @param box0 defines the first box to test
  66159. * @param box1 defines the second box to test
  66160. * @returns true if there is an intersection
  66161. */
  66162. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66163. /**
  66164. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66165. * @param minPoint defines the minimum vector of the bounding box
  66166. * @param maxPoint defines the maximum vector of the bounding box
  66167. * @param sphereCenter defines the sphere center
  66168. * @param sphereRadius defines the sphere radius
  66169. * @returns true if there is an intersection
  66170. */
  66171. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66172. /**
  66173. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66174. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66175. * @param frustumPlanes defines the frustum planes to test
  66176. * @return true if there is an inclusion
  66177. */
  66178. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66179. /**
  66180. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66181. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66182. * @param frustumPlanes defines the frustum planes to test
  66183. * @return true if there is an intersection
  66184. */
  66185. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66186. }
  66187. }
  66188. declare module BABYLON {
  66189. /** @hidden */
  66190. export class Collider {
  66191. /** Define if a collision was found */
  66192. collisionFound: boolean;
  66193. /**
  66194. * Define last intersection point in local space
  66195. */
  66196. intersectionPoint: Vector3;
  66197. /**
  66198. * Define last collided mesh
  66199. */
  66200. collidedMesh: Nullable<AbstractMesh>;
  66201. private _collisionPoint;
  66202. private _planeIntersectionPoint;
  66203. private _tempVector;
  66204. private _tempVector2;
  66205. private _tempVector3;
  66206. private _tempVector4;
  66207. private _edge;
  66208. private _baseToVertex;
  66209. private _destinationPoint;
  66210. private _slidePlaneNormal;
  66211. private _displacementVector;
  66212. /** @hidden */
  66213. _radius: Vector3;
  66214. /** @hidden */
  66215. _retry: number;
  66216. private _velocity;
  66217. private _basePoint;
  66218. private _epsilon;
  66219. /** @hidden */
  66220. _velocityWorldLength: number;
  66221. /** @hidden */
  66222. _basePointWorld: Vector3;
  66223. private _velocityWorld;
  66224. private _normalizedVelocity;
  66225. /** @hidden */
  66226. _initialVelocity: Vector3;
  66227. /** @hidden */
  66228. _initialPosition: Vector3;
  66229. private _nearestDistance;
  66230. private _collisionMask;
  66231. collisionMask: number;
  66232. /**
  66233. * Gets the plane normal used to compute the sliding response (in local space)
  66234. */
  66235. readonly slidePlaneNormal: Vector3;
  66236. /** @hidden */
  66237. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66238. /** @hidden */
  66239. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66240. /** @hidden */
  66241. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66242. /** @hidden */
  66243. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66244. /** @hidden */
  66245. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66246. /** @hidden */
  66247. _getResponse(pos: Vector3, vel: Vector3): void;
  66248. }
  66249. }
  66250. declare module BABYLON {
  66251. /**
  66252. * Interface for cullable objects
  66253. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66254. */
  66255. export interface ICullable {
  66256. /**
  66257. * Checks if the object or part of the object is in the frustum
  66258. * @param frustumPlanes Camera near/planes
  66259. * @returns true if the object is in frustum otherwise false
  66260. */
  66261. isInFrustum(frustumPlanes: Plane[]): boolean;
  66262. /**
  66263. * Checks if a cullable object (mesh...) is in the camera frustum
  66264. * Unlike isInFrustum this cheks the full bounding box
  66265. * @param frustumPlanes Camera near/planes
  66266. * @returns true if the object is in frustum otherwise false
  66267. */
  66268. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66269. }
  66270. /**
  66271. * Info for a bounding data of a mesh
  66272. */
  66273. export class BoundingInfo implements ICullable {
  66274. /**
  66275. * Bounding box for the mesh
  66276. */
  66277. readonly boundingBox: BoundingBox;
  66278. /**
  66279. * Bounding sphere for the mesh
  66280. */
  66281. readonly boundingSphere: BoundingSphere;
  66282. private _isLocked;
  66283. private static readonly TmpVector3;
  66284. /**
  66285. * Constructs bounding info
  66286. * @param minimum min vector of the bounding box/sphere
  66287. * @param maximum max vector of the bounding box/sphere
  66288. * @param worldMatrix defines the new world matrix
  66289. */
  66290. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66291. /**
  66292. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66293. * @param min defines the new minimum vector (in local space)
  66294. * @param max defines the new maximum vector (in local space)
  66295. * @param worldMatrix defines the new world matrix
  66296. */
  66297. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66298. /**
  66299. * min vector of the bounding box/sphere
  66300. */
  66301. readonly minimum: Vector3;
  66302. /**
  66303. * max vector of the bounding box/sphere
  66304. */
  66305. readonly maximum: Vector3;
  66306. /**
  66307. * If the info is locked and won't be updated to avoid perf overhead
  66308. */
  66309. isLocked: boolean;
  66310. /**
  66311. * Updates the bounding sphere and box
  66312. * @param world world matrix to be used to update
  66313. */
  66314. update(world: DeepImmutable<Matrix>): void;
  66315. /**
  66316. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66317. * @param center New center of the bounding info
  66318. * @param extend New extend of the bounding info
  66319. * @returns the current bounding info
  66320. */
  66321. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66322. /**
  66323. * Scale the current bounding info by applying a scale factor
  66324. * @param factor defines the scale factor to apply
  66325. * @returns the current bounding info
  66326. */
  66327. scale(factor: number): BoundingInfo;
  66328. /**
  66329. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66330. * @param frustumPlanes defines the frustum to test
  66331. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66332. * @returns true if the bounding info is in the frustum planes
  66333. */
  66334. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66335. /**
  66336. * Gets the world distance between the min and max points of the bounding box
  66337. */
  66338. readonly diagonalLength: number;
  66339. /**
  66340. * Checks if a cullable object (mesh...) is in the camera frustum
  66341. * Unlike isInFrustum this cheks the full bounding box
  66342. * @param frustumPlanes Camera near/planes
  66343. * @returns true if the object is in frustum otherwise false
  66344. */
  66345. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66346. /** @hidden */
  66347. _checkCollision(collider: Collider): boolean;
  66348. /**
  66349. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66350. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66351. * @param point the point to check intersection with
  66352. * @returns if the point intersects
  66353. */
  66354. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66355. /**
  66356. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66357. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66358. * @param boundingInfo the bounding info to check intersection with
  66359. * @param precise if the intersection should be done using OBB
  66360. * @returns if the bounding info intersects
  66361. */
  66362. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66363. }
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * Defines an array and its length.
  66368. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66369. */
  66370. export interface ISmartArrayLike<T> {
  66371. /**
  66372. * The data of the array.
  66373. */
  66374. data: Array<T>;
  66375. /**
  66376. * The active length of the array.
  66377. */
  66378. length: number;
  66379. }
  66380. /**
  66381. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66382. */
  66383. export class SmartArray<T> implements ISmartArrayLike<T> {
  66384. /**
  66385. * The full set of data from the array.
  66386. */
  66387. data: Array<T>;
  66388. /**
  66389. * The active length of the array.
  66390. */
  66391. length: number;
  66392. protected _id: number;
  66393. /**
  66394. * Instantiates a Smart Array.
  66395. * @param capacity defines the default capacity of the array.
  66396. */
  66397. constructor(capacity: number);
  66398. /**
  66399. * Pushes a value at the end of the active data.
  66400. * @param value defines the object to push in the array.
  66401. */
  66402. push(value: T): void;
  66403. /**
  66404. * Iterates over the active data and apply the lambda to them.
  66405. * @param func defines the action to apply on each value.
  66406. */
  66407. forEach(func: (content: T) => void): void;
  66408. /**
  66409. * Sorts the full sets of data.
  66410. * @param compareFn defines the comparison function to apply.
  66411. */
  66412. sort(compareFn: (a: T, b: T) => number): void;
  66413. /**
  66414. * Resets the active data to an empty array.
  66415. */
  66416. reset(): void;
  66417. /**
  66418. * Releases all the data from the array as well as the array.
  66419. */
  66420. dispose(): void;
  66421. /**
  66422. * Concats the active data with a given array.
  66423. * @param array defines the data to concatenate with.
  66424. */
  66425. concat(array: any): void;
  66426. /**
  66427. * Returns the position of a value in the active data.
  66428. * @param value defines the value to find the index for
  66429. * @returns the index if found in the active data otherwise -1
  66430. */
  66431. indexOf(value: T): number;
  66432. /**
  66433. * Returns whether an element is part of the active data.
  66434. * @param value defines the value to look for
  66435. * @returns true if found in the active data otherwise false
  66436. */
  66437. contains(value: T): boolean;
  66438. private static _GlobalId;
  66439. }
  66440. /**
  66441. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66442. * The data in this array can only be present once
  66443. */
  66444. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66445. private _duplicateId;
  66446. /**
  66447. * Pushes a value at the end of the active data.
  66448. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66449. * @param value defines the object to push in the array.
  66450. */
  66451. push(value: T): void;
  66452. /**
  66453. * Pushes a value at the end of the active data.
  66454. * If the data is already present, it won t be added again
  66455. * @param value defines the object to push in the array.
  66456. * @returns true if added false if it was already present
  66457. */
  66458. pushNoDuplicate(value: T): boolean;
  66459. /**
  66460. * Resets the active data to an empty array.
  66461. */
  66462. reset(): void;
  66463. /**
  66464. * Concats the active data with a given array.
  66465. * This ensures no dupplicate will be present in the result.
  66466. * @param array defines the data to concatenate with.
  66467. */
  66468. concatWithNoDuplicate(array: any): void;
  66469. }
  66470. }
  66471. declare module BABYLON {
  66472. /**
  66473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66474. * separate meshes. This can be use to improve performances.
  66475. * @see http://doc.babylonjs.com/how_to/multi_materials
  66476. */
  66477. export class MultiMaterial extends Material {
  66478. private _subMaterials;
  66479. /**
  66480. * Gets or Sets the list of Materials used within the multi material.
  66481. * They need to be ordered according to the submeshes order in the associated mesh
  66482. */
  66483. subMaterials: Nullable<Material>[];
  66484. /**
  66485. * Function used to align with Node.getChildren()
  66486. * @returns the list of Materials used within the multi material
  66487. */
  66488. getChildren(): Nullable<Material>[];
  66489. /**
  66490. * Instantiates a new Multi Material
  66491. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66492. * separate meshes. This can be use to improve performances.
  66493. * @see http://doc.babylonjs.com/how_to/multi_materials
  66494. * @param name Define the name in the scene
  66495. * @param scene Define the scene the material belongs to
  66496. */
  66497. constructor(name: string, scene: Scene);
  66498. private _hookArray;
  66499. /**
  66500. * Get one of the submaterial by its index in the submaterials array
  66501. * @param index The index to look the sub material at
  66502. * @returns The Material if the index has been defined
  66503. */
  66504. getSubMaterial(index: number): Nullable<Material>;
  66505. /**
  66506. * Get the list of active textures for the whole sub materials list.
  66507. * @returns All the textures that will be used during the rendering
  66508. */
  66509. getActiveTextures(): BaseTexture[];
  66510. /**
  66511. * Gets the current class name of the material e.g. "MultiMaterial"
  66512. * Mainly use in serialization.
  66513. * @returns the class name
  66514. */
  66515. getClassName(): string;
  66516. /**
  66517. * Checks if the material is ready to render the requested sub mesh
  66518. * @param mesh Define the mesh the submesh belongs to
  66519. * @param subMesh Define the sub mesh to look readyness for
  66520. * @param useInstances Define whether or not the material is used with instances
  66521. * @returns true if ready, otherwise false
  66522. */
  66523. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66524. /**
  66525. * Clones the current material and its related sub materials
  66526. * @param name Define the name of the newly cloned material
  66527. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66528. * @returns the cloned material
  66529. */
  66530. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66531. /**
  66532. * Serializes the materials into a JSON representation.
  66533. * @returns the JSON representation
  66534. */
  66535. serialize(): any;
  66536. /**
  66537. * Dispose the material and release its associated resources
  66538. * @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)
  66539. * @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)
  66540. * @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)
  66541. */
  66542. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66543. /**
  66544. * Creates a MultiMaterial from parsed MultiMaterial data.
  66545. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66546. * @param scene defines the hosting scene
  66547. * @returns a new MultiMaterial
  66548. */
  66549. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66550. }
  66551. }
  66552. declare module BABYLON {
  66553. /**
  66554. * Class used to represent data loading progression
  66555. */
  66556. export class SceneLoaderFlags {
  66557. private static _ForceFullSceneLoadingForIncremental;
  66558. private static _ShowLoadingScreen;
  66559. private static _CleanBoneMatrixWeights;
  66560. private static _loggingLevel;
  66561. /**
  66562. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66563. */
  66564. static ForceFullSceneLoadingForIncremental: boolean;
  66565. /**
  66566. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66567. */
  66568. static ShowLoadingScreen: boolean;
  66569. /**
  66570. * Defines the current logging level (while loading the scene)
  66571. * @ignorenaming
  66572. */
  66573. static loggingLevel: number;
  66574. /**
  66575. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66576. */
  66577. static CleanBoneMatrixWeights: boolean;
  66578. }
  66579. }
  66580. declare module BABYLON {
  66581. /**
  66582. * 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.
  66583. * @see https://doc.babylonjs.com/how_to/transformnode
  66584. */
  66585. export class TransformNode extends Node {
  66586. /**
  66587. * Object will not rotate to face the camera
  66588. */
  66589. static BILLBOARDMODE_NONE: number;
  66590. /**
  66591. * Object will rotate to face the camera but only on the x axis
  66592. */
  66593. static BILLBOARDMODE_X: number;
  66594. /**
  66595. * Object will rotate to face the camera but only on the y axis
  66596. */
  66597. static BILLBOARDMODE_Y: number;
  66598. /**
  66599. * Object will rotate to face the camera but only on the z axis
  66600. */
  66601. static BILLBOARDMODE_Z: number;
  66602. /**
  66603. * Object will rotate to face the camera
  66604. */
  66605. static BILLBOARDMODE_ALL: number;
  66606. private _forward;
  66607. private _forwardInverted;
  66608. private _up;
  66609. private _right;
  66610. private _rightInverted;
  66611. private _position;
  66612. private _rotation;
  66613. private _rotationQuaternion;
  66614. protected _scaling: Vector3;
  66615. protected _isDirty: boolean;
  66616. private _transformToBoneReferal;
  66617. /**
  66618. * Set the billboard mode. Default is 0.
  66619. *
  66620. * | Value | Type | Description |
  66621. * | --- | --- | --- |
  66622. * | 0 | BILLBOARDMODE_NONE | |
  66623. * | 1 | BILLBOARDMODE_X | |
  66624. * | 2 | BILLBOARDMODE_Y | |
  66625. * | 4 | BILLBOARDMODE_Z | |
  66626. * | 7 | BILLBOARDMODE_ALL | |
  66627. *
  66628. */
  66629. billboardMode: number;
  66630. /**
  66631. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66632. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66633. */
  66634. preserveParentRotationForBillboard: boolean;
  66635. /**
  66636. * 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
  66637. */
  66638. scalingDeterminant: number;
  66639. /**
  66640. * Sets the distance of the object to max, often used by skybox
  66641. */
  66642. infiniteDistance: boolean;
  66643. /**
  66644. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66645. * By default the system will update normals to compensate
  66646. */
  66647. ignoreNonUniformScaling: boolean;
  66648. /** @hidden */
  66649. _poseMatrix: Matrix;
  66650. /** @hidden */
  66651. _localMatrix: Matrix;
  66652. private _absolutePosition;
  66653. private _pivotMatrix;
  66654. private _pivotMatrixInverse;
  66655. protected _postMultiplyPivotMatrix: boolean;
  66656. private _tempMatrix;
  66657. private _tempMatrix2;
  66658. protected _isWorldMatrixFrozen: boolean;
  66659. /** @hidden */
  66660. _indexInSceneTransformNodesArray: number;
  66661. /**
  66662. * An event triggered after the world matrix is updated
  66663. */
  66664. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66665. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66666. /**
  66667. * Gets a string identifying the name of the class
  66668. * @returns "TransformNode" string
  66669. */
  66670. getClassName(): string;
  66671. /**
  66672. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66673. */
  66674. position: Vector3;
  66675. /**
  66676. * 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)).
  66677. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66678. */
  66679. rotation: Vector3;
  66680. /**
  66681. * 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)).
  66682. */
  66683. scaling: Vector3;
  66684. /**
  66685. * 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).
  66686. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66687. */
  66688. rotationQuaternion: Nullable<Quaternion>;
  66689. /**
  66690. * The forward direction of that transform in world space.
  66691. */
  66692. readonly forward: Vector3;
  66693. /**
  66694. * The up direction of that transform in world space.
  66695. */
  66696. readonly up: Vector3;
  66697. /**
  66698. * The right direction of that transform in world space.
  66699. */
  66700. readonly right: Vector3;
  66701. /**
  66702. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66703. * @param matrix the matrix to copy the pose from
  66704. * @returns this TransformNode.
  66705. */
  66706. updatePoseMatrix(matrix: Matrix): TransformNode;
  66707. /**
  66708. * Returns the mesh Pose matrix.
  66709. * @returns the pose matrix
  66710. */
  66711. getPoseMatrix(): Matrix;
  66712. /** @hidden */
  66713. _isSynchronized(): boolean;
  66714. /** @hidden */
  66715. _initCache(): void;
  66716. /**
  66717. * Flag the transform node as dirty (Forcing it to update everything)
  66718. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66719. * @returns this transform node
  66720. */
  66721. markAsDirty(property: string): TransformNode;
  66722. /**
  66723. * Returns the current mesh absolute position.
  66724. * Returns a Vector3.
  66725. */
  66726. readonly absolutePosition: Vector3;
  66727. /**
  66728. * Sets a new matrix to apply before all other transformation
  66729. * @param matrix defines the transform matrix
  66730. * @returns the current TransformNode
  66731. */
  66732. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66733. /**
  66734. * Sets a new pivot matrix to the current node
  66735. * @param matrix defines the new pivot matrix to use
  66736. * @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
  66737. * @returns the current TransformNode
  66738. */
  66739. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66740. /**
  66741. * Returns the mesh pivot matrix.
  66742. * Default : Identity.
  66743. * @returns the matrix
  66744. */
  66745. getPivotMatrix(): Matrix;
  66746. /**
  66747. * Prevents the World matrix to be computed any longer.
  66748. * @returns the TransformNode.
  66749. */
  66750. freezeWorldMatrix(): TransformNode;
  66751. /**
  66752. * Allows back the World matrix computation.
  66753. * @returns the TransformNode.
  66754. */
  66755. unfreezeWorldMatrix(): this;
  66756. /**
  66757. * True if the World matrix has been frozen.
  66758. */
  66759. readonly isWorldMatrixFrozen: boolean;
  66760. /**
  66761. * Retuns the mesh absolute position in the World.
  66762. * @returns a Vector3.
  66763. */
  66764. getAbsolutePosition(): Vector3;
  66765. /**
  66766. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66767. * @param absolutePosition the absolute position to set
  66768. * @returns the TransformNode.
  66769. */
  66770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66771. /**
  66772. * Sets the mesh position in its local space.
  66773. * @param vector3 the position to set in localspace
  66774. * @returns the TransformNode.
  66775. */
  66776. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66777. /**
  66778. * Returns the mesh position in the local space from the current World matrix values.
  66779. * @returns a new Vector3.
  66780. */
  66781. getPositionExpressedInLocalSpace(): Vector3;
  66782. /**
  66783. * Translates the mesh along the passed Vector3 in its local space.
  66784. * @param vector3 the distance to translate in localspace
  66785. * @returns the TransformNode.
  66786. */
  66787. locallyTranslate(vector3: Vector3): TransformNode;
  66788. private static _lookAtVectorCache;
  66789. /**
  66790. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66791. * @param targetPoint the position (must be in same space as current mesh) to look at
  66792. * @param yawCor optional yaw (y-axis) correction in radians
  66793. * @param pitchCor optional pitch (x-axis) correction in radians
  66794. * @param rollCor optional roll (z-axis) correction in radians
  66795. * @param space the choosen space of the target
  66796. * @returns the TransformNode.
  66797. */
  66798. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66799. /**
  66800. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66801. * This Vector3 is expressed in the World space.
  66802. * @param localAxis axis to rotate
  66803. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66804. */
  66805. getDirection(localAxis: Vector3): Vector3;
  66806. /**
  66807. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66808. * localAxis is expressed in the mesh local space.
  66809. * result is computed in the Wordl space from the mesh World matrix.
  66810. * @param localAxis axis to rotate
  66811. * @param result the resulting transformnode
  66812. * @returns this TransformNode.
  66813. */
  66814. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66815. /**
  66816. * Sets this transform node rotation to the given local axis.
  66817. * @param localAxis the axis in local space
  66818. * @param yawCor optional yaw (y-axis) correction in radians
  66819. * @param pitchCor optional pitch (x-axis) correction in radians
  66820. * @param rollCor optional roll (z-axis) correction in radians
  66821. * @returns this TransformNode
  66822. */
  66823. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66824. /**
  66825. * Sets a new pivot point to the current node
  66826. * @param point defines the new pivot point to use
  66827. * @param space defines if the point is in world or local space (local by default)
  66828. * @returns the current TransformNode
  66829. */
  66830. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66831. /**
  66832. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66833. * @returns the pivot point
  66834. */
  66835. getPivotPoint(): Vector3;
  66836. /**
  66837. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66838. * @param result the vector3 to store the result
  66839. * @returns this TransformNode.
  66840. */
  66841. getPivotPointToRef(result: Vector3): TransformNode;
  66842. /**
  66843. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66844. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66845. */
  66846. getAbsolutePivotPoint(): Vector3;
  66847. /**
  66848. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66849. * @param result vector3 to store the result
  66850. * @returns this TransformNode.
  66851. */
  66852. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66853. /**
  66854. * Defines the passed node as the parent of the current node.
  66855. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66856. * @see https://doc.babylonjs.com/how_to/parenting
  66857. * @param node the node ot set as the parent
  66858. * @returns this TransformNode.
  66859. */
  66860. setParent(node: Nullable<Node>): TransformNode;
  66861. private _nonUniformScaling;
  66862. /**
  66863. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66864. */
  66865. readonly nonUniformScaling: boolean;
  66866. /** @hidden */
  66867. _updateNonUniformScalingState(value: boolean): boolean;
  66868. /**
  66869. * Attach the current TransformNode to another TransformNode associated with a bone
  66870. * @param bone Bone affecting the TransformNode
  66871. * @param affectedTransformNode TransformNode associated with the bone
  66872. * @returns this object
  66873. */
  66874. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66875. /**
  66876. * Detach the transform node if its associated with a bone
  66877. * @returns this object
  66878. */
  66879. detachFromBone(): TransformNode;
  66880. private static _rotationAxisCache;
  66881. /**
  66882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66883. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66885. * The passed axis is also normalized.
  66886. * @param axis the axis to rotate around
  66887. * @param amount the amount to rotate in radians
  66888. * @param space Space to rotate in (Default: local)
  66889. * @returns the TransformNode.
  66890. */
  66891. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66892. /**
  66893. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66894. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66895. * The passed axis is also normalized. .
  66896. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66897. * @param point the point to rotate around
  66898. * @param axis the axis to rotate around
  66899. * @param amount the amount to rotate in radians
  66900. * @returns the TransformNode
  66901. */
  66902. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66903. /**
  66904. * Translates the mesh along the axis vector for the passed distance in the given space.
  66905. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66906. * @param axis the axis to translate in
  66907. * @param distance the distance to translate
  66908. * @param space Space to rotate in (Default: local)
  66909. * @returns the TransformNode.
  66910. */
  66911. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66912. /**
  66913. * Adds a rotation step to the mesh current rotation.
  66914. * x, y, z are Euler angles expressed in radians.
  66915. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66916. * This means this rotation is made in the mesh local space only.
  66917. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66918. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66919. * ```javascript
  66920. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66921. * ```
  66922. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66923. * 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.
  66924. * @param x Rotation to add
  66925. * @param y Rotation to add
  66926. * @param z Rotation to add
  66927. * @returns the TransformNode.
  66928. */
  66929. addRotation(x: number, y: number, z: number): TransformNode;
  66930. /**
  66931. * Computes the world matrix of the node
  66932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66933. * @returns the world matrix
  66934. */
  66935. computeWorldMatrix(force?: boolean): Matrix;
  66936. protected _afterComputeWorldMatrix(): void;
  66937. /**
  66938. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66939. * @param func callback function to add
  66940. *
  66941. * @returns the TransformNode.
  66942. */
  66943. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66944. /**
  66945. * Removes a registered callback function.
  66946. * @param func callback function to remove
  66947. * @returns the TransformNode.
  66948. */
  66949. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66950. /**
  66951. * Gets the position of the current mesh in camera space
  66952. * @param camera defines the camera to use
  66953. * @returns a position
  66954. */
  66955. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66956. /**
  66957. * Returns the distance from the mesh to the active camera
  66958. * @param camera defines the camera to use
  66959. * @returns the distance
  66960. */
  66961. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66962. /**
  66963. * Clone the current transform node
  66964. * @param name Name of the new clone
  66965. * @param newParent New parent for the clone
  66966. * @param doNotCloneChildren Do not clone children hierarchy
  66967. * @returns the new transform node
  66968. */
  66969. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66970. /**
  66971. * Serializes the objects information.
  66972. * @param currentSerializationObject defines the object to serialize in
  66973. * @returns the serialized object
  66974. */
  66975. serialize(currentSerializationObject?: any): any;
  66976. /**
  66977. * Returns a new TransformNode object parsed from the source provided.
  66978. * @param parsedTransformNode is the source.
  66979. * @param scene the scne the object belongs to
  66980. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66981. * @returns a new TransformNode object parsed from the source provided.
  66982. */
  66983. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66984. /**
  66985. * Get all child-transformNodes of this node
  66986. * @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
  66987. * @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
  66988. * @returns an array of TransformNode
  66989. */
  66990. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66991. /**
  66992. * Releases resources associated with this transform node.
  66993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66995. */
  66996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66997. }
  66998. }
  66999. declare module BABYLON {
  67000. /**
  67001. * Class used to override all child animations of a given target
  67002. */
  67003. export class AnimationPropertiesOverride {
  67004. /**
  67005. * Gets or sets a value indicating if animation blending must be used
  67006. */
  67007. enableBlending: boolean;
  67008. /**
  67009. * Gets or sets the blending speed to use when enableBlending is true
  67010. */
  67011. blendingSpeed: number;
  67012. /**
  67013. * Gets or sets the default loop mode to use
  67014. */
  67015. loopMode: number;
  67016. }
  67017. }
  67018. declare module BABYLON {
  67019. /**
  67020. * Class used to store bone information
  67021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67022. */
  67023. export class Bone extends Node {
  67024. /**
  67025. * defines the bone name
  67026. */
  67027. name: string;
  67028. private static _tmpVecs;
  67029. private static _tmpQuat;
  67030. private static _tmpMats;
  67031. /**
  67032. * Gets the list of child bones
  67033. */
  67034. children: Bone[];
  67035. /** Gets the animations associated with this bone */
  67036. animations: Animation[];
  67037. /**
  67038. * Gets or sets bone length
  67039. */
  67040. length: number;
  67041. /**
  67042. * @hidden Internal only
  67043. * Set this value to map this bone to a different index in the transform matrices
  67044. * Set this value to -1 to exclude the bone from the transform matrices
  67045. */
  67046. _index: Nullable<number>;
  67047. private _skeleton;
  67048. private _localMatrix;
  67049. private _restPose;
  67050. private _baseMatrix;
  67051. private _absoluteTransform;
  67052. private _invertedAbsoluteTransform;
  67053. private _parent;
  67054. private _scalingDeterminant;
  67055. private _worldTransform;
  67056. private _localScaling;
  67057. private _localRotation;
  67058. private _localPosition;
  67059. private _needToDecompose;
  67060. private _needToCompose;
  67061. /** @hidden */
  67062. _linkedTransformNode: Nullable<TransformNode>;
  67063. /** @hidden */
  67064. /** @hidden */
  67065. _matrix: Matrix;
  67066. /**
  67067. * Create a new bone
  67068. * @param name defines the bone name
  67069. * @param skeleton defines the parent skeleton
  67070. * @param parentBone defines the parent (can be null if the bone is the root)
  67071. * @param localMatrix defines the local matrix
  67072. * @param restPose defines the rest pose matrix
  67073. * @param baseMatrix defines the base matrix
  67074. * @param index defines index of the bone in the hiearchy
  67075. */
  67076. constructor(
  67077. /**
  67078. * defines the bone name
  67079. */
  67080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67081. /**
  67082. * Gets the current object class name.
  67083. * @return the class name
  67084. */
  67085. getClassName(): string;
  67086. /**
  67087. * Gets the parent skeleton
  67088. * @returns a skeleton
  67089. */
  67090. getSkeleton(): Skeleton;
  67091. /**
  67092. * Gets parent bone
  67093. * @returns a bone or null if the bone is the root of the bone hierarchy
  67094. */
  67095. getParent(): Nullable<Bone>;
  67096. /**
  67097. * Returns an array containing the root bones
  67098. * @returns an array containing the root bones
  67099. */
  67100. getChildren(): Array<Bone>;
  67101. /**
  67102. * Sets the parent bone
  67103. * @param parent defines the parent (can be null if the bone is the root)
  67104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67105. */
  67106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67107. /**
  67108. * Gets the local matrix
  67109. * @returns a matrix
  67110. */
  67111. getLocalMatrix(): Matrix;
  67112. /**
  67113. * Gets the base matrix (initial matrix which remains unchanged)
  67114. * @returns a matrix
  67115. */
  67116. getBaseMatrix(): Matrix;
  67117. /**
  67118. * Gets the rest pose matrix
  67119. * @returns a matrix
  67120. */
  67121. getRestPose(): Matrix;
  67122. /**
  67123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67124. */
  67125. getWorldMatrix(): Matrix;
  67126. /**
  67127. * Sets the local matrix to rest pose matrix
  67128. */
  67129. returnToRest(): void;
  67130. /**
  67131. * Gets the inverse of the absolute transform matrix.
  67132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67133. * @returns a matrix
  67134. */
  67135. getInvertedAbsoluteTransform(): Matrix;
  67136. /**
  67137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67138. * @returns a matrix
  67139. */
  67140. getAbsoluteTransform(): Matrix;
  67141. /**
  67142. * Links with the given transform node.
  67143. * The local matrix of this bone is copied from the transform node every frame.
  67144. * @param transformNode defines the transform node to link to
  67145. */
  67146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67147. /** Gets or sets current position (in local space) */
  67148. position: Vector3;
  67149. /** Gets or sets current rotation (in local space) */
  67150. rotation: Vector3;
  67151. /** Gets or sets current rotation quaternion (in local space) */
  67152. rotationQuaternion: Quaternion;
  67153. /** Gets or sets current scaling (in local space) */
  67154. scaling: Vector3;
  67155. /**
  67156. * Gets the animation properties override
  67157. */
  67158. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67159. private _decompose;
  67160. private _compose;
  67161. /**
  67162. * Update the base and local matrices
  67163. * @param matrix defines the new base or local matrix
  67164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67165. * @param updateLocalMatrix defines if the local matrix should be updated
  67166. */
  67167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67168. /** @hidden */
  67169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67170. /**
  67171. * Flag the bone as dirty (Forcing it to update everything)
  67172. */
  67173. markAsDirty(): void;
  67174. private _markAsDirtyAndCompose;
  67175. private _markAsDirtyAndDecompose;
  67176. /**
  67177. * Translate the bone in local or world space
  67178. * @param vec The amount to translate the bone
  67179. * @param space The space that the translation is in
  67180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67181. */
  67182. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67183. /**
  67184. * Set the postion of the bone in local or world space
  67185. * @param position The position to set the bone
  67186. * @param space The space that the position is in
  67187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67188. */
  67189. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67190. /**
  67191. * Set the absolute position of the bone (world space)
  67192. * @param position The position to set the bone
  67193. * @param mesh The mesh that this bone is attached to
  67194. */
  67195. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67196. /**
  67197. * Scale the bone on the x, y and z axes (in local space)
  67198. * @param x The amount to scale the bone on the x axis
  67199. * @param y The amount to scale the bone on the y axis
  67200. * @param z The amount to scale the bone on the z axis
  67201. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67202. */
  67203. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67204. /**
  67205. * Set the bone scaling in local space
  67206. * @param scale defines the scaling vector
  67207. */
  67208. setScale(scale: Vector3): void;
  67209. /**
  67210. * Gets the current scaling in local space
  67211. * @returns the current scaling vector
  67212. */
  67213. getScale(): Vector3;
  67214. /**
  67215. * Gets the current scaling in local space and stores it in a target vector
  67216. * @param result defines the target vector
  67217. */
  67218. getScaleToRef(result: Vector3): void;
  67219. /**
  67220. * Set the yaw, pitch, and roll of the bone in local or world space
  67221. * @param yaw The rotation of the bone on the y axis
  67222. * @param pitch The rotation of the bone on the x axis
  67223. * @param roll The rotation of the bone on the z axis
  67224. * @param space The space that the axes of rotation are in
  67225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67226. */
  67227. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67228. /**
  67229. * Add a rotation to the bone on an axis in local or world space
  67230. * @param axis The axis to rotate the bone on
  67231. * @param amount The amount to rotate the bone
  67232. * @param space The space that the axis is in
  67233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67234. */
  67235. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67236. /**
  67237. * Set the rotation of the bone to a particular axis angle in local or world space
  67238. * @param axis The axis to rotate the bone on
  67239. * @param angle The angle that the bone should be rotated to
  67240. * @param space The space that the axis is in
  67241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67242. */
  67243. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67244. /**
  67245. * Set the euler rotation of the bone in local of world space
  67246. * @param rotation The euler rotation that the bone should be set to
  67247. * @param space The space that the rotation is in
  67248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67249. */
  67250. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67251. /**
  67252. * Set the quaternion rotation of the bone in local of world space
  67253. * @param quat The quaternion rotation that the bone should be set to
  67254. * @param space The space that the rotation is in
  67255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67256. */
  67257. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67258. /**
  67259. * Set the rotation matrix of the bone in local of world space
  67260. * @param rotMat The rotation matrix that the bone should be set to
  67261. * @param space The space that the rotation is in
  67262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67263. */
  67264. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67265. private _rotateWithMatrix;
  67266. private _getNegativeRotationToRef;
  67267. /**
  67268. * Get the position of the bone in local or world space
  67269. * @param space The space that the returned position is in
  67270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67271. * @returns The position of the bone
  67272. */
  67273. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67274. /**
  67275. * Copy the position of the bone to a vector3 in local or world space
  67276. * @param space The space that the returned position is in
  67277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67278. * @param result The vector3 to copy the position to
  67279. */
  67280. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67281. /**
  67282. * Get the absolute position of the bone (world space)
  67283. * @param mesh The mesh that this bone is attached to
  67284. * @returns The absolute position of the bone
  67285. */
  67286. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67287. /**
  67288. * Copy the absolute position of the bone (world space) to the result param
  67289. * @param mesh The mesh that this bone is attached to
  67290. * @param result The vector3 to copy the absolute position to
  67291. */
  67292. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67293. /**
  67294. * Compute the absolute transforms of this bone and its children
  67295. */
  67296. computeAbsoluteTransforms(): void;
  67297. /**
  67298. * Get the world direction from an axis that is in the local space of the bone
  67299. * @param localAxis The local direction that is used to compute the world direction
  67300. * @param mesh The mesh that this bone is attached to
  67301. * @returns The world direction
  67302. */
  67303. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67304. /**
  67305. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67306. * @param localAxis The local direction that is used to compute the world direction
  67307. * @param mesh The mesh that this bone is attached to
  67308. * @param result The vector3 that the world direction will be copied to
  67309. */
  67310. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67311. /**
  67312. * Get the euler rotation of the bone in local or world space
  67313. * @param space The space that the rotation should be in
  67314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67315. * @returns The euler rotation
  67316. */
  67317. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67318. /**
  67319. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67320. * @param space The space that the rotation should be in
  67321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67322. * @param result The vector3 that the rotation should be copied to
  67323. */
  67324. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67325. /**
  67326. * Get the quaternion rotation of the bone in either local or world space
  67327. * @param space The space that the rotation should be in
  67328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67329. * @returns The quaternion rotation
  67330. */
  67331. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67332. /**
  67333. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67334. * @param space The space that the rotation should be in
  67335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67336. * @param result The quaternion that the rotation should be copied to
  67337. */
  67338. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67339. /**
  67340. * Get the rotation matrix of the bone in local or world space
  67341. * @param space The space that the rotation should be in
  67342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67343. * @returns The rotation matrix
  67344. */
  67345. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67346. /**
  67347. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67348. * @param space The space that the rotation should be in
  67349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67350. * @param result The quaternion that the rotation should be copied to
  67351. */
  67352. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67353. /**
  67354. * Get the world position of a point that is in the local space of the bone
  67355. * @param position The local position
  67356. * @param mesh The mesh that this bone is attached to
  67357. * @returns The world position
  67358. */
  67359. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67360. /**
  67361. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67362. * @param position The local position
  67363. * @param mesh The mesh that this bone is attached to
  67364. * @param result The vector3 that the world position should be copied to
  67365. */
  67366. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67367. /**
  67368. * Get the local position of a point that is in world space
  67369. * @param position The world position
  67370. * @param mesh The mesh that this bone is attached to
  67371. * @returns The local position
  67372. */
  67373. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67374. /**
  67375. * Get the local position of a point that is in world space and copy it to the result param
  67376. * @param position The world position
  67377. * @param mesh The mesh that this bone is attached to
  67378. * @param result The vector3 that the local position should be copied to
  67379. */
  67380. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67381. }
  67382. }
  67383. declare module BABYLON {
  67384. /**
  67385. * Enum that determines the text-wrapping mode to use.
  67386. */
  67387. export enum InspectableType {
  67388. /**
  67389. * Checkbox for booleans
  67390. */
  67391. Checkbox = 0,
  67392. /**
  67393. * Sliders for numbers
  67394. */
  67395. Slider = 1,
  67396. /**
  67397. * Vector3
  67398. */
  67399. Vector3 = 2,
  67400. /**
  67401. * Quaternions
  67402. */
  67403. Quaternion = 3,
  67404. /**
  67405. * Color3
  67406. */
  67407. Color3 = 4
  67408. }
  67409. /**
  67410. * Interface used to define custom inspectable properties.
  67411. * This interface is used by the inspector to display custom property grids
  67412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67413. */
  67414. export interface IInspectable {
  67415. /**
  67416. * Gets the label to display
  67417. */
  67418. label: string;
  67419. /**
  67420. * Gets the name of the property to edit
  67421. */
  67422. propertyName: string;
  67423. /**
  67424. * Gets the type of the editor to use
  67425. */
  67426. type: InspectableType;
  67427. /**
  67428. * Gets the minimum value of the property when using in "slider" mode
  67429. */
  67430. min?: number;
  67431. /**
  67432. * Gets the maximum value of the property when using in "slider" mode
  67433. */
  67434. max?: number;
  67435. /**
  67436. * Gets the setp to use when using in "slider" mode
  67437. */
  67438. step?: number;
  67439. }
  67440. }
  67441. declare module BABYLON {
  67442. /**
  67443. * Class for creating a cube texture
  67444. */
  67445. export class CubeTexture extends BaseTexture {
  67446. private _delayedOnLoad;
  67447. /**
  67448. * The url of the texture
  67449. */
  67450. url: string;
  67451. /**
  67452. * Gets or sets the center of the bounding box associated with the cube texture.
  67453. * It must define where the camera used to render the texture was set
  67454. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67455. */
  67456. boundingBoxPosition: Vector3;
  67457. private _boundingBoxSize;
  67458. /**
  67459. * Gets or sets the size of the bounding box associated with the cube texture
  67460. * When defined, the cubemap will switch to local mode
  67461. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67462. * @example https://www.babylonjs-playground.com/#RNASML
  67463. */
  67464. /**
  67465. * Returns the bounding box size
  67466. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67467. */
  67468. boundingBoxSize: Vector3;
  67469. protected _rotationY: number;
  67470. /**
  67471. * Sets texture matrix rotation angle around Y axis in radians.
  67472. */
  67473. /**
  67474. * Gets texture matrix rotation angle around Y axis radians.
  67475. */
  67476. rotationY: number;
  67477. /**
  67478. * Are mip maps generated for this texture or not.
  67479. */
  67480. readonly noMipmap: boolean;
  67481. private _noMipmap;
  67482. private _files;
  67483. private _extensions;
  67484. private _textureMatrix;
  67485. private _format;
  67486. private _createPolynomials;
  67487. /** @hidden */
  67488. _prefiltered: boolean;
  67489. /**
  67490. * Creates a cube texture from an array of image urls
  67491. * @param files defines an array of image urls
  67492. * @param scene defines the hosting scene
  67493. * @param noMipmap specifies if mip maps are not used
  67494. * @returns a cube texture
  67495. */
  67496. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67497. /**
  67498. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67499. * @param url defines the url of the prefiltered texture
  67500. * @param scene defines the scene the texture is attached to
  67501. * @param forcedExtension defines the extension of the file if different from the url
  67502. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67503. * @return the prefiltered texture
  67504. */
  67505. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67506. /**
  67507. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67508. * as prefiltered data.
  67509. * @param rootUrl defines the url of the texture or the root name of the six images
  67510. * @param scene defines the scene the texture is attached to
  67511. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67512. * @param noMipmap defines if mipmaps should be created or not
  67513. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67514. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67515. * @param onError defines a callback triggered in case of error during load
  67516. * @param format defines the internal format to use for the texture once loaded
  67517. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67518. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67519. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67522. * @return the cube texture
  67523. */
  67524. 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);
  67525. /**
  67526. * Get the current class name of the texture useful for serialization or dynamic coding.
  67527. * @returns "CubeTexture"
  67528. */
  67529. getClassName(): string;
  67530. /**
  67531. * Update the url (and optional buffer) of this texture if url was null during construction.
  67532. * @param url the url of the texture
  67533. * @param forcedExtension defines the extension to use
  67534. * @param onLoad callback called when the texture is loaded (defaults to null)
  67535. */
  67536. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67537. /**
  67538. * Delays loading of the cube texture
  67539. * @param forcedExtension defines the extension to use
  67540. */
  67541. delayLoad(forcedExtension?: string): void;
  67542. /**
  67543. * Returns the reflection texture matrix
  67544. * @returns the reflection texture matrix
  67545. */
  67546. getReflectionTextureMatrix(): Matrix;
  67547. /**
  67548. * Sets the reflection texture matrix
  67549. * @param value Reflection texture matrix
  67550. */
  67551. setReflectionTextureMatrix(value: Matrix): void;
  67552. /**
  67553. * Parses text to create a cube texture
  67554. * @param parsedTexture define the serialized text to read from
  67555. * @param scene defines the hosting scene
  67556. * @param rootUrl defines the root url of the cube texture
  67557. * @returns a cube texture
  67558. */
  67559. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67560. /**
  67561. * Makes a clone, or deep copy, of the cube texture
  67562. * @returns a new cube texture
  67563. */
  67564. clone(): CubeTexture;
  67565. }
  67566. }
  67567. declare module BABYLON {
  67568. /** @hidden */
  67569. export var postprocessVertexShader: {
  67570. name: string;
  67571. shader: string;
  67572. };
  67573. }
  67574. declare module BABYLON {
  67575. /**
  67576. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67577. * This is the base of the follow, arc rotate cameras and Free camera
  67578. * @see http://doc.babylonjs.com/features/cameras
  67579. */
  67580. export class TargetCamera extends Camera {
  67581. private static _RigCamTransformMatrix;
  67582. private static _TargetTransformMatrix;
  67583. private static _TargetFocalPoint;
  67584. /**
  67585. * Define the current direction the camera is moving to
  67586. */
  67587. cameraDirection: Vector3;
  67588. /**
  67589. * Define the current rotation the camera is rotating to
  67590. */
  67591. cameraRotation: Vector2;
  67592. /**
  67593. * When set, the up vector of the camera will be updated by the rotation of the camera
  67594. */
  67595. updateUpVectorFromRotation: boolean;
  67596. private _tmpQuaternion;
  67597. /**
  67598. * Define the current rotation of the camera
  67599. */
  67600. rotation: Vector3;
  67601. /**
  67602. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67603. */
  67604. rotationQuaternion: Quaternion;
  67605. /**
  67606. * Define the current speed of the camera
  67607. */
  67608. speed: number;
  67609. /**
  67610. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67611. * around all axis.
  67612. */
  67613. noRotationConstraint: boolean;
  67614. /**
  67615. * Define the current target of the camera as an object or a position.
  67616. */
  67617. lockedTarget: any;
  67618. /** @hidden */
  67619. _currentTarget: Vector3;
  67620. /** @hidden */
  67621. _initialFocalDistance: number;
  67622. /** @hidden */
  67623. _viewMatrix: Matrix;
  67624. /** @hidden */
  67625. _camMatrix: Matrix;
  67626. /** @hidden */
  67627. _cameraTransformMatrix: Matrix;
  67628. /** @hidden */
  67629. _cameraRotationMatrix: Matrix;
  67630. /** @hidden */
  67631. _referencePoint: Vector3;
  67632. /** @hidden */
  67633. _transformedReferencePoint: Vector3;
  67634. protected _globalCurrentTarget: Vector3;
  67635. protected _globalCurrentUpVector: Vector3;
  67636. /** @hidden */
  67637. _reset: () => void;
  67638. private _defaultUp;
  67639. /**
  67640. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67641. * This is the base of the follow, arc rotate cameras and Free camera
  67642. * @see http://doc.babylonjs.com/features/cameras
  67643. * @param name Defines the name of the camera in the scene
  67644. * @param position Defines the start position of the camera in the scene
  67645. * @param scene Defines the scene the camera belongs to
  67646. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67647. */
  67648. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67649. /**
  67650. * Gets the position in front of the camera at a given distance.
  67651. * @param distance The distance from the camera we want the position to be
  67652. * @returns the position
  67653. */
  67654. getFrontPosition(distance: number): Vector3;
  67655. /** @hidden */
  67656. _getLockedTargetPosition(): Nullable<Vector3>;
  67657. private _storedPosition;
  67658. private _storedRotation;
  67659. private _storedRotationQuaternion;
  67660. /**
  67661. * Store current camera state of the camera (fov, position, rotation, etc..)
  67662. * @returns the camera
  67663. */
  67664. storeState(): Camera;
  67665. /**
  67666. * Restored camera state. You must call storeState() first
  67667. * @returns whether it was successful or not
  67668. * @hidden
  67669. */
  67670. _restoreStateValues(): boolean;
  67671. /** @hidden */
  67672. _initCache(): void;
  67673. /** @hidden */
  67674. _updateCache(ignoreParentClass?: boolean): void;
  67675. /** @hidden */
  67676. _isSynchronizedViewMatrix(): boolean;
  67677. /** @hidden */
  67678. _computeLocalCameraSpeed(): number;
  67679. /**
  67680. * Defines the target the camera should look at.
  67681. * This will automatically adapt alpha beta and radius to fit within the new target.
  67682. * @param target Defines the new target as a Vector or a mesh
  67683. */
  67684. setTarget(target: Vector3): void;
  67685. /**
  67686. * Return the current target position of the camera. This value is expressed in local space.
  67687. * @returns the target position
  67688. */
  67689. getTarget(): Vector3;
  67690. /** @hidden */
  67691. _decideIfNeedsToMove(): boolean;
  67692. /** @hidden */
  67693. _updatePosition(): void;
  67694. /** @hidden */
  67695. _checkInputs(): void;
  67696. protected _updateCameraRotationMatrix(): void;
  67697. /**
  67698. * 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)
  67699. * @returns the current camera
  67700. */
  67701. private _rotateUpVectorWithCameraRotationMatrix;
  67702. private _cachedRotationZ;
  67703. private _cachedQuaternionRotationZ;
  67704. /** @hidden */
  67705. _getViewMatrix(): Matrix;
  67706. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67707. /**
  67708. * @hidden
  67709. */
  67710. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67711. /**
  67712. * @hidden
  67713. */
  67714. _updateRigCameras(): void;
  67715. private _getRigCamPositionAndTarget;
  67716. /**
  67717. * Gets the current object class name.
  67718. * @return the class name
  67719. */
  67720. getClassName(): string;
  67721. }
  67722. }
  67723. declare module BABYLON {
  67724. /**
  67725. * @ignore
  67726. * This is a list of all the different input types that are available in the application.
  67727. * Fo instance: ArcRotateCameraGamepadInput...
  67728. */
  67729. export var CameraInputTypes: {};
  67730. /**
  67731. * This is the contract to implement in order to create a new input class.
  67732. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67733. */
  67734. export interface ICameraInput<TCamera extends Camera> {
  67735. /**
  67736. * Defines the camera the input is attached to.
  67737. */
  67738. camera: Nullable<TCamera>;
  67739. /**
  67740. * Gets the class name of the current intput.
  67741. * @returns the class name
  67742. */
  67743. getClassName(): string;
  67744. /**
  67745. * Get the friendly name associated with the input class.
  67746. * @returns the input friendly name
  67747. */
  67748. getSimpleName(): string;
  67749. /**
  67750. * Attach the input controls to a specific dom element to get the input from.
  67751. * @param element Defines the element the controls should be listened from
  67752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67753. */
  67754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67755. /**
  67756. * Detach the current controls from the specified dom element.
  67757. * @param element Defines the element to stop listening the inputs from
  67758. */
  67759. detachControl(element: Nullable<HTMLElement>): void;
  67760. /**
  67761. * Update the current camera state depending on the inputs that have been used this frame.
  67762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67763. */
  67764. checkInputs?: () => void;
  67765. }
  67766. /**
  67767. * Represents a map of input types to input instance or input index to input instance.
  67768. */
  67769. export interface CameraInputsMap<TCamera extends Camera> {
  67770. /**
  67771. * Accessor to the input by input type.
  67772. */
  67773. [name: string]: ICameraInput<TCamera>;
  67774. /**
  67775. * Accessor to the input by input index.
  67776. */
  67777. [idx: number]: ICameraInput<TCamera>;
  67778. }
  67779. /**
  67780. * This represents the input manager used within a camera.
  67781. * It helps dealing with all the different kind of input attached to a camera.
  67782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67783. */
  67784. export class CameraInputsManager<TCamera extends Camera> {
  67785. /**
  67786. * Defines the list of inputs attahed to the camera.
  67787. */
  67788. attached: CameraInputsMap<TCamera>;
  67789. /**
  67790. * Defines the dom element the camera is collecting inputs from.
  67791. * This is null if the controls have not been attached.
  67792. */
  67793. attachedElement: Nullable<HTMLElement>;
  67794. /**
  67795. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67796. */
  67797. noPreventDefault: boolean;
  67798. /**
  67799. * Defined the camera the input manager belongs to.
  67800. */
  67801. camera: TCamera;
  67802. /**
  67803. * Update the current camera state depending on the inputs that have been used this frame.
  67804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67805. */
  67806. checkInputs: () => void;
  67807. /**
  67808. * Instantiate a new Camera Input Manager.
  67809. * @param camera Defines the camera the input manager blongs to
  67810. */
  67811. constructor(camera: TCamera);
  67812. /**
  67813. * Add an input method to a camera
  67814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67815. * @param input camera input method
  67816. */
  67817. add(input: ICameraInput<TCamera>): void;
  67818. /**
  67819. * Remove a specific input method from a camera
  67820. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67821. * @param inputToRemove camera input method
  67822. */
  67823. remove(inputToRemove: ICameraInput<TCamera>): void;
  67824. /**
  67825. * Remove a specific input type from a camera
  67826. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67827. * @param inputType the type of the input to remove
  67828. */
  67829. removeByType(inputType: string): void;
  67830. private _addCheckInputs;
  67831. /**
  67832. * Attach the input controls to the currently attached dom element to listen the events from.
  67833. * @param input Defines the input to attach
  67834. */
  67835. attachInput(input: ICameraInput<TCamera>): void;
  67836. /**
  67837. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67838. * @param element Defines the dom element to collect the events from
  67839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67840. */
  67841. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67842. /**
  67843. * Detach the current manager inputs controls from a specific dom element.
  67844. * @param element Defines the dom element to collect the events from
  67845. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67846. */
  67847. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67848. /**
  67849. * Rebuild the dynamic inputCheck function from the current list of
  67850. * defined inputs in the manager.
  67851. */
  67852. rebuildInputCheck(): void;
  67853. /**
  67854. * Remove all attached input methods from a camera
  67855. */
  67856. clear(): void;
  67857. /**
  67858. * Serialize the current input manager attached to a camera.
  67859. * This ensures than once parsed,
  67860. * the input associated to the camera will be identical to the current ones
  67861. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67862. */
  67863. serialize(serializedCamera: any): void;
  67864. /**
  67865. * Parses an input manager serialized JSON to restore the previous list of inputs
  67866. * and states associated to a camera.
  67867. * @param parsedCamera Defines the JSON to parse
  67868. */
  67869. parse(parsedCamera: any): void;
  67870. }
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * Gather the list of keyboard event types as constants.
  67875. */
  67876. export class KeyboardEventTypes {
  67877. /**
  67878. * The keydown event is fired when a key becomes active (pressed).
  67879. */
  67880. static readonly KEYDOWN: number;
  67881. /**
  67882. * The keyup event is fired when a key has been released.
  67883. */
  67884. static readonly KEYUP: number;
  67885. }
  67886. /**
  67887. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67888. */
  67889. export class KeyboardInfo {
  67890. /**
  67891. * Defines the type of event (KeyboardEventTypes)
  67892. */
  67893. type: number;
  67894. /**
  67895. * Defines the related dom event
  67896. */
  67897. event: KeyboardEvent;
  67898. /**
  67899. * Instantiates a new keyboard info.
  67900. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67901. * @param type Defines the type of event (KeyboardEventTypes)
  67902. * @param event Defines the related dom event
  67903. */
  67904. constructor(
  67905. /**
  67906. * Defines the type of event (KeyboardEventTypes)
  67907. */
  67908. type: number,
  67909. /**
  67910. * Defines the related dom event
  67911. */
  67912. event: KeyboardEvent);
  67913. }
  67914. /**
  67915. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67916. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67917. */
  67918. export class KeyboardInfoPre extends KeyboardInfo {
  67919. /**
  67920. * Defines the type of event (KeyboardEventTypes)
  67921. */
  67922. type: number;
  67923. /**
  67924. * Defines the related dom event
  67925. */
  67926. event: KeyboardEvent;
  67927. /**
  67928. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67929. */
  67930. skipOnPointerObservable: boolean;
  67931. /**
  67932. * Instantiates a new keyboard pre info.
  67933. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67934. * @param type Defines the type of event (KeyboardEventTypes)
  67935. * @param event Defines the related dom event
  67936. */
  67937. constructor(
  67938. /**
  67939. * Defines the type of event (KeyboardEventTypes)
  67940. */
  67941. type: number,
  67942. /**
  67943. * Defines the related dom event
  67944. */
  67945. event: KeyboardEvent);
  67946. }
  67947. }
  67948. declare module BABYLON {
  67949. /**
  67950. * Manage the keyboard inputs to control the movement of a free camera.
  67951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67952. */
  67953. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67954. /**
  67955. * Defines the camera the input is attached to.
  67956. */
  67957. camera: FreeCamera;
  67958. /**
  67959. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67960. */
  67961. keysUp: number[];
  67962. /**
  67963. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67964. */
  67965. keysDown: number[];
  67966. /**
  67967. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67968. */
  67969. keysLeft: number[];
  67970. /**
  67971. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67972. */
  67973. keysRight: number[];
  67974. private _keys;
  67975. private _onCanvasBlurObserver;
  67976. private _onKeyboardObserver;
  67977. private _engine;
  67978. private _scene;
  67979. /**
  67980. * Attach the input controls to a specific dom element to get the input from.
  67981. * @param element Defines the element the controls should be listened from
  67982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67983. */
  67984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67985. /**
  67986. * Detach the current controls from the specified dom element.
  67987. * @param element Defines the element to stop listening the inputs from
  67988. */
  67989. detachControl(element: Nullable<HTMLElement>): void;
  67990. /**
  67991. * Update the current camera state depending on the inputs that have been used this frame.
  67992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67993. */
  67994. checkInputs(): void;
  67995. /**
  67996. * Gets the class name of the current intput.
  67997. * @returns the class name
  67998. */
  67999. getClassName(): string;
  68000. /** @hidden */
  68001. _onLostFocus(): void;
  68002. /**
  68003. * Get the friendly name associated with the input class.
  68004. * @returns the input friendly name
  68005. */
  68006. getSimpleName(): string;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /**
  68011. * Interface describing all the common properties and methods a shadow light needs to implement.
  68012. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68013. * as well as binding the different shadow properties to the effects.
  68014. */
  68015. export interface IShadowLight extends Light {
  68016. /**
  68017. * The light id in the scene (used in scene.findLighById for instance)
  68018. */
  68019. id: string;
  68020. /**
  68021. * The position the shdow will be casted from.
  68022. */
  68023. position: Vector3;
  68024. /**
  68025. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68026. */
  68027. direction: Vector3;
  68028. /**
  68029. * The transformed position. Position of the light in world space taking parenting in account.
  68030. */
  68031. transformedPosition: Vector3;
  68032. /**
  68033. * The transformed direction. Direction of the light in world space taking parenting in account.
  68034. */
  68035. transformedDirection: Vector3;
  68036. /**
  68037. * The friendly name of the light in the scene.
  68038. */
  68039. name: string;
  68040. /**
  68041. * Defines the shadow projection clipping minimum z value.
  68042. */
  68043. shadowMinZ: number;
  68044. /**
  68045. * Defines the shadow projection clipping maximum z value.
  68046. */
  68047. shadowMaxZ: number;
  68048. /**
  68049. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68050. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68051. */
  68052. computeTransformedInformation(): boolean;
  68053. /**
  68054. * Gets the scene the light belongs to.
  68055. * @returns The scene
  68056. */
  68057. getScene(): Scene;
  68058. /**
  68059. * Callback defining a custom Projection Matrix Builder.
  68060. * This can be used to override the default projection matrix computation.
  68061. */
  68062. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68063. /**
  68064. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68065. * @param matrix The materix to updated with the projection information
  68066. * @param viewMatrix The transform matrix of the light
  68067. * @param renderList The list of mesh to render in the map
  68068. * @returns The current light
  68069. */
  68070. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68071. /**
  68072. * Gets the current depth scale used in ESM.
  68073. * @returns The scale
  68074. */
  68075. getDepthScale(): number;
  68076. /**
  68077. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68078. * @returns true if a cube texture needs to be use
  68079. */
  68080. needCube(): boolean;
  68081. /**
  68082. * Detects if the projection matrix requires to be recomputed this frame.
  68083. * @returns true if it requires to be recomputed otherwise, false.
  68084. */
  68085. needProjectionMatrixCompute(): boolean;
  68086. /**
  68087. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68088. */
  68089. forceProjectionMatrixCompute(): void;
  68090. /**
  68091. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68094. */
  68095. getShadowDirection(faceIndex?: number): Vector3;
  68096. /**
  68097. * Gets the minZ used for shadow according to both the scene and the light.
  68098. * @param activeCamera The camera we are returning the min for
  68099. * @returns the depth min z
  68100. */
  68101. getDepthMinZ(activeCamera: Camera): number;
  68102. /**
  68103. * Gets the maxZ used for shadow according to both the scene and the light.
  68104. * @param activeCamera The camera we are returning the max for
  68105. * @returns the depth max z
  68106. */
  68107. getDepthMaxZ(activeCamera: Camera): number;
  68108. }
  68109. /**
  68110. * Base implementation IShadowLight
  68111. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68112. */
  68113. export abstract class ShadowLight extends Light implements IShadowLight {
  68114. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68115. protected _position: Vector3;
  68116. protected _setPosition(value: Vector3): void;
  68117. /**
  68118. * Sets the position the shadow will be casted from. Also use as the light position for both
  68119. * point and spot lights.
  68120. */
  68121. /**
  68122. * Sets the position the shadow will be casted from. Also use as the light position for both
  68123. * point and spot lights.
  68124. */
  68125. position: Vector3;
  68126. protected _direction: Vector3;
  68127. protected _setDirection(value: Vector3): void;
  68128. /**
  68129. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68130. * Also use as the light direction on spot and directional lights.
  68131. */
  68132. /**
  68133. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68134. * Also use as the light direction on spot and directional lights.
  68135. */
  68136. direction: Vector3;
  68137. private _shadowMinZ;
  68138. /**
  68139. * Gets the shadow projection clipping minimum z value.
  68140. */
  68141. /**
  68142. * Sets the shadow projection clipping minimum z value.
  68143. */
  68144. shadowMinZ: number;
  68145. private _shadowMaxZ;
  68146. /**
  68147. * Sets the shadow projection clipping maximum z value.
  68148. */
  68149. /**
  68150. * Gets the shadow projection clipping maximum z value.
  68151. */
  68152. shadowMaxZ: number;
  68153. /**
  68154. * Callback defining a custom Projection Matrix Builder.
  68155. * This can be used to override the default projection matrix computation.
  68156. */
  68157. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68158. /**
  68159. * The transformed position. Position of the light in world space taking parenting in account.
  68160. */
  68161. transformedPosition: Vector3;
  68162. /**
  68163. * The transformed direction. Direction of the light in world space taking parenting in account.
  68164. */
  68165. transformedDirection: Vector3;
  68166. private _needProjectionMatrixCompute;
  68167. /**
  68168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68170. */
  68171. computeTransformedInformation(): boolean;
  68172. /**
  68173. * Return the depth scale used for the shadow map.
  68174. * @returns the depth scale.
  68175. */
  68176. getDepthScale(): number;
  68177. /**
  68178. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68179. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68180. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68181. */
  68182. getShadowDirection(faceIndex?: number): Vector3;
  68183. /**
  68184. * Returns the ShadowLight absolute position in the World.
  68185. * @returns the position vector in world space
  68186. */
  68187. getAbsolutePosition(): Vector3;
  68188. /**
  68189. * Sets the ShadowLight direction toward the passed target.
  68190. * @param target The point to target in local space
  68191. * @returns the updated ShadowLight direction
  68192. */
  68193. setDirectionToTarget(target: Vector3): Vector3;
  68194. /**
  68195. * Returns the light rotation in euler definition.
  68196. * @returns the x y z rotation in local space.
  68197. */
  68198. getRotation(): Vector3;
  68199. /**
  68200. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68201. * @returns true if a cube texture needs to be use
  68202. */
  68203. needCube(): boolean;
  68204. /**
  68205. * Detects if the projection matrix requires to be recomputed this frame.
  68206. * @returns true if it requires to be recomputed otherwise, false.
  68207. */
  68208. needProjectionMatrixCompute(): boolean;
  68209. /**
  68210. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68211. */
  68212. forceProjectionMatrixCompute(): void;
  68213. /** @hidden */
  68214. _initCache(): void;
  68215. /** @hidden */
  68216. _isSynchronized(): boolean;
  68217. /**
  68218. * Computes the world matrix of the node
  68219. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68220. * @returns the world matrix
  68221. */
  68222. computeWorldMatrix(force?: boolean): Matrix;
  68223. /**
  68224. * Gets the minZ used for shadow according to both the scene and the light.
  68225. * @param activeCamera The camera we are returning the min for
  68226. * @returns the depth min z
  68227. */
  68228. getDepthMinZ(activeCamera: Camera): number;
  68229. /**
  68230. * Gets the maxZ used for shadow according to both the scene and the light.
  68231. * @param activeCamera The camera we are returning the max for
  68232. * @returns the depth max z
  68233. */
  68234. getDepthMaxZ(activeCamera: Camera): number;
  68235. /**
  68236. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68237. * @param matrix The materix to updated with the projection information
  68238. * @param viewMatrix The transform matrix of the light
  68239. * @param renderList The list of mesh to render in the map
  68240. * @returns The current light
  68241. */
  68242. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68243. }
  68244. }
  68245. declare module BABYLON {
  68246. /**
  68247. * "Static Class" containing the most commonly used helper while dealing with material for
  68248. * rendering purpose.
  68249. *
  68250. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68251. *
  68252. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68253. */
  68254. export class MaterialHelper {
  68255. /**
  68256. * Bind the current view position to an effect.
  68257. * @param effect The effect to be bound
  68258. * @param scene The scene the eyes position is used from
  68259. */
  68260. static BindEyePosition(effect: Effect, scene: Scene): void;
  68261. /**
  68262. * Helps preparing the defines values about the UVs in used in the effect.
  68263. * UVs are shared as much as we can accross channels in the shaders.
  68264. * @param texture The texture we are preparing the UVs for
  68265. * @param defines The defines to update
  68266. * @param key The channel key "diffuse", "specular"... used in the shader
  68267. */
  68268. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68269. /**
  68270. * Binds a texture matrix value to its corrsponding uniform
  68271. * @param texture The texture to bind the matrix for
  68272. * @param uniformBuffer The uniform buffer receivin the data
  68273. * @param key The channel key "diffuse", "specular"... used in the shader
  68274. */
  68275. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68276. /**
  68277. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68278. * @param mesh defines the current mesh
  68279. * @param scene defines the current scene
  68280. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68281. * @param pointsCloud defines if point cloud rendering has to be turned on
  68282. * @param fogEnabled defines if fog has to be turned on
  68283. * @param alphaTest defines if alpha testing has to be turned on
  68284. * @param defines defines the current list of defines
  68285. */
  68286. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68287. /**
  68288. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68289. * @param scene defines the current scene
  68290. * @param engine defines the current engine
  68291. * @param defines specifies the list of active defines
  68292. * @param useInstances defines if instances have to be turned on
  68293. * @param useClipPlane defines if clip plane have to be turned on
  68294. */
  68295. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68296. /**
  68297. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68298. * @param mesh The mesh containing the geometry data we will draw
  68299. * @param defines The defines to update
  68300. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68301. * @param useBones Precise whether bones should be used or not (override mesh info)
  68302. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68303. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68304. * @returns false if defines are considered not dirty and have not been checked
  68305. */
  68306. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68307. /**
  68308. * Prepares the defines related to multiview
  68309. * @param scene The scene we are intending to draw
  68310. * @param defines The defines to update
  68311. */
  68312. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68313. /**
  68314. * Prepares the defines related to the light information passed in parameter
  68315. * @param scene The scene we are intending to draw
  68316. * @param mesh The mesh the effect is compiling for
  68317. * @param defines The defines to update
  68318. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68319. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68320. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68321. * @returns true if normals will be required for the rest of the effect
  68322. */
  68323. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68324. /**
  68325. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68326. * that won t be acctive due to defines being turned off.
  68327. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68328. * @param samplersList The samplers list
  68329. * @param defines The defines helping in the list generation
  68330. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68331. */
  68332. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68333. /**
  68334. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68335. * @param defines The defines to update while falling back
  68336. * @param fallbacks The authorized effect fallbacks
  68337. * @param maxSimultaneousLights The maximum number of lights allowed
  68338. * @param rank the current rank of the Effect
  68339. * @returns The newly affected rank
  68340. */
  68341. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68342. /**
  68343. * Prepares the list of attributes required for morph targets according to the effect defines.
  68344. * @param attribs The current list of supported attribs
  68345. * @param mesh The mesh to prepare the morph targets attributes for
  68346. * @param defines The current Defines of the effect
  68347. */
  68348. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68349. /**
  68350. * Prepares the list of attributes required for bones according to the effect defines.
  68351. * @param attribs The current list of supported attribs
  68352. * @param mesh The mesh to prepare the bones attributes for
  68353. * @param defines The current Defines of the effect
  68354. * @param fallbacks The current efffect fallback strategy
  68355. */
  68356. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68357. /**
  68358. * Prepares the list of attributes required for instances according to the effect defines.
  68359. * @param attribs The current list of supported attribs
  68360. * @param defines The current Defines of the effect
  68361. */
  68362. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68363. /**
  68364. * Binds the light shadow information to the effect for the given mesh.
  68365. * @param light The light containing the generator
  68366. * @param scene The scene the lights belongs to
  68367. * @param mesh The mesh we are binding the information to render
  68368. * @param lightIndex The light index in the effect used to render the mesh
  68369. * @param effect The effect we are binding the data to
  68370. */
  68371. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68372. /**
  68373. * Binds the light information to the effect.
  68374. * @param light The light containing the generator
  68375. * @param effect The effect we are binding the data to
  68376. * @param lightIndex The light index in the effect used to render
  68377. */
  68378. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68379. /**
  68380. * Binds the lights information from the scene to the effect for the given mesh.
  68381. * @param scene The scene the lights belongs to
  68382. * @param mesh The mesh we are binding the information to render
  68383. * @param effect The effect we are binding the data to
  68384. * @param defines The generated defines for the effect
  68385. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68386. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68387. */
  68388. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68389. private static _tempFogColor;
  68390. /**
  68391. * Binds the fog information from the scene to the effect for the given mesh.
  68392. * @param scene The scene the lights belongs to
  68393. * @param mesh The mesh we are binding the information to render
  68394. * @param effect The effect we are binding the data to
  68395. * @param linearSpace Defines if the fog effect is applied in linear space
  68396. */
  68397. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68398. /**
  68399. * Binds the bones information from the mesh to the effect.
  68400. * @param mesh The mesh we are binding the information to render
  68401. * @param effect The effect we are binding the data to
  68402. */
  68403. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68404. /**
  68405. * Binds the morph targets information from the mesh to the effect.
  68406. * @param abstractMesh The mesh we are binding the information to render
  68407. * @param effect The effect we are binding the data to
  68408. */
  68409. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68410. /**
  68411. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68412. * @param defines The generated defines used in the effect
  68413. * @param effect The effect we are binding the data to
  68414. * @param scene The scene we are willing to render with logarithmic scale for
  68415. */
  68416. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68417. /**
  68418. * Binds the clip plane information from the scene to the effect.
  68419. * @param scene The scene the clip plane information are extracted from
  68420. * @param effect The effect we are binding the data to
  68421. */
  68422. static BindClipPlane(effect: Effect, scene: Scene): void;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /** @hidden */
  68427. export var kernelBlurVaryingDeclaration: {
  68428. name: string;
  68429. shader: string;
  68430. };
  68431. }
  68432. declare module BABYLON {
  68433. /** @hidden */
  68434. export var kernelBlurFragment: {
  68435. name: string;
  68436. shader: string;
  68437. };
  68438. }
  68439. declare module BABYLON {
  68440. /** @hidden */
  68441. export var kernelBlurFragment2: {
  68442. name: string;
  68443. shader: string;
  68444. };
  68445. }
  68446. declare module BABYLON {
  68447. /** @hidden */
  68448. export var kernelBlurPixelShader: {
  68449. name: string;
  68450. shader: string;
  68451. };
  68452. }
  68453. declare module BABYLON {
  68454. /** @hidden */
  68455. export var kernelBlurVertex: {
  68456. name: string;
  68457. shader: string;
  68458. };
  68459. }
  68460. declare module BABYLON {
  68461. /** @hidden */
  68462. export var kernelBlurVertexShader: {
  68463. name: string;
  68464. shader: string;
  68465. };
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * The Blur Post Process which blurs an image based on a kernel and direction.
  68470. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68471. */
  68472. export class BlurPostProcess extends PostProcess {
  68473. /** The direction in which to blur the image. */
  68474. direction: Vector2;
  68475. private blockCompilation;
  68476. protected _kernel: number;
  68477. protected _idealKernel: number;
  68478. protected _packedFloat: boolean;
  68479. private _staticDefines;
  68480. /**
  68481. * Sets the length in pixels of the blur sample region
  68482. */
  68483. /**
  68484. * Gets the length in pixels of the blur sample region
  68485. */
  68486. kernel: number;
  68487. /**
  68488. * Sets wether or not the blur needs to unpack/repack floats
  68489. */
  68490. /**
  68491. * Gets wether or not the blur is unpacking/repacking floats
  68492. */
  68493. packedFloat: boolean;
  68494. /**
  68495. * Creates a new instance BlurPostProcess
  68496. * @param name The name of the effect.
  68497. * @param direction The direction in which to blur the image.
  68498. * @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.
  68499. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68500. * @param camera The camera to apply the render pass to.
  68501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68502. * @param engine The engine which the post process will be applied. (default: current engine)
  68503. * @param reusable If the post process can be reused on the same frame. (default: false)
  68504. * @param textureType Type of textures used when performing the post process. (default: 0)
  68505. * @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)
  68506. */
  68507. constructor(name: string,
  68508. /** The direction in which to blur the image. */
  68509. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68510. /**
  68511. * Updates the effect with the current post process compile time values and recompiles the shader.
  68512. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68513. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68514. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68515. * @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
  68516. * @param onCompiled Called when the shader has been compiled.
  68517. * @param onError Called if there is an error when compiling a shader.
  68518. */
  68519. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68520. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68521. /**
  68522. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68523. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68524. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68525. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68526. * The gaps between physical kernels are compensated for in the weighting of the samples
  68527. * @param idealKernel Ideal blur kernel.
  68528. * @return Nearest best kernel.
  68529. */
  68530. protected _nearestBestKernel(idealKernel: number): number;
  68531. /**
  68532. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68533. * @param x The point on the Gaussian distribution to sample.
  68534. * @return the value of the Gaussian function at x.
  68535. */
  68536. protected _gaussianWeight(x: number): number;
  68537. /**
  68538. * Generates a string that can be used as a floating point number in GLSL.
  68539. * @param x Value to print.
  68540. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68541. * @return GLSL float string.
  68542. */
  68543. protected _glslFloat(x: number, decimalFigures?: number): string;
  68544. }
  68545. }
  68546. declare module BABYLON {
  68547. /** @hidden */
  68548. export var shadowMapPixelShader: {
  68549. name: string;
  68550. shader: string;
  68551. };
  68552. }
  68553. declare module BABYLON {
  68554. /** @hidden */
  68555. export var bonesDeclaration: {
  68556. name: string;
  68557. shader: string;
  68558. };
  68559. }
  68560. declare module BABYLON {
  68561. /** @hidden */
  68562. export var morphTargetsVertexGlobalDeclaration: {
  68563. name: string;
  68564. shader: string;
  68565. };
  68566. }
  68567. declare module BABYLON {
  68568. /** @hidden */
  68569. export var morphTargetsVertexDeclaration: {
  68570. name: string;
  68571. shader: string;
  68572. };
  68573. }
  68574. declare module BABYLON {
  68575. /** @hidden */
  68576. export var instancesDeclaration: {
  68577. name: string;
  68578. shader: string;
  68579. };
  68580. }
  68581. declare module BABYLON {
  68582. /** @hidden */
  68583. export var helperFunctions: {
  68584. name: string;
  68585. shader: string;
  68586. };
  68587. }
  68588. declare module BABYLON {
  68589. /** @hidden */
  68590. export var morphTargetsVertex: {
  68591. name: string;
  68592. shader: string;
  68593. };
  68594. }
  68595. declare module BABYLON {
  68596. /** @hidden */
  68597. export var instancesVertex: {
  68598. name: string;
  68599. shader: string;
  68600. };
  68601. }
  68602. declare module BABYLON {
  68603. /** @hidden */
  68604. export var bonesVertex: {
  68605. name: string;
  68606. shader: string;
  68607. };
  68608. }
  68609. declare module BABYLON {
  68610. /** @hidden */
  68611. export var shadowMapVertexShader: {
  68612. name: string;
  68613. shader: string;
  68614. };
  68615. }
  68616. declare module BABYLON {
  68617. /** @hidden */
  68618. export var depthBoxBlurPixelShader: {
  68619. name: string;
  68620. shader: string;
  68621. };
  68622. }
  68623. declare module BABYLON {
  68624. /**
  68625. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68626. */
  68627. export interface ICustomShaderOptions {
  68628. /**
  68629. * Gets or sets the custom shader name to use
  68630. */
  68631. shaderName: string;
  68632. /**
  68633. * The list of attribute names used in the shader
  68634. */
  68635. attributes?: string[];
  68636. /**
  68637. * The list of unifrom names used in the shader
  68638. */
  68639. uniforms?: string[];
  68640. /**
  68641. * The list of sampler names used in the shader
  68642. */
  68643. samplers?: string[];
  68644. /**
  68645. * The list of defines used in the shader
  68646. */
  68647. defines?: string[];
  68648. }
  68649. /**
  68650. * Interface to implement to create a shadow generator compatible with BJS.
  68651. */
  68652. export interface IShadowGenerator {
  68653. /**
  68654. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68655. * @returns The render target texture if present otherwise, null
  68656. */
  68657. getShadowMap(): Nullable<RenderTargetTexture>;
  68658. /**
  68659. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68660. * @returns The render target texture if the shadow map is present otherwise, null
  68661. */
  68662. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68663. /**
  68664. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68665. * @param subMesh The submesh we want to render in the shadow map
  68666. * @param useInstances Defines wether will draw in the map using instances
  68667. * @returns true if ready otherwise, false
  68668. */
  68669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68670. /**
  68671. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68672. * @param defines Defines of the material we want to update
  68673. * @param lightIndex Index of the light in the enabled light list of the material
  68674. */
  68675. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68676. /**
  68677. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68678. * defined in the generator but impacting the effect).
  68679. * It implies the unifroms available on the materials are the standard BJS ones.
  68680. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68681. * @param effect The effect we are binfing the information for
  68682. */
  68683. bindShadowLight(lightIndex: string, effect: Effect): void;
  68684. /**
  68685. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68686. * (eq to shadow prjection matrix * light transform matrix)
  68687. * @returns The transform matrix used to create the shadow map
  68688. */
  68689. getTransformMatrix(): Matrix;
  68690. /**
  68691. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68692. * Cube and 2D textures for instance.
  68693. */
  68694. recreateShadowMap(): void;
  68695. /**
  68696. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68697. * @param onCompiled Callback triggered at the and of the effects compilation
  68698. * @param options Sets of optional options forcing the compilation with different modes
  68699. */
  68700. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68701. useInstances: boolean;
  68702. }>): void;
  68703. /**
  68704. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68705. * @param options Sets of optional options forcing the compilation with different modes
  68706. * @returns A promise that resolves when the compilation completes
  68707. */
  68708. forceCompilationAsync(options?: Partial<{
  68709. useInstances: boolean;
  68710. }>): Promise<void>;
  68711. /**
  68712. * Serializes the shadow generator setup to a json object.
  68713. * @returns The serialized JSON object
  68714. */
  68715. serialize(): any;
  68716. /**
  68717. * Disposes the Shadow map and related Textures and effects.
  68718. */
  68719. dispose(): void;
  68720. }
  68721. /**
  68722. * Default implementation IShadowGenerator.
  68723. * This is the main object responsible of generating shadows in the framework.
  68724. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68725. */
  68726. export class ShadowGenerator implements IShadowGenerator {
  68727. /**
  68728. * Shadow generator mode None: no filtering applied.
  68729. */
  68730. static readonly FILTER_NONE: number;
  68731. /**
  68732. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68733. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68734. */
  68735. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68736. /**
  68737. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68738. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68739. */
  68740. static readonly FILTER_POISSONSAMPLING: number;
  68741. /**
  68742. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68743. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68744. */
  68745. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68746. /**
  68747. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68748. * edge artifacts on steep falloff.
  68749. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68750. */
  68751. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68752. /**
  68753. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68754. * edge artifacts on steep falloff.
  68755. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68756. */
  68757. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68758. /**
  68759. * Shadow generator mode PCF: Percentage Closer Filtering
  68760. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68761. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68762. */
  68763. static readonly FILTER_PCF: number;
  68764. /**
  68765. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68766. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68767. * Contact Hardening
  68768. */
  68769. static readonly FILTER_PCSS: number;
  68770. /**
  68771. * Reserved for PCF and PCSS
  68772. * Highest Quality.
  68773. *
  68774. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68775. *
  68776. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68777. */
  68778. static readonly QUALITY_HIGH: number;
  68779. /**
  68780. * Reserved for PCF and PCSS
  68781. * Good tradeoff for quality/perf cross devices
  68782. *
  68783. * Execute PCF on a 3*3 kernel.
  68784. *
  68785. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68786. */
  68787. static readonly QUALITY_MEDIUM: number;
  68788. /**
  68789. * Reserved for PCF and PCSS
  68790. * The lowest quality but the fastest.
  68791. *
  68792. * Execute PCF on a 1*1 kernel.
  68793. *
  68794. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68795. */
  68796. static readonly QUALITY_LOW: number;
  68797. /** Gets or sets the custom shader name to use */
  68798. customShaderOptions: ICustomShaderOptions;
  68799. /**
  68800. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68801. */
  68802. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68803. /**
  68804. * Observable triggered before a mesh is rendered in the shadow map.
  68805. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68806. */
  68807. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68808. private _bias;
  68809. /**
  68810. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68811. */
  68812. /**
  68813. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68814. */
  68815. bias: number;
  68816. private _normalBias;
  68817. /**
  68818. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68819. */
  68820. /**
  68821. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68822. */
  68823. normalBias: number;
  68824. private _blurBoxOffset;
  68825. /**
  68826. * Gets the blur box offset: offset applied during the blur pass.
  68827. * Only useful if useKernelBlur = false
  68828. */
  68829. /**
  68830. * Sets the blur box offset: offset applied during the blur pass.
  68831. * Only useful if useKernelBlur = false
  68832. */
  68833. blurBoxOffset: number;
  68834. private _blurScale;
  68835. /**
  68836. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68837. * 2 means half of the size.
  68838. */
  68839. /**
  68840. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68841. * 2 means half of the size.
  68842. */
  68843. blurScale: number;
  68844. private _blurKernel;
  68845. /**
  68846. * Gets the blur kernel: kernel size of the blur pass.
  68847. * Only useful if useKernelBlur = true
  68848. */
  68849. /**
  68850. * Sets the blur kernel: kernel size of the blur pass.
  68851. * Only useful if useKernelBlur = true
  68852. */
  68853. blurKernel: number;
  68854. private _useKernelBlur;
  68855. /**
  68856. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68857. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68858. */
  68859. /**
  68860. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68861. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68862. */
  68863. useKernelBlur: boolean;
  68864. private _depthScale;
  68865. /**
  68866. * Gets the depth scale used in ESM mode.
  68867. */
  68868. /**
  68869. * Sets the depth scale used in ESM mode.
  68870. * This can override the scale stored on the light.
  68871. */
  68872. depthScale: number;
  68873. private _filter;
  68874. /**
  68875. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68876. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68877. */
  68878. /**
  68879. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68880. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68881. */
  68882. filter: number;
  68883. /**
  68884. * Gets if the current filter is set to Poisson Sampling.
  68885. */
  68886. /**
  68887. * Sets the current filter to Poisson Sampling.
  68888. */
  68889. usePoissonSampling: boolean;
  68890. /**
  68891. * Gets if the current filter is set to ESM.
  68892. */
  68893. /**
  68894. * Sets the current filter is to ESM.
  68895. */
  68896. useExponentialShadowMap: boolean;
  68897. /**
  68898. * Gets if the current filter is set to filtered ESM.
  68899. */
  68900. /**
  68901. * Gets if the current filter is set to filtered ESM.
  68902. */
  68903. useBlurExponentialShadowMap: boolean;
  68904. /**
  68905. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68906. * exponential to prevent steep falloff artifacts).
  68907. */
  68908. /**
  68909. * Sets the current filter to "close ESM" (using the inverse of the
  68910. * exponential to prevent steep falloff artifacts).
  68911. */
  68912. useCloseExponentialShadowMap: boolean;
  68913. /**
  68914. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68915. * exponential to prevent steep falloff artifacts).
  68916. */
  68917. /**
  68918. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68919. * exponential to prevent steep falloff artifacts).
  68920. */
  68921. useBlurCloseExponentialShadowMap: boolean;
  68922. /**
  68923. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68924. */
  68925. /**
  68926. * Sets the current filter to "PCF" (percentage closer filtering).
  68927. */
  68928. usePercentageCloserFiltering: boolean;
  68929. private _filteringQuality;
  68930. /**
  68931. * Gets the PCF or PCSS Quality.
  68932. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68933. */
  68934. /**
  68935. * Sets the PCF or PCSS Quality.
  68936. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68937. */
  68938. filteringQuality: number;
  68939. /**
  68940. * Gets if the current filter is set to "PCSS" (contact hardening).
  68941. */
  68942. /**
  68943. * Sets the current filter to "PCSS" (contact hardening).
  68944. */
  68945. useContactHardeningShadow: boolean;
  68946. private _contactHardeningLightSizeUVRatio;
  68947. /**
  68948. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68949. * Using a ratio helps keeping shape stability independently of the map size.
  68950. *
  68951. * It does not account for the light projection as it was having too much
  68952. * instability during the light setup or during light position changes.
  68953. *
  68954. * Only valid if useContactHardeningShadow is true.
  68955. */
  68956. /**
  68957. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68958. * Using a ratio helps keeping shape stability independently of the map size.
  68959. *
  68960. * It does not account for the light projection as it was having too much
  68961. * instability during the light setup or during light position changes.
  68962. *
  68963. * Only valid if useContactHardeningShadow is true.
  68964. */
  68965. contactHardeningLightSizeUVRatio: number;
  68966. private _darkness;
  68967. /**
  68968. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68969. * 0 means strongest and 1 would means no shadow.
  68970. * @returns the darkness.
  68971. */
  68972. getDarkness(): number;
  68973. /**
  68974. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68975. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68976. * @returns the shadow generator allowing fluent coding.
  68977. */
  68978. setDarkness(darkness: number): ShadowGenerator;
  68979. private _transparencyShadow;
  68980. /**
  68981. * Sets the ability to have transparent shadow (boolean).
  68982. * @param transparent True if transparent else False
  68983. * @returns the shadow generator allowing fluent coding
  68984. */
  68985. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68986. private _shadowMap;
  68987. private _shadowMap2;
  68988. /**
  68989. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68990. * @returns The render target texture if present otherwise, null
  68991. */
  68992. getShadowMap(): Nullable<RenderTargetTexture>;
  68993. /**
  68994. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68995. * @returns The render target texture if the shadow map is present otherwise, null
  68996. */
  68997. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68998. /**
  68999. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69000. * @param mesh Mesh to add
  69001. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69002. * @returns the Shadow Generator itself
  69003. */
  69004. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69005. /**
  69006. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69007. * @param mesh Mesh to remove
  69008. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69009. * @returns the Shadow Generator itself
  69010. */
  69011. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69012. /**
  69013. * Controls the extent to which the shadows fade out at the edge of the frustum
  69014. * Used only by directionals and spots
  69015. */
  69016. frustumEdgeFalloff: number;
  69017. private _light;
  69018. /**
  69019. * Returns the associated light object.
  69020. * @returns the light generating the shadow
  69021. */
  69022. getLight(): IShadowLight;
  69023. /**
  69024. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69025. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69026. * It might on the other hand introduce peter panning.
  69027. */
  69028. forceBackFacesOnly: boolean;
  69029. private _scene;
  69030. private _lightDirection;
  69031. private _effect;
  69032. private _viewMatrix;
  69033. private _projectionMatrix;
  69034. private _transformMatrix;
  69035. private _cachedPosition;
  69036. private _cachedDirection;
  69037. private _cachedDefines;
  69038. private _currentRenderID;
  69039. private _boxBlurPostprocess;
  69040. private _kernelBlurXPostprocess;
  69041. private _kernelBlurYPostprocess;
  69042. private _blurPostProcesses;
  69043. private _mapSize;
  69044. private _currentFaceIndex;
  69045. private _currentFaceIndexCache;
  69046. private _textureType;
  69047. private _defaultTextureMatrix;
  69048. /** @hidden */
  69049. static _SceneComponentInitialization: (scene: Scene) => void;
  69050. /**
  69051. * Creates a ShadowGenerator object.
  69052. * A ShadowGenerator is the required tool to use the shadows.
  69053. * Each light casting shadows needs to use its own ShadowGenerator.
  69054. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69055. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69056. * @param light The light object generating the shadows.
  69057. * @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.
  69058. */
  69059. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69060. private _initializeGenerator;
  69061. private _initializeShadowMap;
  69062. private _initializeBlurRTTAndPostProcesses;
  69063. private _renderForShadowMap;
  69064. private _renderSubMeshForShadowMap;
  69065. private _applyFilterValues;
  69066. /**
  69067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69068. * @param onCompiled Callback triggered at the and of the effects compilation
  69069. * @param options Sets of optional options forcing the compilation with different modes
  69070. */
  69071. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69072. useInstances: boolean;
  69073. }>): void;
  69074. /**
  69075. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69076. * @param options Sets of optional options forcing the compilation with different modes
  69077. * @returns A promise that resolves when the compilation completes
  69078. */
  69079. forceCompilationAsync(options?: Partial<{
  69080. useInstances: boolean;
  69081. }>): Promise<void>;
  69082. /**
  69083. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69084. * @param subMesh The submesh we want to render in the shadow map
  69085. * @param useInstances Defines wether will draw in the map using instances
  69086. * @returns true if ready otherwise, false
  69087. */
  69088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69089. /**
  69090. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69091. * @param defines Defines of the material we want to update
  69092. * @param lightIndex Index of the light in the enabled light list of the material
  69093. */
  69094. prepareDefines(defines: any, lightIndex: number): void;
  69095. /**
  69096. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69097. * defined in the generator but impacting the effect).
  69098. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69099. * @param effect The effect we are binfing the information for
  69100. */
  69101. bindShadowLight(lightIndex: string, effect: Effect): void;
  69102. /**
  69103. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69104. * (eq to shadow prjection matrix * light transform matrix)
  69105. * @returns The transform matrix used to create the shadow map
  69106. */
  69107. getTransformMatrix(): Matrix;
  69108. /**
  69109. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69110. * Cube and 2D textures for instance.
  69111. */
  69112. recreateShadowMap(): void;
  69113. private _disposeBlurPostProcesses;
  69114. private _disposeRTTandPostProcesses;
  69115. /**
  69116. * Disposes the ShadowGenerator.
  69117. * Returns nothing.
  69118. */
  69119. dispose(): void;
  69120. /**
  69121. * Serializes the shadow generator setup to a json object.
  69122. * @returns The serialized JSON object
  69123. */
  69124. serialize(): any;
  69125. /**
  69126. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69127. * @param parsedShadowGenerator The JSON object to parse
  69128. * @param scene The scene to create the shadow map for
  69129. * @returns The parsed shadow generator
  69130. */
  69131. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69132. }
  69133. }
  69134. declare module BABYLON {
  69135. /**
  69136. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69137. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69138. * 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.
  69139. */
  69140. export abstract class Light extends Node {
  69141. /**
  69142. * Falloff Default: light is falling off following the material specification:
  69143. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69144. */
  69145. static readonly FALLOFF_DEFAULT: number;
  69146. /**
  69147. * Falloff Physical: light is falling off following the inverse squared distance law.
  69148. */
  69149. static readonly FALLOFF_PHYSICAL: number;
  69150. /**
  69151. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69152. * to enhance interoperability with other engines.
  69153. */
  69154. static readonly FALLOFF_GLTF: number;
  69155. /**
  69156. * Falloff Standard: light is falling off like in the standard material
  69157. * to enhance interoperability with other materials.
  69158. */
  69159. static readonly FALLOFF_STANDARD: number;
  69160. /**
  69161. * If every light affecting the material is in this lightmapMode,
  69162. * material.lightmapTexture adds or multiplies
  69163. * (depends on material.useLightmapAsShadowmap)
  69164. * after every other light calculations.
  69165. */
  69166. static readonly LIGHTMAP_DEFAULT: number;
  69167. /**
  69168. * material.lightmapTexture as only diffuse lighting from this light
  69169. * adds only specular lighting from this light
  69170. * adds dynamic shadows
  69171. */
  69172. static readonly LIGHTMAP_SPECULAR: number;
  69173. /**
  69174. * material.lightmapTexture as only lighting
  69175. * no light calculation from this light
  69176. * only adds dynamic shadows from this light
  69177. */
  69178. static readonly LIGHTMAP_SHADOWSONLY: number;
  69179. /**
  69180. * Each light type uses the default quantity according to its type:
  69181. * point/spot lights use luminous intensity
  69182. * directional lights use illuminance
  69183. */
  69184. static readonly INTENSITYMODE_AUTOMATIC: number;
  69185. /**
  69186. * lumen (lm)
  69187. */
  69188. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69189. /**
  69190. * candela (lm/sr)
  69191. */
  69192. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69193. /**
  69194. * lux (lm/m^2)
  69195. */
  69196. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69197. /**
  69198. * nit (cd/m^2)
  69199. */
  69200. static readonly INTENSITYMODE_LUMINANCE: number;
  69201. /**
  69202. * Light type const id of the point light.
  69203. */
  69204. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69205. /**
  69206. * Light type const id of the directional light.
  69207. */
  69208. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69209. /**
  69210. * Light type const id of the spot light.
  69211. */
  69212. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69213. /**
  69214. * Light type const id of the hemispheric light.
  69215. */
  69216. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69217. /**
  69218. * Diffuse gives the basic color to an object.
  69219. */
  69220. diffuse: Color3;
  69221. /**
  69222. * Specular produces a highlight color on an object.
  69223. * Note: This is note affecting PBR materials.
  69224. */
  69225. specular: Color3;
  69226. /**
  69227. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69228. * falling off base on range or angle.
  69229. * This can be set to any values in Light.FALLOFF_x.
  69230. *
  69231. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69232. * other types of materials.
  69233. */
  69234. falloffType: number;
  69235. /**
  69236. * Strength of the light.
  69237. * Note: By default it is define in the framework own unit.
  69238. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69239. */
  69240. intensity: number;
  69241. private _range;
  69242. protected _inverseSquaredRange: number;
  69243. /**
  69244. * Defines how far from the source the light is impacting in scene units.
  69245. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69246. */
  69247. /**
  69248. * Defines how far from the source the light is impacting in scene units.
  69249. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69250. */
  69251. range: number;
  69252. /**
  69253. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69254. * of light.
  69255. */
  69256. private _photometricScale;
  69257. private _intensityMode;
  69258. /**
  69259. * Gets the photometric scale used to interpret the intensity.
  69260. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69261. */
  69262. /**
  69263. * Sets the photometric scale used to interpret the intensity.
  69264. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69265. */
  69266. intensityMode: number;
  69267. private _radius;
  69268. /**
  69269. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69270. */
  69271. /**
  69272. * sets the light radius used by PBR Materials to simulate soft area lights.
  69273. */
  69274. radius: number;
  69275. private _renderPriority;
  69276. /**
  69277. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69278. * exceeding the number allowed of the materials.
  69279. */
  69280. renderPriority: number;
  69281. private _shadowEnabled;
  69282. /**
  69283. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69284. * the current shadow generator.
  69285. */
  69286. /**
  69287. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69288. * the current shadow generator.
  69289. */
  69290. shadowEnabled: boolean;
  69291. private _includedOnlyMeshes;
  69292. /**
  69293. * Gets the only meshes impacted by this light.
  69294. */
  69295. /**
  69296. * Sets the only meshes impacted by this light.
  69297. */
  69298. includedOnlyMeshes: AbstractMesh[];
  69299. private _excludedMeshes;
  69300. /**
  69301. * Gets the meshes not impacted by this light.
  69302. */
  69303. /**
  69304. * Sets the meshes not impacted by this light.
  69305. */
  69306. excludedMeshes: AbstractMesh[];
  69307. private _excludeWithLayerMask;
  69308. /**
  69309. * Gets the layer id use to find what meshes are not impacted by the light.
  69310. * Inactive if 0
  69311. */
  69312. /**
  69313. * Sets the layer id use to find what meshes are not impacted by the light.
  69314. * Inactive if 0
  69315. */
  69316. excludeWithLayerMask: number;
  69317. private _includeOnlyWithLayerMask;
  69318. /**
  69319. * Gets the layer id use to find what meshes are impacted by the light.
  69320. * Inactive if 0
  69321. */
  69322. /**
  69323. * Sets the layer id use to find what meshes are impacted by the light.
  69324. * Inactive if 0
  69325. */
  69326. includeOnlyWithLayerMask: number;
  69327. private _lightmapMode;
  69328. /**
  69329. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69330. */
  69331. /**
  69332. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69333. */
  69334. lightmapMode: number;
  69335. /**
  69336. * Shadow generator associted to the light.
  69337. * @hidden Internal use only.
  69338. */
  69339. _shadowGenerator: Nullable<IShadowGenerator>;
  69340. /**
  69341. * @hidden Internal use only.
  69342. */
  69343. _excludedMeshesIds: string[];
  69344. /**
  69345. * @hidden Internal use only.
  69346. */
  69347. _includedOnlyMeshesIds: string[];
  69348. /**
  69349. * The current light unifom buffer.
  69350. * @hidden Internal use only.
  69351. */
  69352. _uniformBuffer: UniformBuffer;
  69353. /**
  69354. * Creates a Light object in the scene.
  69355. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69356. * @param name The firendly name of the light
  69357. * @param scene The scene the light belongs too
  69358. */
  69359. constructor(name: string, scene: Scene);
  69360. protected abstract _buildUniformLayout(): void;
  69361. /**
  69362. * Sets the passed Effect "effect" with the Light information.
  69363. * @param effect The effect to update
  69364. * @param lightIndex The index of the light in the effect to update
  69365. * @returns The light
  69366. */
  69367. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69368. /**
  69369. * Returns the string "Light".
  69370. * @returns the class name
  69371. */
  69372. getClassName(): string;
  69373. /** @hidden */
  69374. readonly _isLight: boolean;
  69375. /**
  69376. * Converts the light information to a readable string for debug purpose.
  69377. * @param fullDetails Supports for multiple levels of logging within scene loading
  69378. * @returns the human readable light info
  69379. */
  69380. toString(fullDetails?: boolean): string;
  69381. /** @hidden */
  69382. protected _syncParentEnabledState(): void;
  69383. /**
  69384. * Set the enabled state of this node.
  69385. * @param value - the new enabled state
  69386. */
  69387. setEnabled(value: boolean): void;
  69388. /**
  69389. * Returns the Light associated shadow generator if any.
  69390. * @return the associated shadow generator.
  69391. */
  69392. getShadowGenerator(): Nullable<IShadowGenerator>;
  69393. /**
  69394. * Returns a Vector3, the absolute light position in the World.
  69395. * @returns the world space position of the light
  69396. */
  69397. getAbsolutePosition(): Vector3;
  69398. /**
  69399. * Specifies if the light will affect the passed mesh.
  69400. * @param mesh The mesh to test against the light
  69401. * @return true the mesh is affected otherwise, false.
  69402. */
  69403. canAffectMesh(mesh: AbstractMesh): boolean;
  69404. /**
  69405. * Sort function to order lights for rendering.
  69406. * @param a First Light object to compare to second.
  69407. * @param b Second Light object to compare first.
  69408. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69409. */
  69410. static CompareLightsPriority(a: Light, b: Light): number;
  69411. /**
  69412. * Releases resources associated with this node.
  69413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69415. */
  69416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69417. /**
  69418. * Returns the light type ID (integer).
  69419. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69420. */
  69421. getTypeID(): number;
  69422. /**
  69423. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69424. * @returns the scaled intensity in intensity mode unit
  69425. */
  69426. getScaledIntensity(): number;
  69427. /**
  69428. * Returns a new Light object, named "name", from the current one.
  69429. * @param name The name of the cloned light
  69430. * @returns the new created light
  69431. */
  69432. clone(name: string): Nullable<Light>;
  69433. /**
  69434. * Serializes the current light into a Serialization object.
  69435. * @returns the serialized object.
  69436. */
  69437. serialize(): any;
  69438. /**
  69439. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69440. * This new light is named "name" and added to the passed scene.
  69441. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69442. * @param name The friendly name of the light
  69443. * @param scene The scene the new light will belong to
  69444. * @returns the constructor function
  69445. */
  69446. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69447. /**
  69448. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69449. * @param parsedLight The JSON representation of the light
  69450. * @param scene The scene to create the parsed light in
  69451. * @returns the created light after parsing
  69452. */
  69453. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69454. private _hookArrayForExcluded;
  69455. private _hookArrayForIncludedOnly;
  69456. private _resyncMeshes;
  69457. /**
  69458. * Forces the meshes to update their light related information in their rendering used effects
  69459. * @hidden Internal Use Only
  69460. */
  69461. _markMeshesAsLightDirty(): void;
  69462. /**
  69463. * Recomputes the cached photometric scale if needed.
  69464. */
  69465. private _computePhotometricScale;
  69466. /**
  69467. * Returns the Photometric Scale according to the light type and intensity mode.
  69468. */
  69469. private _getPhotometricScale;
  69470. /**
  69471. * Reorder the light in the scene according to their defined priority.
  69472. * @hidden Internal Use Only
  69473. */
  69474. _reorderLightsInScene(): void;
  69475. /**
  69476. * Prepares the list of defines specific to the light type.
  69477. * @param defines the list of defines
  69478. * @param lightIndex defines the index of the light for the effect
  69479. */
  69480. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /**
  69485. * Interface used to define Action
  69486. */
  69487. export interface IAction {
  69488. /**
  69489. * Trigger for the action
  69490. */
  69491. trigger: number;
  69492. /** Options of the trigger */
  69493. triggerOptions: any;
  69494. /**
  69495. * Gets the trigger parameters
  69496. * @returns the trigger parameters
  69497. */
  69498. getTriggerParameter(): any;
  69499. /**
  69500. * Internal only - executes current action event
  69501. * @hidden
  69502. */
  69503. _executeCurrent(evt?: ActionEvent): void;
  69504. /**
  69505. * Serialize placeholder for child classes
  69506. * @param parent of child
  69507. * @returns the serialized object
  69508. */
  69509. serialize(parent: any): any;
  69510. /**
  69511. * Internal only
  69512. * @hidden
  69513. */
  69514. _prepare(): void;
  69515. /**
  69516. * Internal only - manager for action
  69517. * @hidden
  69518. */
  69519. _actionManager: AbstractActionManager;
  69520. }
  69521. /**
  69522. * The action to be carried out following a trigger
  69523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69524. */
  69525. export class Action implements IAction {
  69526. /** the trigger, with or without parameters, for the action */
  69527. triggerOptions: any;
  69528. /**
  69529. * Trigger for the action
  69530. */
  69531. trigger: number;
  69532. /**
  69533. * Internal only - manager for action
  69534. * @hidden
  69535. */
  69536. _actionManager: ActionManager;
  69537. private _nextActiveAction;
  69538. private _child;
  69539. private _condition?;
  69540. private _triggerParameter;
  69541. /**
  69542. * An event triggered prior to action being executed.
  69543. */
  69544. onBeforeExecuteObservable: Observable<Action>;
  69545. /**
  69546. * Creates a new Action
  69547. * @param triggerOptions the trigger, with or without parameters, for the action
  69548. * @param condition an optional determinant of action
  69549. */
  69550. constructor(
  69551. /** the trigger, with or without parameters, for the action */
  69552. triggerOptions: any, condition?: Condition);
  69553. /**
  69554. * Internal only
  69555. * @hidden
  69556. */
  69557. _prepare(): void;
  69558. /**
  69559. * Gets the trigger parameters
  69560. * @returns the trigger parameters
  69561. */
  69562. getTriggerParameter(): any;
  69563. /**
  69564. * Internal only - executes current action event
  69565. * @hidden
  69566. */
  69567. _executeCurrent(evt?: ActionEvent): void;
  69568. /**
  69569. * Execute placeholder for child classes
  69570. * @param evt optional action event
  69571. */
  69572. execute(evt?: ActionEvent): void;
  69573. /**
  69574. * Skips to next active action
  69575. */
  69576. skipToNextActiveAction(): void;
  69577. /**
  69578. * Adds action to chain of actions, may be a DoNothingAction
  69579. * @param action defines the next action to execute
  69580. * @returns The action passed in
  69581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69582. */
  69583. then(action: Action): Action;
  69584. /**
  69585. * Internal only
  69586. * @hidden
  69587. */
  69588. _getProperty(propertyPath: string): string;
  69589. /**
  69590. * Internal only
  69591. * @hidden
  69592. */
  69593. _getEffectiveTarget(target: any, propertyPath: string): any;
  69594. /**
  69595. * Serialize placeholder for child classes
  69596. * @param parent of child
  69597. * @returns the serialized object
  69598. */
  69599. serialize(parent: any): any;
  69600. /**
  69601. * Internal only called by serialize
  69602. * @hidden
  69603. */
  69604. protected _serialize(serializedAction: any, parent?: any): any;
  69605. /**
  69606. * Internal only
  69607. * @hidden
  69608. */
  69609. static _SerializeValueAsString: (value: any) => string;
  69610. /**
  69611. * Internal only
  69612. * @hidden
  69613. */
  69614. static _GetTargetProperty: (target: Scene | Node) => {
  69615. name: string;
  69616. targetType: string;
  69617. value: string;
  69618. };
  69619. }
  69620. }
  69621. declare module BABYLON {
  69622. /**
  69623. * A Condition applied to an Action
  69624. */
  69625. export class Condition {
  69626. /**
  69627. * Internal only - manager for action
  69628. * @hidden
  69629. */
  69630. _actionManager: ActionManager;
  69631. /**
  69632. * Internal only
  69633. * @hidden
  69634. */
  69635. _evaluationId: number;
  69636. /**
  69637. * Internal only
  69638. * @hidden
  69639. */
  69640. _currentResult: boolean;
  69641. /**
  69642. * Creates a new Condition
  69643. * @param actionManager the manager of the action the condition is applied to
  69644. */
  69645. constructor(actionManager: ActionManager);
  69646. /**
  69647. * Check if the current condition is valid
  69648. * @returns a boolean
  69649. */
  69650. isValid(): boolean;
  69651. /**
  69652. * Internal only
  69653. * @hidden
  69654. */
  69655. _getProperty(propertyPath: string): string;
  69656. /**
  69657. * Internal only
  69658. * @hidden
  69659. */
  69660. _getEffectiveTarget(target: any, propertyPath: string): any;
  69661. /**
  69662. * Serialize placeholder for child classes
  69663. * @returns the serialized object
  69664. */
  69665. serialize(): any;
  69666. /**
  69667. * Internal only
  69668. * @hidden
  69669. */
  69670. protected _serialize(serializedCondition: any): any;
  69671. }
  69672. /**
  69673. * Defines specific conditional operators as extensions of Condition
  69674. */
  69675. export class ValueCondition extends Condition {
  69676. /** path to specify the property of the target the conditional operator uses */
  69677. propertyPath: string;
  69678. /** the value compared by the conditional operator against the current value of the property */
  69679. value: any;
  69680. /** the conditional operator, default ValueCondition.IsEqual */
  69681. operator: number;
  69682. /**
  69683. * Internal only
  69684. * @hidden
  69685. */
  69686. private static _IsEqual;
  69687. /**
  69688. * Internal only
  69689. * @hidden
  69690. */
  69691. private static _IsDifferent;
  69692. /**
  69693. * Internal only
  69694. * @hidden
  69695. */
  69696. private static _IsGreater;
  69697. /**
  69698. * Internal only
  69699. * @hidden
  69700. */
  69701. private static _IsLesser;
  69702. /**
  69703. * returns the number for IsEqual
  69704. */
  69705. static readonly IsEqual: number;
  69706. /**
  69707. * Returns the number for IsDifferent
  69708. */
  69709. static readonly IsDifferent: number;
  69710. /**
  69711. * Returns the number for IsGreater
  69712. */
  69713. static readonly IsGreater: number;
  69714. /**
  69715. * Returns the number for IsLesser
  69716. */
  69717. static readonly IsLesser: number;
  69718. /**
  69719. * Internal only The action manager for the condition
  69720. * @hidden
  69721. */
  69722. _actionManager: ActionManager;
  69723. /**
  69724. * Internal only
  69725. * @hidden
  69726. */
  69727. private _target;
  69728. /**
  69729. * Internal only
  69730. * @hidden
  69731. */
  69732. private _effectiveTarget;
  69733. /**
  69734. * Internal only
  69735. * @hidden
  69736. */
  69737. private _property;
  69738. /**
  69739. * Creates a new ValueCondition
  69740. * @param actionManager manager for the action the condition applies to
  69741. * @param target for the action
  69742. * @param propertyPath path to specify the property of the target the conditional operator uses
  69743. * @param value the value compared by the conditional operator against the current value of the property
  69744. * @param operator the conditional operator, default ValueCondition.IsEqual
  69745. */
  69746. constructor(actionManager: ActionManager, target: any,
  69747. /** path to specify the property of the target the conditional operator uses */
  69748. propertyPath: string,
  69749. /** the value compared by the conditional operator against the current value of the property */
  69750. value: any,
  69751. /** the conditional operator, default ValueCondition.IsEqual */
  69752. operator?: number);
  69753. /**
  69754. * Compares the given value with the property value for the specified conditional operator
  69755. * @returns the result of the comparison
  69756. */
  69757. isValid(): boolean;
  69758. /**
  69759. * Serialize the ValueCondition into a JSON compatible object
  69760. * @returns serialization object
  69761. */
  69762. serialize(): any;
  69763. /**
  69764. * Gets the name of the conditional operator for the ValueCondition
  69765. * @param operator the conditional operator
  69766. * @returns the name
  69767. */
  69768. static GetOperatorName(operator: number): string;
  69769. }
  69770. /**
  69771. * Defines a predicate condition as an extension of Condition
  69772. */
  69773. export class PredicateCondition extends Condition {
  69774. /** defines the predicate function used to validate the condition */
  69775. predicate: () => boolean;
  69776. /**
  69777. * Internal only - manager for action
  69778. * @hidden
  69779. */
  69780. _actionManager: ActionManager;
  69781. /**
  69782. * Creates a new PredicateCondition
  69783. * @param actionManager manager for the action the condition applies to
  69784. * @param predicate defines the predicate function used to validate the condition
  69785. */
  69786. constructor(actionManager: ActionManager,
  69787. /** defines the predicate function used to validate the condition */
  69788. predicate: () => boolean);
  69789. /**
  69790. * @returns the validity of the predicate condition
  69791. */
  69792. isValid(): boolean;
  69793. }
  69794. /**
  69795. * Defines a state condition as an extension of Condition
  69796. */
  69797. export class StateCondition extends Condition {
  69798. /** Value to compare with target state */
  69799. value: string;
  69800. /**
  69801. * Internal only - manager for action
  69802. * @hidden
  69803. */
  69804. _actionManager: ActionManager;
  69805. /**
  69806. * Internal only
  69807. * @hidden
  69808. */
  69809. private _target;
  69810. /**
  69811. * Creates a new StateCondition
  69812. * @param actionManager manager for the action the condition applies to
  69813. * @param target of the condition
  69814. * @param value to compare with target state
  69815. */
  69816. constructor(actionManager: ActionManager, target: any,
  69817. /** Value to compare with target state */
  69818. value: string);
  69819. /**
  69820. * Gets a boolean indicating if the current condition is met
  69821. * @returns the validity of the state
  69822. */
  69823. isValid(): boolean;
  69824. /**
  69825. * Serialize the StateCondition into a JSON compatible object
  69826. * @returns serialization object
  69827. */
  69828. serialize(): any;
  69829. }
  69830. }
  69831. declare module BABYLON {
  69832. /**
  69833. * This defines an action responsible to toggle a boolean once triggered.
  69834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69835. */
  69836. export class SwitchBooleanAction extends Action {
  69837. /**
  69838. * The path to the boolean property in the target object
  69839. */
  69840. propertyPath: string;
  69841. private _target;
  69842. private _effectiveTarget;
  69843. private _property;
  69844. /**
  69845. * Instantiate the action
  69846. * @param triggerOptions defines the trigger options
  69847. * @param target defines the object containing the boolean
  69848. * @param propertyPath defines the path to the boolean property in the target object
  69849. * @param condition defines the trigger related conditions
  69850. */
  69851. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69852. /** @hidden */
  69853. _prepare(): void;
  69854. /**
  69855. * Execute the action toggle the boolean value.
  69856. */
  69857. execute(): void;
  69858. /**
  69859. * Serializes the actions and its related information.
  69860. * @param parent defines the object to serialize in
  69861. * @returns the serialized object
  69862. */
  69863. serialize(parent: any): any;
  69864. }
  69865. /**
  69866. * This defines an action responsible to set a the state field of the target
  69867. * to a desired value once triggered.
  69868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69869. */
  69870. export class SetStateAction extends Action {
  69871. /**
  69872. * The value to store in the state field.
  69873. */
  69874. value: string;
  69875. private _target;
  69876. /**
  69877. * Instantiate the action
  69878. * @param triggerOptions defines the trigger options
  69879. * @param target defines the object containing the state property
  69880. * @param value defines the value to store in the state field
  69881. * @param condition defines the trigger related conditions
  69882. */
  69883. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69884. /**
  69885. * Execute the action and store the value on the target state property.
  69886. */
  69887. execute(): void;
  69888. /**
  69889. * Serializes the actions and its related information.
  69890. * @param parent defines the object to serialize in
  69891. * @returns the serialized object
  69892. */
  69893. serialize(parent: any): any;
  69894. }
  69895. /**
  69896. * This defines an action responsible to set a property of the target
  69897. * to a desired value once triggered.
  69898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69899. */
  69900. export class SetValueAction extends Action {
  69901. /**
  69902. * The path of the property to set in the target.
  69903. */
  69904. propertyPath: string;
  69905. /**
  69906. * The value to set in the property
  69907. */
  69908. value: any;
  69909. private _target;
  69910. private _effectiveTarget;
  69911. private _property;
  69912. /**
  69913. * Instantiate the action
  69914. * @param triggerOptions defines the trigger options
  69915. * @param target defines the object containing the property
  69916. * @param propertyPath defines the path of the property to set in the target
  69917. * @param value defines the value to set in the property
  69918. * @param condition defines the trigger related conditions
  69919. */
  69920. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69921. /** @hidden */
  69922. _prepare(): void;
  69923. /**
  69924. * Execute the action and set the targetted property to the desired value.
  69925. */
  69926. execute(): void;
  69927. /**
  69928. * Serializes the actions and its related information.
  69929. * @param parent defines the object to serialize in
  69930. * @returns the serialized object
  69931. */
  69932. serialize(parent: any): any;
  69933. }
  69934. /**
  69935. * This defines an action responsible to increment the target value
  69936. * to a desired value once triggered.
  69937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69938. */
  69939. export class IncrementValueAction extends Action {
  69940. /**
  69941. * The path of the property to increment in the target.
  69942. */
  69943. propertyPath: string;
  69944. /**
  69945. * The value we should increment the property by.
  69946. */
  69947. value: any;
  69948. private _target;
  69949. private _effectiveTarget;
  69950. private _property;
  69951. /**
  69952. * Instantiate the action
  69953. * @param triggerOptions defines the trigger options
  69954. * @param target defines the object containing the property
  69955. * @param propertyPath defines the path of the property to increment in the target
  69956. * @param value defines the value value we should increment the property by
  69957. * @param condition defines the trigger related conditions
  69958. */
  69959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69960. /** @hidden */
  69961. _prepare(): void;
  69962. /**
  69963. * Execute the action and increment the target of the value amount.
  69964. */
  69965. execute(): void;
  69966. /**
  69967. * Serializes the actions and its related information.
  69968. * @param parent defines the object to serialize in
  69969. * @returns the serialized object
  69970. */
  69971. serialize(parent: any): any;
  69972. }
  69973. /**
  69974. * This defines an action responsible to start an animation once triggered.
  69975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69976. */
  69977. export class PlayAnimationAction extends Action {
  69978. /**
  69979. * Where the animation should start (animation frame)
  69980. */
  69981. from: number;
  69982. /**
  69983. * Where the animation should stop (animation frame)
  69984. */
  69985. to: number;
  69986. /**
  69987. * Define if the animation should loop or stop after the first play.
  69988. */
  69989. loop?: boolean;
  69990. private _target;
  69991. /**
  69992. * Instantiate the action
  69993. * @param triggerOptions defines the trigger options
  69994. * @param target defines the target animation or animation name
  69995. * @param from defines from where the animation should start (animation frame)
  69996. * @param end defines where the animation should stop (animation frame)
  69997. * @param loop defines if the animation should loop or stop after the first play
  69998. * @param condition defines the trigger related conditions
  69999. */
  70000. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70001. /** @hidden */
  70002. _prepare(): void;
  70003. /**
  70004. * Execute the action and play the animation.
  70005. */
  70006. execute(): void;
  70007. /**
  70008. * Serializes the actions and its related information.
  70009. * @param parent defines the object to serialize in
  70010. * @returns the serialized object
  70011. */
  70012. serialize(parent: any): any;
  70013. }
  70014. /**
  70015. * This defines an action responsible to stop an animation once triggered.
  70016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70017. */
  70018. export class StopAnimationAction extends Action {
  70019. private _target;
  70020. /**
  70021. * Instantiate the action
  70022. * @param triggerOptions defines the trigger options
  70023. * @param target defines the target animation or animation name
  70024. * @param condition defines the trigger related conditions
  70025. */
  70026. constructor(triggerOptions: any, target: any, condition?: Condition);
  70027. /** @hidden */
  70028. _prepare(): void;
  70029. /**
  70030. * Execute the action and stop the animation.
  70031. */
  70032. execute(): void;
  70033. /**
  70034. * Serializes the actions and its related information.
  70035. * @param parent defines the object to serialize in
  70036. * @returns the serialized object
  70037. */
  70038. serialize(parent: any): any;
  70039. }
  70040. /**
  70041. * This defines an action responsible that does nothing once triggered.
  70042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70043. */
  70044. export class DoNothingAction extends Action {
  70045. /**
  70046. * Instantiate the action
  70047. * @param triggerOptions defines the trigger options
  70048. * @param condition defines the trigger related conditions
  70049. */
  70050. constructor(triggerOptions?: any, condition?: Condition);
  70051. /**
  70052. * Execute the action and do nothing.
  70053. */
  70054. execute(): void;
  70055. /**
  70056. * Serializes the actions and its related information.
  70057. * @param parent defines the object to serialize in
  70058. * @returns the serialized object
  70059. */
  70060. serialize(parent: any): any;
  70061. }
  70062. /**
  70063. * This defines an action responsible to trigger several actions once triggered.
  70064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70065. */
  70066. export class CombineAction extends Action {
  70067. /**
  70068. * The list of aggregated animations to run.
  70069. */
  70070. children: Action[];
  70071. /**
  70072. * Instantiate the action
  70073. * @param triggerOptions defines the trigger options
  70074. * @param children defines the list of aggregated animations to run
  70075. * @param condition defines the trigger related conditions
  70076. */
  70077. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70078. /** @hidden */
  70079. _prepare(): void;
  70080. /**
  70081. * Execute the action and executes all the aggregated actions.
  70082. */
  70083. execute(evt: ActionEvent): void;
  70084. /**
  70085. * Serializes the actions and its related information.
  70086. * @param parent defines the object to serialize in
  70087. * @returns the serialized object
  70088. */
  70089. serialize(parent: any): any;
  70090. }
  70091. /**
  70092. * This defines an action responsible to run code (external event) once triggered.
  70093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70094. */
  70095. export class ExecuteCodeAction extends Action {
  70096. /**
  70097. * The callback function to run.
  70098. */
  70099. func: (evt: ActionEvent) => void;
  70100. /**
  70101. * Instantiate the action
  70102. * @param triggerOptions defines the trigger options
  70103. * @param func defines the callback function to run
  70104. * @param condition defines the trigger related conditions
  70105. */
  70106. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70107. /**
  70108. * Execute the action and run the attached code.
  70109. */
  70110. execute(evt: ActionEvent): void;
  70111. }
  70112. /**
  70113. * This defines an action responsible to set the parent property of the target once triggered.
  70114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70115. */
  70116. export class SetParentAction extends Action {
  70117. private _parent;
  70118. private _target;
  70119. /**
  70120. * Instantiate the action
  70121. * @param triggerOptions defines the trigger options
  70122. * @param target defines the target containing the parent property
  70123. * @param parent defines from where the animation should start (animation frame)
  70124. * @param condition defines the trigger related conditions
  70125. */
  70126. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70127. /** @hidden */
  70128. _prepare(): void;
  70129. /**
  70130. * Execute the action and set the parent property.
  70131. */
  70132. execute(): void;
  70133. /**
  70134. * Serializes the actions and its related information.
  70135. * @param parent defines the object to serialize in
  70136. * @returns the serialized object
  70137. */
  70138. serialize(parent: any): any;
  70139. }
  70140. }
  70141. declare module BABYLON {
  70142. /**
  70143. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70144. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70146. */
  70147. export class ActionManager extends AbstractActionManager {
  70148. /**
  70149. * Nothing
  70150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70151. */
  70152. static readonly NothingTrigger: number;
  70153. /**
  70154. * On pick
  70155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70156. */
  70157. static readonly OnPickTrigger: number;
  70158. /**
  70159. * On left pick
  70160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70161. */
  70162. static readonly OnLeftPickTrigger: number;
  70163. /**
  70164. * On right pick
  70165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70166. */
  70167. static readonly OnRightPickTrigger: number;
  70168. /**
  70169. * On center pick
  70170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70171. */
  70172. static readonly OnCenterPickTrigger: number;
  70173. /**
  70174. * On pick down
  70175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70176. */
  70177. static readonly OnPickDownTrigger: number;
  70178. /**
  70179. * On double pick
  70180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70181. */
  70182. static readonly OnDoublePickTrigger: number;
  70183. /**
  70184. * On pick up
  70185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70186. */
  70187. static readonly OnPickUpTrigger: number;
  70188. /**
  70189. * On pick out.
  70190. * This trigger will only be raised if you also declared a OnPickDown
  70191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70192. */
  70193. static readonly OnPickOutTrigger: number;
  70194. /**
  70195. * On long press
  70196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70197. */
  70198. static readonly OnLongPressTrigger: number;
  70199. /**
  70200. * On pointer over
  70201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70202. */
  70203. static readonly OnPointerOverTrigger: number;
  70204. /**
  70205. * On pointer out
  70206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70207. */
  70208. static readonly OnPointerOutTrigger: number;
  70209. /**
  70210. * On every frame
  70211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70212. */
  70213. static readonly OnEveryFrameTrigger: number;
  70214. /**
  70215. * On intersection enter
  70216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70217. */
  70218. static readonly OnIntersectionEnterTrigger: number;
  70219. /**
  70220. * On intersection exit
  70221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70222. */
  70223. static readonly OnIntersectionExitTrigger: number;
  70224. /**
  70225. * On key down
  70226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70227. */
  70228. static readonly OnKeyDownTrigger: number;
  70229. /**
  70230. * On key up
  70231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70232. */
  70233. static readonly OnKeyUpTrigger: number;
  70234. private _scene;
  70235. /**
  70236. * Creates a new action manager
  70237. * @param scene defines the hosting scene
  70238. */
  70239. constructor(scene: Scene);
  70240. /**
  70241. * Releases all associated resources
  70242. */
  70243. dispose(): void;
  70244. /**
  70245. * Gets hosting scene
  70246. * @returns the hosting scene
  70247. */
  70248. getScene(): Scene;
  70249. /**
  70250. * Does this action manager handles actions of any of the given triggers
  70251. * @param triggers defines the triggers to be tested
  70252. * @return a boolean indicating whether one (or more) of the triggers is handled
  70253. */
  70254. hasSpecificTriggers(triggers: number[]): boolean;
  70255. /**
  70256. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70257. * speed.
  70258. * @param triggerA defines the trigger to be tested
  70259. * @param triggerB defines the trigger to be tested
  70260. * @return a boolean indicating whether one (or more) of the triggers is handled
  70261. */
  70262. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70263. /**
  70264. * Does this action manager handles actions of a given trigger
  70265. * @param trigger defines the trigger to be tested
  70266. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70267. * @return whether the trigger is handled
  70268. */
  70269. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70270. /**
  70271. * Does this action manager has pointer triggers
  70272. */
  70273. readonly hasPointerTriggers: boolean;
  70274. /**
  70275. * Does this action manager has pick triggers
  70276. */
  70277. readonly hasPickTriggers: boolean;
  70278. /**
  70279. * Registers an action to this action manager
  70280. * @param action defines the action to be registered
  70281. * @return the action amended (prepared) after registration
  70282. */
  70283. registerAction(action: IAction): Nullable<IAction>;
  70284. /**
  70285. * Unregisters an action to this action manager
  70286. * @param action defines the action to be unregistered
  70287. * @return a boolean indicating whether the action has been unregistered
  70288. */
  70289. unregisterAction(action: IAction): Boolean;
  70290. /**
  70291. * Process a specific trigger
  70292. * @param trigger defines the trigger to process
  70293. * @param evt defines the event details to be processed
  70294. */
  70295. processTrigger(trigger: number, evt?: IActionEvent): void;
  70296. /** @hidden */
  70297. _getEffectiveTarget(target: any, propertyPath: string): any;
  70298. /** @hidden */
  70299. _getProperty(propertyPath: string): string;
  70300. /**
  70301. * Serialize this manager to a JSON object
  70302. * @param name defines the property name to store this manager
  70303. * @returns a JSON representation of this manager
  70304. */
  70305. serialize(name: string): any;
  70306. /**
  70307. * Creates a new ActionManager from a JSON data
  70308. * @param parsedActions defines the JSON data to read from
  70309. * @param object defines the hosting mesh
  70310. * @param scene defines the hosting scene
  70311. */
  70312. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70313. /**
  70314. * Get a trigger name by index
  70315. * @param trigger defines the trigger index
  70316. * @returns a trigger name
  70317. */
  70318. static GetTriggerName(trigger: number): string;
  70319. }
  70320. }
  70321. declare module BABYLON {
  70322. /**
  70323. * Class representing a ray with position and direction
  70324. */
  70325. export class Ray {
  70326. /** origin point */
  70327. origin: Vector3;
  70328. /** direction */
  70329. direction: Vector3;
  70330. /** length of the ray */
  70331. length: number;
  70332. private static readonly TmpVector3;
  70333. private _tmpRay;
  70334. /**
  70335. * Creates a new ray
  70336. * @param origin origin point
  70337. * @param direction direction
  70338. * @param length length of the ray
  70339. */
  70340. constructor(
  70341. /** origin point */
  70342. origin: Vector3,
  70343. /** direction */
  70344. direction: Vector3,
  70345. /** length of the ray */
  70346. length?: number);
  70347. /**
  70348. * Checks if the ray intersects a box
  70349. * @param minimum bound of the box
  70350. * @param maximum bound of the box
  70351. * @param intersectionTreshold extra extend to be added to the box in all direction
  70352. * @returns if the box was hit
  70353. */
  70354. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70355. /**
  70356. * Checks if the ray intersects a box
  70357. * @param box the bounding box to check
  70358. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70359. * @returns if the box was hit
  70360. */
  70361. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70362. /**
  70363. * If the ray hits a sphere
  70364. * @param sphere the bounding sphere to check
  70365. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70366. * @returns true if it hits the sphere
  70367. */
  70368. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70369. /**
  70370. * If the ray hits a triange
  70371. * @param vertex0 triangle vertex
  70372. * @param vertex1 triangle vertex
  70373. * @param vertex2 triangle vertex
  70374. * @returns intersection information if hit
  70375. */
  70376. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70377. /**
  70378. * Checks if ray intersects a plane
  70379. * @param plane the plane to check
  70380. * @returns the distance away it was hit
  70381. */
  70382. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70383. /**
  70384. * Checks if ray intersects a mesh
  70385. * @param mesh the mesh to check
  70386. * @param fastCheck if only the bounding box should checked
  70387. * @returns picking info of the intersecton
  70388. */
  70389. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70390. /**
  70391. * Checks if ray intersects a mesh
  70392. * @param meshes the meshes to check
  70393. * @param fastCheck if only the bounding box should checked
  70394. * @param results array to store result in
  70395. * @returns Array of picking infos
  70396. */
  70397. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70398. private _comparePickingInfo;
  70399. private static smallnum;
  70400. private static rayl;
  70401. /**
  70402. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70403. * @param sega the first point of the segment to test the intersection against
  70404. * @param segb the second point of the segment to test the intersection against
  70405. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70406. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70407. */
  70408. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70409. /**
  70410. * Update the ray from viewport position
  70411. * @param x position
  70412. * @param y y position
  70413. * @param viewportWidth viewport width
  70414. * @param viewportHeight viewport height
  70415. * @param world world matrix
  70416. * @param view view matrix
  70417. * @param projection projection matrix
  70418. * @returns this ray updated
  70419. */
  70420. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70421. /**
  70422. * Creates a ray with origin and direction of 0,0,0
  70423. * @returns the new ray
  70424. */
  70425. static Zero(): Ray;
  70426. /**
  70427. * Creates a new ray from screen space and viewport
  70428. * @param x position
  70429. * @param y y position
  70430. * @param viewportWidth viewport width
  70431. * @param viewportHeight viewport height
  70432. * @param world world matrix
  70433. * @param view view matrix
  70434. * @param projection projection matrix
  70435. * @returns new ray
  70436. */
  70437. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70438. /**
  70439. * 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
  70440. * transformed to the given world matrix.
  70441. * @param origin The origin point
  70442. * @param end The end point
  70443. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70444. * @returns the new ray
  70445. */
  70446. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70447. /**
  70448. * Transforms a ray by a matrix
  70449. * @param ray ray to transform
  70450. * @param matrix matrix to apply
  70451. * @returns the resulting new ray
  70452. */
  70453. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70454. /**
  70455. * Transforms a ray by a matrix
  70456. * @param ray ray to transform
  70457. * @param matrix matrix to apply
  70458. * @param result ray to store result in
  70459. */
  70460. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70461. /**
  70462. * Unproject a ray from screen space to object space
  70463. * @param sourceX defines the screen space x coordinate to use
  70464. * @param sourceY defines the screen space y coordinate to use
  70465. * @param viewportWidth defines the current width of the viewport
  70466. * @param viewportHeight defines the current height of the viewport
  70467. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70468. * @param view defines the view matrix to use
  70469. * @param projection defines the projection matrix to use
  70470. */
  70471. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70472. }
  70473. /**
  70474. * Type used to define predicate used to select faces when a mesh intersection is detected
  70475. */
  70476. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70477. interface Scene {
  70478. /** @hidden */
  70479. _tempPickingRay: Nullable<Ray>;
  70480. /** @hidden */
  70481. _cachedRayForTransform: Ray;
  70482. /** @hidden */
  70483. _pickWithRayInverseMatrix: Matrix;
  70484. /** @hidden */
  70485. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70486. /** @hidden */
  70487. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70488. }
  70489. }
  70490. declare module BABYLON {
  70491. /**
  70492. * Groups all the scene component constants in one place to ease maintenance.
  70493. * @hidden
  70494. */
  70495. export class SceneComponentConstants {
  70496. static readonly NAME_EFFECTLAYER: string;
  70497. static readonly NAME_LAYER: string;
  70498. static readonly NAME_LENSFLARESYSTEM: string;
  70499. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70500. static readonly NAME_PARTICLESYSTEM: string;
  70501. static readonly NAME_GAMEPAD: string;
  70502. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70503. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70504. static readonly NAME_DEPTHRENDERER: string;
  70505. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70506. static readonly NAME_SPRITE: string;
  70507. static readonly NAME_OUTLINERENDERER: string;
  70508. static readonly NAME_PROCEDURALTEXTURE: string;
  70509. static readonly NAME_SHADOWGENERATOR: string;
  70510. static readonly NAME_OCTREE: string;
  70511. static readonly NAME_PHYSICSENGINE: string;
  70512. static readonly NAME_AUDIO: string;
  70513. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70514. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70515. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70516. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70517. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70518. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70519. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70520. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70521. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70522. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70523. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70524. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70525. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70526. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70527. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70528. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70529. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70530. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70531. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70532. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70533. static readonly STEP_AFTERRENDER_AUDIO: number;
  70534. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70535. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70536. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70537. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70538. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70539. static readonly STEP_POINTERMOVE_SPRITE: number;
  70540. static readonly STEP_POINTERDOWN_SPRITE: number;
  70541. static readonly STEP_POINTERUP_SPRITE: number;
  70542. }
  70543. /**
  70544. * This represents a scene component.
  70545. *
  70546. * This is used to decouple the dependency the scene is having on the different workloads like
  70547. * layers, post processes...
  70548. */
  70549. export interface ISceneComponent {
  70550. /**
  70551. * The name of the component. Each component must have a unique name.
  70552. */
  70553. name: string;
  70554. /**
  70555. * The scene the component belongs to.
  70556. */
  70557. scene: Scene;
  70558. /**
  70559. * Register the component to one instance of a scene.
  70560. */
  70561. register(): void;
  70562. /**
  70563. * Rebuilds the elements related to this component in case of
  70564. * context lost for instance.
  70565. */
  70566. rebuild(): void;
  70567. /**
  70568. * Disposes the component and the associated ressources.
  70569. */
  70570. dispose(): void;
  70571. }
  70572. /**
  70573. * This represents a SERIALIZABLE scene component.
  70574. *
  70575. * This extends Scene Component to add Serialization methods on top.
  70576. */
  70577. export interface ISceneSerializableComponent extends ISceneComponent {
  70578. /**
  70579. * Adds all the element from the container to the scene
  70580. * @param container the container holding the elements
  70581. */
  70582. addFromContainer(container: AbstractScene): void;
  70583. /**
  70584. * Removes all the elements in the container from the scene
  70585. * @param container contains the elements to remove
  70586. * @param dispose if the removed element should be disposed (default: false)
  70587. */
  70588. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70589. /**
  70590. * Serializes the component data to the specified json object
  70591. * @param serializationObject The object to serialize to
  70592. */
  70593. serialize(serializationObject: any): void;
  70594. }
  70595. /**
  70596. * Strong typing of a Mesh related stage step action
  70597. */
  70598. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70599. /**
  70600. * Strong typing of a Evaluate Sub Mesh related stage step action
  70601. */
  70602. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70603. /**
  70604. * Strong typing of a Active Mesh related stage step action
  70605. */
  70606. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70607. /**
  70608. * Strong typing of a Camera related stage step action
  70609. */
  70610. export type CameraStageAction = (camera: Camera) => void;
  70611. /**
  70612. * Strong typing of a Render Target related stage step action
  70613. */
  70614. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70615. /**
  70616. * Strong typing of a RenderingGroup related stage step action
  70617. */
  70618. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70619. /**
  70620. * Strong typing of a Mesh Render related stage step action
  70621. */
  70622. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70623. /**
  70624. * Strong typing of a simple stage step action
  70625. */
  70626. export type SimpleStageAction = () => void;
  70627. /**
  70628. * Strong typing of a render target action.
  70629. */
  70630. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70631. /**
  70632. * Strong typing of a pointer move action.
  70633. */
  70634. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70635. /**
  70636. * Strong typing of a pointer up/down action.
  70637. */
  70638. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70639. /**
  70640. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70641. * @hidden
  70642. */
  70643. export class Stage<T extends Function> extends Array<{
  70644. index: number;
  70645. component: ISceneComponent;
  70646. action: T;
  70647. }> {
  70648. /**
  70649. * Hide ctor from the rest of the world.
  70650. * @param items The items to add.
  70651. */
  70652. private constructor();
  70653. /**
  70654. * Creates a new Stage.
  70655. * @returns A new instance of a Stage
  70656. */
  70657. static Create<T extends Function>(): Stage<T>;
  70658. /**
  70659. * Registers a step in an ordered way in the targeted stage.
  70660. * @param index Defines the position to register the step in
  70661. * @param component Defines the component attached to the step
  70662. * @param action Defines the action to launch during the step
  70663. */
  70664. registerStep(index: number, component: ISceneComponent, action: T): void;
  70665. /**
  70666. * Clears all the steps from the stage.
  70667. */
  70668. clear(): void;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. interface Scene {
  70673. /** @hidden */
  70674. _pointerOverSprite: Nullable<Sprite>;
  70675. /** @hidden */
  70676. _pickedDownSprite: Nullable<Sprite>;
  70677. /** @hidden */
  70678. _tempSpritePickingRay: Nullable<Ray>;
  70679. /**
  70680. * All of the sprite managers added to this scene
  70681. * @see http://doc.babylonjs.com/babylon101/sprites
  70682. */
  70683. spriteManagers: Array<ISpriteManager>;
  70684. /**
  70685. * An event triggered when sprites rendering is about to start
  70686. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70687. */
  70688. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70689. /**
  70690. * An event triggered when sprites rendering is done
  70691. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70692. */
  70693. onAfterSpritesRenderingObservable: Observable<Scene>;
  70694. /** @hidden */
  70695. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70696. /** Launch a ray to try to pick a sprite in the scene
  70697. * @param x position on screen
  70698. * @param y position on screen
  70699. * @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
  70700. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70701. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70702. * @returns a PickingInfo
  70703. */
  70704. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70705. /** Use the given ray to pick a sprite in the scene
  70706. * @param ray The ray (in world space) to use to pick meshes
  70707. * @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
  70708. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70709. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70710. * @returns a PickingInfo
  70711. */
  70712. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70713. /**
  70714. * Force the sprite under the pointer
  70715. * @param sprite defines the sprite to use
  70716. */
  70717. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70718. /**
  70719. * Gets the sprite under the pointer
  70720. * @returns a Sprite or null if no sprite is under the pointer
  70721. */
  70722. getPointerOverSprite(): Nullable<Sprite>;
  70723. }
  70724. /**
  70725. * Defines the sprite scene component responsible to manage sprites
  70726. * in a given scene.
  70727. */
  70728. export class SpriteSceneComponent implements ISceneComponent {
  70729. /**
  70730. * The component name helpfull to identify the component in the list of scene components.
  70731. */
  70732. readonly name: string;
  70733. /**
  70734. * The scene the component belongs to.
  70735. */
  70736. scene: Scene;
  70737. /** @hidden */
  70738. private _spritePredicate;
  70739. /**
  70740. * Creates a new instance of the component for the given scene
  70741. * @param scene Defines the scene to register the component in
  70742. */
  70743. constructor(scene: Scene);
  70744. /**
  70745. * Registers the component in a given scene
  70746. */
  70747. register(): void;
  70748. /**
  70749. * Rebuilds the elements related to this component in case of
  70750. * context lost for instance.
  70751. */
  70752. rebuild(): void;
  70753. /**
  70754. * Disposes the component and the associated ressources.
  70755. */
  70756. dispose(): void;
  70757. private _pickSpriteButKeepRay;
  70758. private _pointerMove;
  70759. private _pointerDown;
  70760. private _pointerUp;
  70761. }
  70762. }
  70763. declare module BABYLON {
  70764. /** @hidden */
  70765. export var fogFragmentDeclaration: {
  70766. name: string;
  70767. shader: string;
  70768. };
  70769. }
  70770. declare module BABYLON {
  70771. /** @hidden */
  70772. export var fogFragment: {
  70773. name: string;
  70774. shader: string;
  70775. };
  70776. }
  70777. declare module BABYLON {
  70778. /** @hidden */
  70779. export var spritesPixelShader: {
  70780. name: string;
  70781. shader: string;
  70782. };
  70783. }
  70784. declare module BABYLON {
  70785. /** @hidden */
  70786. export var fogVertexDeclaration: {
  70787. name: string;
  70788. shader: string;
  70789. };
  70790. }
  70791. declare module BABYLON {
  70792. /** @hidden */
  70793. export var spritesVertexShader: {
  70794. name: string;
  70795. shader: string;
  70796. };
  70797. }
  70798. declare module BABYLON {
  70799. /**
  70800. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70801. */
  70802. export interface ISpriteManager extends IDisposable {
  70803. /**
  70804. * Restricts the camera to viewing objects with the same layerMask.
  70805. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70806. */
  70807. layerMask: number;
  70808. /**
  70809. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70810. */
  70811. isPickable: boolean;
  70812. /**
  70813. * Specifies the rendering group id for this mesh (0 by default)
  70814. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70815. */
  70816. renderingGroupId: number;
  70817. /**
  70818. * Defines the list of sprites managed by the manager.
  70819. */
  70820. sprites: Array<Sprite>;
  70821. /**
  70822. * Tests the intersection of a sprite with a specific ray.
  70823. * @param ray The ray we are sending to test the collision
  70824. * @param camera The camera space we are sending rays in
  70825. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70826. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70827. * @returns picking info or null.
  70828. */
  70829. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70830. /**
  70831. * Renders the list of sprites on screen.
  70832. */
  70833. render(): void;
  70834. }
  70835. /**
  70836. * Class used to manage multiple sprites on the same spritesheet
  70837. * @see http://doc.babylonjs.com/babylon101/sprites
  70838. */
  70839. export class SpriteManager implements ISpriteManager {
  70840. /** defines the manager's name */
  70841. name: string;
  70842. /** Gets the list of sprites */
  70843. sprites: Sprite[];
  70844. /** Gets or sets the rendering group id (0 by default) */
  70845. renderingGroupId: number;
  70846. /** Gets or sets camera layer mask */
  70847. layerMask: number;
  70848. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70849. fogEnabled: boolean;
  70850. /** Gets or sets a boolean indicating if the sprites are pickable */
  70851. isPickable: boolean;
  70852. /** Defines the default width of a cell in the spritesheet */
  70853. cellWidth: number;
  70854. /** Defines the default height of a cell in the spritesheet */
  70855. cellHeight: number;
  70856. /**
  70857. * An event triggered when the manager is disposed.
  70858. */
  70859. onDisposeObservable: Observable<SpriteManager>;
  70860. private _onDisposeObserver;
  70861. /**
  70862. * Callback called when the manager is disposed
  70863. */
  70864. onDispose: () => void;
  70865. private _capacity;
  70866. private _spriteTexture;
  70867. private _epsilon;
  70868. private _scene;
  70869. private _vertexData;
  70870. private _buffer;
  70871. private _vertexBuffers;
  70872. private _indexBuffer;
  70873. private _effectBase;
  70874. private _effectFog;
  70875. /**
  70876. * Gets or sets the spritesheet texture
  70877. */
  70878. texture: Texture;
  70879. /**
  70880. * Creates a new sprite manager
  70881. * @param name defines the manager's name
  70882. * @param imgUrl defines the sprite sheet url
  70883. * @param capacity defines the maximum allowed number of sprites
  70884. * @param cellSize defines the size of a sprite cell
  70885. * @param scene defines the hosting scene
  70886. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70887. * @param samplingMode defines the smapling mode to use with spritesheet
  70888. */
  70889. constructor(
  70890. /** defines the manager's name */
  70891. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70892. private _appendSpriteVertex;
  70893. /**
  70894. * Intersects the sprites with a ray
  70895. * @param ray defines the ray to intersect with
  70896. * @param camera defines the current active camera
  70897. * @param predicate defines a predicate used to select candidate sprites
  70898. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70899. * @returns null if no hit or a PickingInfo
  70900. */
  70901. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70902. /**
  70903. * Render all child sprites
  70904. */
  70905. render(): void;
  70906. /**
  70907. * Release associated resources
  70908. */
  70909. dispose(): void;
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /**
  70914. * Class used to represent a sprite
  70915. * @see http://doc.babylonjs.com/babylon101/sprites
  70916. */
  70917. export class Sprite {
  70918. /** defines the name */
  70919. name: string;
  70920. /** Gets or sets the current world position */
  70921. position: Vector3;
  70922. /** Gets or sets the main color */
  70923. color: Color4;
  70924. /** Gets or sets the width */
  70925. width: number;
  70926. /** Gets or sets the height */
  70927. height: number;
  70928. /** Gets or sets rotation angle */
  70929. angle: number;
  70930. /** Gets or sets the cell index in the sprite sheet */
  70931. cellIndex: number;
  70932. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70933. invertU: number;
  70934. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70935. invertV: number;
  70936. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70937. disposeWhenFinishedAnimating: boolean;
  70938. /** Gets the list of attached animations */
  70939. animations: Animation[];
  70940. /** Gets or sets a boolean indicating if the sprite can be picked */
  70941. isPickable: boolean;
  70942. /**
  70943. * Gets or sets the associated action manager
  70944. */
  70945. actionManager: Nullable<ActionManager>;
  70946. private _animationStarted;
  70947. private _loopAnimation;
  70948. private _fromIndex;
  70949. private _toIndex;
  70950. private _delay;
  70951. private _direction;
  70952. private _manager;
  70953. private _time;
  70954. private _onAnimationEnd;
  70955. /**
  70956. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70957. */
  70958. isVisible: boolean;
  70959. /**
  70960. * Gets or sets the sprite size
  70961. */
  70962. size: number;
  70963. /**
  70964. * Creates a new Sprite
  70965. * @param name defines the name
  70966. * @param manager defines the manager
  70967. */
  70968. constructor(
  70969. /** defines the name */
  70970. name: string, manager: ISpriteManager);
  70971. /**
  70972. * Starts an animation
  70973. * @param from defines the initial key
  70974. * @param to defines the end key
  70975. * @param loop defines if the animation must loop
  70976. * @param delay defines the start delay (in ms)
  70977. * @param onAnimationEnd defines a callback to call when animation ends
  70978. */
  70979. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70980. /** Stops current animation (if any) */
  70981. stopAnimation(): void;
  70982. /** @hidden */
  70983. _animate(deltaTime: number): void;
  70984. /** Release associated resources */
  70985. dispose(): void;
  70986. }
  70987. }
  70988. declare module BABYLON {
  70989. /**
  70990. * Information about the result of picking within a scene
  70991. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70992. */
  70993. export class PickingInfo {
  70994. /** @hidden */
  70995. _pickingUnavailable: boolean;
  70996. /**
  70997. * If the pick collided with an object
  70998. */
  70999. hit: boolean;
  71000. /**
  71001. * Distance away where the pick collided
  71002. */
  71003. distance: number;
  71004. /**
  71005. * The location of pick collision
  71006. */
  71007. pickedPoint: Nullable<Vector3>;
  71008. /**
  71009. * The mesh corresponding the the pick collision
  71010. */
  71011. pickedMesh: Nullable<AbstractMesh>;
  71012. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71013. bu: number;
  71014. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71015. bv: number;
  71016. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71017. faceId: number;
  71018. /** Id of the the submesh that was picked */
  71019. subMeshId: number;
  71020. /** If a sprite was picked, this will be the sprite the pick collided with */
  71021. pickedSprite: Nullable<Sprite>;
  71022. /**
  71023. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71024. */
  71025. originMesh: Nullable<AbstractMesh>;
  71026. /**
  71027. * The ray that was used to perform the picking.
  71028. */
  71029. ray: Nullable<Ray>;
  71030. /**
  71031. * Gets the normal correspodning to the face the pick collided with
  71032. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71033. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71034. * @returns The normal correspodning to the face the pick collided with
  71035. */
  71036. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71037. /**
  71038. * Gets the texture coordinates of where the pick occured
  71039. * @returns the vector containing the coordnates of the texture
  71040. */
  71041. getTextureCoordinates(): Nullable<Vector2>;
  71042. }
  71043. }
  71044. declare module BABYLON {
  71045. /**
  71046. * Gather the list of pointer event types as constants.
  71047. */
  71048. export class PointerEventTypes {
  71049. /**
  71050. * 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.
  71051. */
  71052. static readonly POINTERDOWN: number;
  71053. /**
  71054. * The pointerup event is fired when a pointer is no longer active.
  71055. */
  71056. static readonly POINTERUP: number;
  71057. /**
  71058. * The pointermove event is fired when a pointer changes coordinates.
  71059. */
  71060. static readonly POINTERMOVE: number;
  71061. /**
  71062. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71063. */
  71064. static readonly POINTERWHEEL: number;
  71065. /**
  71066. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71067. */
  71068. static readonly POINTERPICK: number;
  71069. /**
  71070. * The pointertap event is fired when a the object has been touched and released without drag.
  71071. */
  71072. static readonly POINTERTAP: number;
  71073. /**
  71074. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71075. */
  71076. static readonly POINTERDOUBLETAP: number;
  71077. }
  71078. /**
  71079. * Base class of pointer info types.
  71080. */
  71081. export class PointerInfoBase {
  71082. /**
  71083. * Defines the type of event (PointerEventTypes)
  71084. */
  71085. type: number;
  71086. /**
  71087. * Defines the related dom event
  71088. */
  71089. event: PointerEvent | MouseWheelEvent;
  71090. /**
  71091. * Instantiates the base class of pointers info.
  71092. * @param type Defines the type of event (PointerEventTypes)
  71093. * @param event Defines the related dom event
  71094. */
  71095. constructor(
  71096. /**
  71097. * Defines the type of event (PointerEventTypes)
  71098. */
  71099. type: number,
  71100. /**
  71101. * Defines the related dom event
  71102. */
  71103. event: PointerEvent | MouseWheelEvent);
  71104. }
  71105. /**
  71106. * This class is used to store pointer related info for the onPrePointerObservable event.
  71107. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71108. */
  71109. export class PointerInfoPre extends PointerInfoBase {
  71110. /**
  71111. * Ray from a pointer if availible (eg. 6dof controller)
  71112. */
  71113. ray: Nullable<Ray>;
  71114. /**
  71115. * Defines the local position of the pointer on the canvas.
  71116. */
  71117. localPosition: Vector2;
  71118. /**
  71119. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71120. */
  71121. skipOnPointerObservable: boolean;
  71122. /**
  71123. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71124. * @param type Defines the type of event (PointerEventTypes)
  71125. * @param event Defines the related dom event
  71126. * @param localX Defines the local x coordinates of the pointer when the event occured
  71127. * @param localY Defines the local y coordinates of the pointer when the event occured
  71128. */
  71129. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71130. }
  71131. /**
  71132. * This type contains all the data related to a pointer event in Babylon.js.
  71133. * 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.
  71134. */
  71135. export class PointerInfo extends PointerInfoBase {
  71136. /**
  71137. * Defines the picking info associated to the info (if any)\
  71138. */
  71139. pickInfo: Nullable<PickingInfo>;
  71140. /**
  71141. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71142. * @param type Defines the type of event (PointerEventTypes)
  71143. * @param event Defines the related dom event
  71144. * @param pickInfo Defines the picking info associated to the info (if any)\
  71145. */
  71146. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71147. /**
  71148. * Defines the picking info associated to the info (if any)\
  71149. */
  71150. pickInfo: Nullable<PickingInfo>);
  71151. }
  71152. /**
  71153. * Data relating to a touch event on the screen.
  71154. */
  71155. export interface PointerTouch {
  71156. /**
  71157. * X coordinate of touch.
  71158. */
  71159. x: number;
  71160. /**
  71161. * Y coordinate of touch.
  71162. */
  71163. y: number;
  71164. /**
  71165. * Id of touch. Unique for each finger.
  71166. */
  71167. pointerId: number;
  71168. /**
  71169. * Event type passed from DOM.
  71170. */
  71171. type: any;
  71172. }
  71173. }
  71174. declare module BABYLON {
  71175. /**
  71176. * Manage the mouse inputs to control the movement of a free camera.
  71177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71178. */
  71179. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71180. /**
  71181. * Define if touch is enabled in the mouse input
  71182. */
  71183. touchEnabled: boolean;
  71184. /**
  71185. * Defines the camera the input is attached to.
  71186. */
  71187. camera: FreeCamera;
  71188. /**
  71189. * Defines the buttons associated with the input to handle camera move.
  71190. */
  71191. buttons: number[];
  71192. /**
  71193. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71194. */
  71195. angularSensibility: number;
  71196. private _pointerInput;
  71197. private _onMouseMove;
  71198. private _observer;
  71199. private previousPosition;
  71200. /**
  71201. * Observable for when a pointer move event occurs containing the move offset
  71202. */
  71203. onPointerMovedObservable: Observable<{
  71204. offsetX: number;
  71205. offsetY: number;
  71206. }>;
  71207. /**
  71208. * @hidden
  71209. * If the camera should be rotated automatically based on pointer movement
  71210. */
  71211. _allowCameraRotation: boolean;
  71212. /**
  71213. * Manage the mouse inputs to control the movement of a free camera.
  71214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71215. * @param touchEnabled Defines if touch is enabled or not
  71216. */
  71217. constructor(
  71218. /**
  71219. * Define if touch is enabled in the mouse input
  71220. */
  71221. touchEnabled?: boolean);
  71222. /**
  71223. * Attach the input controls to a specific dom element to get the input from.
  71224. * @param element Defines the element the controls should be listened from
  71225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71226. */
  71227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71228. /**
  71229. * Called on JS contextmenu event.
  71230. * Override this method to provide functionality.
  71231. */
  71232. protected onContextMenu(evt: PointerEvent): void;
  71233. /**
  71234. * Detach the current controls from the specified dom element.
  71235. * @param element Defines the element to stop listening the inputs from
  71236. */
  71237. detachControl(element: Nullable<HTMLElement>): void;
  71238. /**
  71239. * Gets the class name of the current intput.
  71240. * @returns the class name
  71241. */
  71242. getClassName(): string;
  71243. /**
  71244. * Get the friendly name associated with the input class.
  71245. * @returns the input friendly name
  71246. */
  71247. getSimpleName(): string;
  71248. }
  71249. }
  71250. declare module BABYLON {
  71251. /**
  71252. * Manage the touch inputs to control the movement of a free camera.
  71253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71254. */
  71255. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71256. /**
  71257. * Defines the camera the input is attached to.
  71258. */
  71259. camera: FreeCamera;
  71260. /**
  71261. * Defines the touch sensibility for rotation.
  71262. * The higher the faster.
  71263. */
  71264. touchAngularSensibility: number;
  71265. /**
  71266. * Defines the touch sensibility for move.
  71267. * The higher the faster.
  71268. */
  71269. touchMoveSensibility: number;
  71270. private _offsetX;
  71271. private _offsetY;
  71272. private _pointerPressed;
  71273. private _pointerInput;
  71274. private _observer;
  71275. private _onLostFocus;
  71276. /**
  71277. * Attach the input controls to a specific dom element to get the input from.
  71278. * @param element Defines the element the controls should be listened from
  71279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71280. */
  71281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71282. /**
  71283. * Detach the current controls from the specified dom element.
  71284. * @param element Defines the element to stop listening the inputs from
  71285. */
  71286. detachControl(element: Nullable<HTMLElement>): void;
  71287. /**
  71288. * Update the current camera state depending on the inputs that have been used this frame.
  71289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71290. */
  71291. checkInputs(): void;
  71292. /**
  71293. * Gets the class name of the current intput.
  71294. * @returns the class name
  71295. */
  71296. getClassName(): string;
  71297. /**
  71298. * Get the friendly name associated with the input class.
  71299. * @returns the input friendly name
  71300. */
  71301. getSimpleName(): string;
  71302. }
  71303. }
  71304. declare module BABYLON {
  71305. /**
  71306. * Default Inputs manager for the FreeCamera.
  71307. * It groups all the default supported inputs for ease of use.
  71308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71309. */
  71310. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71311. /**
  71312. * @hidden
  71313. */
  71314. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71315. /**
  71316. * @hidden
  71317. */
  71318. _mouseInput: Nullable<FreeCameraMouseInput>;
  71319. /**
  71320. * Instantiates a new FreeCameraInputsManager.
  71321. * @param camera Defines the camera the inputs belong to
  71322. */
  71323. constructor(camera: FreeCamera);
  71324. /**
  71325. * Add keyboard input support to the input manager.
  71326. * @returns the current input manager
  71327. */
  71328. addKeyboard(): FreeCameraInputsManager;
  71329. /**
  71330. * Add mouse input support to the input manager.
  71331. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71332. * @returns the current input manager
  71333. */
  71334. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71335. /**
  71336. * Removes the mouse input support from the manager
  71337. * @returns the current input manager
  71338. */
  71339. removeMouse(): FreeCameraInputsManager;
  71340. /**
  71341. * Add touch input support to the input manager.
  71342. * @returns the current input manager
  71343. */
  71344. addTouch(): FreeCameraInputsManager;
  71345. }
  71346. }
  71347. declare module BABYLON {
  71348. /**
  71349. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71350. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71351. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71352. */
  71353. export class FreeCamera extends TargetCamera {
  71354. /**
  71355. * Define the collision ellipsoid of the camera.
  71356. * This is helpful to simulate a camera body like the player body around the camera
  71357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71358. */
  71359. ellipsoid: Vector3;
  71360. /**
  71361. * Define an offset for the position of the ellipsoid around the camera.
  71362. * This can be helpful to determine the center of the body near the gravity center of the body
  71363. * instead of its head.
  71364. */
  71365. ellipsoidOffset: Vector3;
  71366. /**
  71367. * Enable or disable collisions of the camera with the rest of the scene objects.
  71368. */
  71369. checkCollisions: boolean;
  71370. /**
  71371. * Enable or disable gravity on the camera.
  71372. */
  71373. applyGravity: boolean;
  71374. /**
  71375. * Define the input manager associated to the camera.
  71376. */
  71377. inputs: FreeCameraInputsManager;
  71378. /**
  71379. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71380. * Higher values reduce sensitivity.
  71381. */
  71382. /**
  71383. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71384. * Higher values reduce sensitivity.
  71385. */
  71386. angularSensibility: number;
  71387. /**
  71388. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71389. */
  71390. keysUp: number[];
  71391. /**
  71392. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71393. */
  71394. keysDown: number[];
  71395. /**
  71396. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71397. */
  71398. keysLeft: number[];
  71399. /**
  71400. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71401. */
  71402. keysRight: number[];
  71403. /**
  71404. * Event raised when the camera collide with a mesh in the scene.
  71405. */
  71406. onCollide: (collidedMesh: AbstractMesh) => void;
  71407. private _collider;
  71408. private _needMoveForGravity;
  71409. private _oldPosition;
  71410. private _diffPosition;
  71411. private _newPosition;
  71412. /** @hidden */
  71413. _localDirection: Vector3;
  71414. /** @hidden */
  71415. _transformedDirection: Vector3;
  71416. /**
  71417. * Instantiates a Free Camera.
  71418. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71419. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71420. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71421. * @param name Define the name of the camera in the scene
  71422. * @param position Define the start position of the camera in the scene
  71423. * @param scene Define the scene the camera belongs to
  71424. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71425. */
  71426. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71427. /**
  71428. * Attached controls to the current camera.
  71429. * @param element Defines the element the controls should be listened from
  71430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71431. */
  71432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71433. /**
  71434. * Detach the current controls from the camera.
  71435. * The camera will stop reacting to inputs.
  71436. * @param element Defines the element to stop listening the inputs from
  71437. */
  71438. detachControl(element: HTMLElement): void;
  71439. private _collisionMask;
  71440. /**
  71441. * Define a collision mask to limit the list of object the camera can collide with
  71442. */
  71443. collisionMask: number;
  71444. /** @hidden */
  71445. _collideWithWorld(displacement: Vector3): void;
  71446. private _onCollisionPositionChange;
  71447. /** @hidden */
  71448. _checkInputs(): void;
  71449. /** @hidden */
  71450. _decideIfNeedsToMove(): boolean;
  71451. /** @hidden */
  71452. _updatePosition(): void;
  71453. /**
  71454. * Destroy the camera and release the current resources hold by it.
  71455. */
  71456. dispose(): void;
  71457. /**
  71458. * Gets the current object class name.
  71459. * @return the class name
  71460. */
  71461. getClassName(): string;
  71462. }
  71463. }
  71464. declare module BABYLON {
  71465. /**
  71466. * Represents a gamepad control stick position
  71467. */
  71468. export class StickValues {
  71469. /**
  71470. * The x component of the control stick
  71471. */
  71472. x: number;
  71473. /**
  71474. * The y component of the control stick
  71475. */
  71476. y: number;
  71477. /**
  71478. * Initializes the gamepad x and y control stick values
  71479. * @param x The x component of the gamepad control stick value
  71480. * @param y The y component of the gamepad control stick value
  71481. */
  71482. constructor(
  71483. /**
  71484. * The x component of the control stick
  71485. */
  71486. x: number,
  71487. /**
  71488. * The y component of the control stick
  71489. */
  71490. y: number);
  71491. }
  71492. /**
  71493. * An interface which manages callbacks for gamepad button changes
  71494. */
  71495. export interface GamepadButtonChanges {
  71496. /**
  71497. * Called when a gamepad has been changed
  71498. */
  71499. changed: boolean;
  71500. /**
  71501. * Called when a gamepad press event has been triggered
  71502. */
  71503. pressChanged: boolean;
  71504. /**
  71505. * Called when a touch event has been triggered
  71506. */
  71507. touchChanged: boolean;
  71508. /**
  71509. * Called when a value has changed
  71510. */
  71511. valueChanged: boolean;
  71512. }
  71513. /**
  71514. * Represents a gamepad
  71515. */
  71516. export class Gamepad {
  71517. /**
  71518. * The id of the gamepad
  71519. */
  71520. id: string;
  71521. /**
  71522. * The index of the gamepad
  71523. */
  71524. index: number;
  71525. /**
  71526. * The browser gamepad
  71527. */
  71528. browserGamepad: any;
  71529. /**
  71530. * Specifies what type of gamepad this represents
  71531. */
  71532. type: number;
  71533. private _leftStick;
  71534. private _rightStick;
  71535. /** @hidden */
  71536. _isConnected: boolean;
  71537. private _leftStickAxisX;
  71538. private _leftStickAxisY;
  71539. private _rightStickAxisX;
  71540. private _rightStickAxisY;
  71541. /**
  71542. * Triggered when the left control stick has been changed
  71543. */
  71544. private _onleftstickchanged;
  71545. /**
  71546. * Triggered when the right control stick has been changed
  71547. */
  71548. private _onrightstickchanged;
  71549. /**
  71550. * Represents a gamepad controller
  71551. */
  71552. static GAMEPAD: number;
  71553. /**
  71554. * Represents a generic controller
  71555. */
  71556. static GENERIC: number;
  71557. /**
  71558. * Represents an XBox controller
  71559. */
  71560. static XBOX: number;
  71561. /**
  71562. * Represents a pose-enabled controller
  71563. */
  71564. static POSE_ENABLED: number;
  71565. /**
  71566. * Specifies whether the left control stick should be Y-inverted
  71567. */
  71568. protected _invertLeftStickY: boolean;
  71569. /**
  71570. * Specifies if the gamepad has been connected
  71571. */
  71572. readonly isConnected: boolean;
  71573. /**
  71574. * Initializes the gamepad
  71575. * @param id The id of the gamepad
  71576. * @param index The index of the gamepad
  71577. * @param browserGamepad The browser gamepad
  71578. * @param leftStickX The x component of the left joystick
  71579. * @param leftStickY The y component of the left joystick
  71580. * @param rightStickX The x component of the right joystick
  71581. * @param rightStickY The y component of the right joystick
  71582. */
  71583. constructor(
  71584. /**
  71585. * The id of the gamepad
  71586. */
  71587. id: string,
  71588. /**
  71589. * The index of the gamepad
  71590. */
  71591. index: number,
  71592. /**
  71593. * The browser gamepad
  71594. */
  71595. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71596. /**
  71597. * Callback triggered when the left joystick has changed
  71598. * @param callback
  71599. */
  71600. onleftstickchanged(callback: (values: StickValues) => void): void;
  71601. /**
  71602. * Callback triggered when the right joystick has changed
  71603. * @param callback
  71604. */
  71605. onrightstickchanged(callback: (values: StickValues) => void): void;
  71606. /**
  71607. * Gets the left joystick
  71608. */
  71609. /**
  71610. * Sets the left joystick values
  71611. */
  71612. leftStick: StickValues;
  71613. /**
  71614. * Gets the right joystick
  71615. */
  71616. /**
  71617. * Sets the right joystick value
  71618. */
  71619. rightStick: StickValues;
  71620. /**
  71621. * Updates the gamepad joystick positions
  71622. */
  71623. update(): void;
  71624. /**
  71625. * Disposes the gamepad
  71626. */
  71627. dispose(): void;
  71628. }
  71629. /**
  71630. * Represents a generic gamepad
  71631. */
  71632. export class GenericPad extends Gamepad {
  71633. private _buttons;
  71634. private _onbuttondown;
  71635. private _onbuttonup;
  71636. /**
  71637. * Observable triggered when a button has been pressed
  71638. */
  71639. onButtonDownObservable: Observable<number>;
  71640. /**
  71641. * Observable triggered when a button has been released
  71642. */
  71643. onButtonUpObservable: Observable<number>;
  71644. /**
  71645. * Callback triggered when a button has been pressed
  71646. * @param callback Called when a button has been pressed
  71647. */
  71648. onbuttondown(callback: (buttonPressed: number) => void): void;
  71649. /**
  71650. * Callback triggered when a button has been released
  71651. * @param callback Called when a button has been released
  71652. */
  71653. onbuttonup(callback: (buttonReleased: number) => void): void;
  71654. /**
  71655. * Initializes the generic gamepad
  71656. * @param id The id of the generic gamepad
  71657. * @param index The index of the generic gamepad
  71658. * @param browserGamepad The browser gamepad
  71659. */
  71660. constructor(id: string, index: number, browserGamepad: any);
  71661. private _setButtonValue;
  71662. /**
  71663. * Updates the generic gamepad
  71664. */
  71665. update(): void;
  71666. /**
  71667. * Disposes the generic gamepad
  71668. */
  71669. dispose(): void;
  71670. }
  71671. }
  71672. declare module BABYLON {
  71673. /**
  71674. * Defines the types of pose enabled controllers that are supported
  71675. */
  71676. export enum PoseEnabledControllerType {
  71677. /**
  71678. * HTC Vive
  71679. */
  71680. VIVE = 0,
  71681. /**
  71682. * Oculus Rift
  71683. */
  71684. OCULUS = 1,
  71685. /**
  71686. * Windows mixed reality
  71687. */
  71688. WINDOWS = 2,
  71689. /**
  71690. * Samsung gear VR
  71691. */
  71692. GEAR_VR = 3,
  71693. /**
  71694. * Google Daydream
  71695. */
  71696. DAYDREAM = 4,
  71697. /**
  71698. * Generic
  71699. */
  71700. GENERIC = 5
  71701. }
  71702. /**
  71703. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71704. */
  71705. export interface MutableGamepadButton {
  71706. /**
  71707. * Value of the button/trigger
  71708. */
  71709. value: number;
  71710. /**
  71711. * If the button/trigger is currently touched
  71712. */
  71713. touched: boolean;
  71714. /**
  71715. * If the button/trigger is currently pressed
  71716. */
  71717. pressed: boolean;
  71718. }
  71719. /**
  71720. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71721. * @hidden
  71722. */
  71723. export interface ExtendedGamepadButton extends GamepadButton {
  71724. /**
  71725. * If the button/trigger is currently pressed
  71726. */
  71727. readonly pressed: boolean;
  71728. /**
  71729. * If the button/trigger is currently touched
  71730. */
  71731. readonly touched: boolean;
  71732. /**
  71733. * Value of the button/trigger
  71734. */
  71735. readonly value: number;
  71736. }
  71737. /** @hidden */
  71738. export interface _GamePadFactory {
  71739. /**
  71740. * Returns wether or not the current gamepad can be created for this type of controller.
  71741. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71742. * @returns true if it can be created, otherwise false
  71743. */
  71744. canCreate(gamepadInfo: any): boolean;
  71745. /**
  71746. * Creates a new instance of the Gamepad.
  71747. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71748. * @returns the new gamepad instance
  71749. */
  71750. create(gamepadInfo: any): Gamepad;
  71751. }
  71752. /**
  71753. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71754. */
  71755. export class PoseEnabledControllerHelper {
  71756. /** @hidden */
  71757. static _ControllerFactories: _GamePadFactory[];
  71758. /** @hidden */
  71759. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71760. /**
  71761. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71762. * @param vrGamepad the gamepad to initialized
  71763. * @returns a vr controller of the type the gamepad identified as
  71764. */
  71765. static InitiateController(vrGamepad: any): Gamepad;
  71766. }
  71767. /**
  71768. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71769. */
  71770. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71771. private _deviceRoomPosition;
  71772. private _deviceRoomRotationQuaternion;
  71773. /**
  71774. * The device position in babylon space
  71775. */
  71776. devicePosition: Vector3;
  71777. /**
  71778. * The device rotation in babylon space
  71779. */
  71780. deviceRotationQuaternion: Quaternion;
  71781. /**
  71782. * The scale factor of the device in babylon space
  71783. */
  71784. deviceScaleFactor: number;
  71785. /**
  71786. * (Likely devicePosition should be used instead) The device position in its room space
  71787. */
  71788. position: Vector3;
  71789. /**
  71790. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71791. */
  71792. rotationQuaternion: Quaternion;
  71793. /**
  71794. * The type of controller (Eg. Windows mixed reality)
  71795. */
  71796. controllerType: PoseEnabledControllerType;
  71797. protected _calculatedPosition: Vector3;
  71798. private _calculatedRotation;
  71799. /**
  71800. * The raw pose from the device
  71801. */
  71802. rawPose: DevicePose;
  71803. private _trackPosition;
  71804. private _maxRotationDistFromHeadset;
  71805. private _draggedRoomRotation;
  71806. /**
  71807. * @hidden
  71808. */
  71809. _disableTrackPosition(fixedPosition: Vector3): void;
  71810. /**
  71811. * Internal, the mesh attached to the controller
  71812. * @hidden
  71813. */
  71814. _mesh: Nullable<AbstractMesh>;
  71815. private _poseControlledCamera;
  71816. private _leftHandSystemQuaternion;
  71817. /**
  71818. * Internal, matrix used to convert room space to babylon space
  71819. * @hidden
  71820. */
  71821. _deviceToWorld: Matrix;
  71822. /**
  71823. * Node to be used when casting a ray from the controller
  71824. * @hidden
  71825. */
  71826. _pointingPoseNode: Nullable<TransformNode>;
  71827. /**
  71828. * Name of the child mesh that can be used to cast a ray from the controller
  71829. */
  71830. static readonly POINTING_POSE: string;
  71831. /**
  71832. * Creates a new PoseEnabledController from a gamepad
  71833. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71834. */
  71835. constructor(browserGamepad: any);
  71836. private _workingMatrix;
  71837. /**
  71838. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71839. */
  71840. update(): void;
  71841. /**
  71842. * Updates only the pose device and mesh without doing any button event checking
  71843. */
  71844. protected _updatePoseAndMesh(): void;
  71845. /**
  71846. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71847. * @param poseData raw pose fromthe device
  71848. */
  71849. updateFromDevice(poseData: DevicePose): void;
  71850. /**
  71851. * @hidden
  71852. */
  71853. _meshAttachedObservable: Observable<AbstractMesh>;
  71854. /**
  71855. * Attaches a mesh to the controller
  71856. * @param mesh the mesh to be attached
  71857. */
  71858. attachToMesh(mesh: AbstractMesh): void;
  71859. /**
  71860. * Attaches the controllers mesh to a camera
  71861. * @param camera the camera the mesh should be attached to
  71862. */
  71863. attachToPoseControlledCamera(camera: TargetCamera): void;
  71864. /**
  71865. * Disposes of the controller
  71866. */
  71867. dispose(): void;
  71868. /**
  71869. * The mesh that is attached to the controller
  71870. */
  71871. readonly mesh: Nullable<AbstractMesh>;
  71872. /**
  71873. * Gets the ray of the controller in the direction the controller is pointing
  71874. * @param length the length the resulting ray should be
  71875. * @returns a ray in the direction the controller is pointing
  71876. */
  71877. getForwardRay(length?: number): Ray;
  71878. }
  71879. }
  71880. declare module BABYLON {
  71881. /**
  71882. * Defines the WebVRController object that represents controllers tracked in 3D space
  71883. */
  71884. export abstract class WebVRController extends PoseEnabledController {
  71885. /**
  71886. * Internal, the default controller model for the controller
  71887. */
  71888. protected _defaultModel: AbstractMesh;
  71889. /**
  71890. * Fired when the trigger state has changed
  71891. */
  71892. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71893. /**
  71894. * Fired when the main button state has changed
  71895. */
  71896. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71897. /**
  71898. * Fired when the secondary button state has changed
  71899. */
  71900. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71901. /**
  71902. * Fired when the pad state has changed
  71903. */
  71904. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71905. /**
  71906. * Fired when controllers stick values have changed
  71907. */
  71908. onPadValuesChangedObservable: Observable<StickValues>;
  71909. /**
  71910. * Array of button availible on the controller
  71911. */
  71912. protected _buttons: Array<MutableGamepadButton>;
  71913. private _onButtonStateChange;
  71914. /**
  71915. * Fired when a controller button's state has changed
  71916. * @param callback the callback containing the button that was modified
  71917. */
  71918. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71919. /**
  71920. * X and Y axis corrisponding to the controllers joystick
  71921. */
  71922. pad: StickValues;
  71923. /**
  71924. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71925. */
  71926. hand: string;
  71927. /**
  71928. * The default controller model for the controller
  71929. */
  71930. readonly defaultModel: AbstractMesh;
  71931. /**
  71932. * Creates a new WebVRController from a gamepad
  71933. * @param vrGamepad the gamepad that the WebVRController should be created from
  71934. */
  71935. constructor(vrGamepad: any);
  71936. /**
  71937. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71938. */
  71939. update(): void;
  71940. /**
  71941. * Function to be called when a button is modified
  71942. */
  71943. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71944. /**
  71945. * Loads a mesh and attaches it to the controller
  71946. * @param scene the scene the mesh should be added to
  71947. * @param meshLoaded callback for when the mesh has been loaded
  71948. */
  71949. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71950. private _setButtonValue;
  71951. private _changes;
  71952. private _checkChanges;
  71953. /**
  71954. * Disposes of th webVRCOntroller
  71955. */
  71956. dispose(): void;
  71957. }
  71958. }
  71959. declare module BABYLON {
  71960. /**
  71961. * The HemisphericLight simulates the ambient environment light,
  71962. * so the passed direction is the light reflection direction, not the incoming direction.
  71963. */
  71964. export class HemisphericLight extends Light {
  71965. /**
  71966. * The groundColor is the light in the opposite direction to the one specified during creation.
  71967. * 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.
  71968. */
  71969. groundColor: Color3;
  71970. /**
  71971. * The light reflection direction, not the incoming direction.
  71972. */
  71973. direction: Vector3;
  71974. /**
  71975. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71976. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71977. * The HemisphericLight can't cast shadows.
  71978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71979. * @param name The friendly name of the light
  71980. * @param direction The direction of the light reflection
  71981. * @param scene The scene the light belongs to
  71982. */
  71983. constructor(name: string, direction: Vector3, scene: Scene);
  71984. protected _buildUniformLayout(): void;
  71985. /**
  71986. * Returns the string "HemisphericLight".
  71987. * @return The class name
  71988. */
  71989. getClassName(): string;
  71990. /**
  71991. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71992. * Returns the updated direction.
  71993. * @param target The target the direction should point to
  71994. * @return The computed direction
  71995. */
  71996. setDirectionToTarget(target: Vector3): Vector3;
  71997. /**
  71998. * Returns the shadow generator associated to the light.
  71999. * @returns Always null for hemispheric lights because it does not support shadows.
  72000. */
  72001. getShadowGenerator(): Nullable<IShadowGenerator>;
  72002. /**
  72003. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72004. * @param effect The effect to update
  72005. * @param lightIndex The index of the light in the effect to update
  72006. * @returns The hemispheric light
  72007. */
  72008. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72009. /**
  72010. * Computes the world matrix of the node
  72011. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72012. * @param useWasUpdatedFlag defines a reserved property
  72013. * @returns the world matrix
  72014. */
  72015. computeWorldMatrix(): Matrix;
  72016. /**
  72017. * Returns the integer 3.
  72018. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72019. */
  72020. getTypeID(): number;
  72021. /**
  72022. * Prepares the list of defines specific to the light type.
  72023. * @param defines the list of defines
  72024. * @param lightIndex defines the index of the light for the effect
  72025. */
  72026. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72027. }
  72028. }
  72029. declare module BABYLON {
  72030. /** @hidden */
  72031. export var vrMultiviewToSingleviewPixelShader: {
  72032. name: string;
  72033. shader: string;
  72034. };
  72035. }
  72036. declare module BABYLON {
  72037. /**
  72038. * Renders to multiple views with a single draw call
  72039. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72040. */
  72041. export class MultiviewRenderTarget extends RenderTargetTexture {
  72042. /**
  72043. * Creates a multiview render target
  72044. * @param scene scene used with the render target
  72045. * @param size the size of the render target (used for each view)
  72046. */
  72047. constructor(scene: Scene, size?: number | {
  72048. width: number;
  72049. height: number;
  72050. } | {
  72051. ratio: number;
  72052. });
  72053. /**
  72054. * @hidden
  72055. * @param faceIndex the face index, if its a cube texture
  72056. */
  72057. _bindFrameBuffer(faceIndex?: number): void;
  72058. /**
  72059. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72060. * @returns the view count
  72061. */
  72062. getViewCount(): number;
  72063. }
  72064. }
  72065. declare module BABYLON {
  72066. interface Engine {
  72067. /**
  72068. * Creates a new multiview render target
  72069. * @param width defines the width of the texture
  72070. * @param height defines the height of the texture
  72071. * @returns the created multiview texture
  72072. */
  72073. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72074. /**
  72075. * Binds a multiview framebuffer to be drawn to
  72076. * @param multiviewTexture texture to bind
  72077. */
  72078. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72079. }
  72080. interface Camera {
  72081. /**
  72082. * @hidden
  72083. * 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)
  72084. */
  72085. _useMultiviewToSingleView: boolean;
  72086. /**
  72087. * @hidden
  72088. * 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)
  72089. */
  72090. _multiviewTexture: Nullable<RenderTargetTexture>;
  72091. /**
  72092. * @hidden
  72093. * ensures the multiview texture of the camera exists and has the specified width/height
  72094. * @param width height to set on the multiview texture
  72095. * @param height width to set on the multiview texture
  72096. */
  72097. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72098. }
  72099. interface Scene {
  72100. /** @hidden */
  72101. _transformMatrixR: Matrix;
  72102. /** @hidden */
  72103. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72104. /** @hidden */
  72105. _createMultiviewUbo(): void;
  72106. /** @hidden */
  72107. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72108. /** @hidden */
  72109. _renderMultiviewToSingleView(camera: Camera): void;
  72110. }
  72111. }
  72112. declare module BABYLON {
  72113. /**
  72114. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72115. * This will not be used for webXR as it supports displaying texture arrays directly
  72116. */
  72117. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72118. /**
  72119. * Initializes a VRMultiviewToSingleview
  72120. * @param name name of the post process
  72121. * @param camera camera to be applied to
  72122. * @param scaleFactor scaling factor to the size of the output texture
  72123. */
  72124. constructor(name: string, camera: Camera, scaleFactor: number);
  72125. }
  72126. }
  72127. declare module BABYLON {
  72128. /**
  72129. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72130. * IMPORTANT!! The data is right-hand data.
  72131. * @export
  72132. * @interface DevicePose
  72133. */
  72134. export interface DevicePose {
  72135. /**
  72136. * The position of the device, values in array are [x,y,z].
  72137. */
  72138. readonly position: Nullable<Float32Array>;
  72139. /**
  72140. * The linearVelocity of the device, values in array are [x,y,z].
  72141. */
  72142. readonly linearVelocity: Nullable<Float32Array>;
  72143. /**
  72144. * The linearAcceleration of the device, values in array are [x,y,z].
  72145. */
  72146. readonly linearAcceleration: Nullable<Float32Array>;
  72147. /**
  72148. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72149. */
  72150. readonly orientation: Nullable<Float32Array>;
  72151. /**
  72152. * The angularVelocity of the device, values in array are [x,y,z].
  72153. */
  72154. readonly angularVelocity: Nullable<Float32Array>;
  72155. /**
  72156. * The angularAcceleration of the device, values in array are [x,y,z].
  72157. */
  72158. readonly angularAcceleration: Nullable<Float32Array>;
  72159. }
  72160. /**
  72161. * Interface representing a pose controlled object in Babylon.
  72162. * A pose controlled object has both regular pose values as well as pose values
  72163. * from an external device such as a VR head mounted display
  72164. */
  72165. export interface PoseControlled {
  72166. /**
  72167. * The position of the object in babylon space.
  72168. */
  72169. position: Vector3;
  72170. /**
  72171. * The rotation quaternion of the object in babylon space.
  72172. */
  72173. rotationQuaternion: Quaternion;
  72174. /**
  72175. * The position of the device in babylon space.
  72176. */
  72177. devicePosition?: Vector3;
  72178. /**
  72179. * The rotation quaternion of the device in babylon space.
  72180. */
  72181. deviceRotationQuaternion: Quaternion;
  72182. /**
  72183. * The raw pose coming from the device.
  72184. */
  72185. rawPose: Nullable<DevicePose>;
  72186. /**
  72187. * The scale of the device to be used when translating from device space to babylon space.
  72188. */
  72189. deviceScaleFactor: number;
  72190. /**
  72191. * Updates the poseControlled values based on the input device pose.
  72192. * @param poseData the pose data to update the object with
  72193. */
  72194. updateFromDevice(poseData: DevicePose): void;
  72195. }
  72196. /**
  72197. * Set of options to customize the webVRCamera
  72198. */
  72199. export interface WebVROptions {
  72200. /**
  72201. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72202. */
  72203. trackPosition?: boolean;
  72204. /**
  72205. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72206. */
  72207. positionScale?: number;
  72208. /**
  72209. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72210. */
  72211. displayName?: string;
  72212. /**
  72213. * Should the native controller meshes be initialized. (default: true)
  72214. */
  72215. controllerMeshes?: boolean;
  72216. /**
  72217. * Creating a default HemiLight only on controllers. (default: true)
  72218. */
  72219. defaultLightingOnControllers?: boolean;
  72220. /**
  72221. * If you don't want to use the default VR button of the helper. (default: false)
  72222. */
  72223. useCustomVRButton?: boolean;
  72224. /**
  72225. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72226. */
  72227. customVRButton?: HTMLButtonElement;
  72228. /**
  72229. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72230. */
  72231. rayLength?: number;
  72232. /**
  72233. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72234. */
  72235. defaultHeight?: number;
  72236. /**
  72237. * If multiview should be used if availible (default: false)
  72238. */
  72239. useMultiview?: boolean;
  72240. }
  72241. /**
  72242. * This represents a WebVR camera.
  72243. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72244. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72245. */
  72246. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72247. private webVROptions;
  72248. /**
  72249. * @hidden
  72250. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72251. */
  72252. _vrDevice: any;
  72253. /**
  72254. * The rawPose of the vrDevice.
  72255. */
  72256. rawPose: Nullable<DevicePose>;
  72257. private _onVREnabled;
  72258. private _specsVersion;
  72259. private _attached;
  72260. private _frameData;
  72261. protected _descendants: Array<Node>;
  72262. private _deviceRoomPosition;
  72263. /** @hidden */
  72264. _deviceRoomRotationQuaternion: Quaternion;
  72265. private _standingMatrix;
  72266. /**
  72267. * Represents device position in babylon space.
  72268. */
  72269. devicePosition: Vector3;
  72270. /**
  72271. * Represents device rotation in babylon space.
  72272. */
  72273. deviceRotationQuaternion: Quaternion;
  72274. /**
  72275. * The scale of the device to be used when translating from device space to babylon space.
  72276. */
  72277. deviceScaleFactor: number;
  72278. private _deviceToWorld;
  72279. private _worldToDevice;
  72280. /**
  72281. * References to the webVR controllers for the vrDevice.
  72282. */
  72283. controllers: Array<WebVRController>;
  72284. /**
  72285. * Emits an event when a controller is attached.
  72286. */
  72287. onControllersAttachedObservable: Observable<WebVRController[]>;
  72288. /**
  72289. * Emits an event when a controller's mesh has been loaded;
  72290. */
  72291. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72292. /**
  72293. * Emits an event when the HMD's pose has been updated.
  72294. */
  72295. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72296. private _poseSet;
  72297. /**
  72298. * If the rig cameras be used as parent instead of this camera.
  72299. */
  72300. rigParenting: boolean;
  72301. private _lightOnControllers;
  72302. private _defaultHeight?;
  72303. /**
  72304. * Instantiates a WebVRFreeCamera.
  72305. * @param name The name of the WebVRFreeCamera
  72306. * @param position The starting anchor position for the camera
  72307. * @param scene The scene the camera belongs to
  72308. * @param webVROptions a set of customizable options for the webVRCamera
  72309. */
  72310. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72311. /**
  72312. * Gets the device distance from the ground in meters.
  72313. * @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.
  72314. */
  72315. deviceDistanceToRoomGround(): number;
  72316. /**
  72317. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72318. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72319. */
  72320. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72321. /**
  72322. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72323. * @returns A promise with a boolean set to if the standing matrix is supported.
  72324. */
  72325. useStandingMatrixAsync(): Promise<boolean>;
  72326. /**
  72327. * Disposes the camera
  72328. */
  72329. dispose(): void;
  72330. /**
  72331. * Gets a vrController by name.
  72332. * @param name The name of the controller to retreive
  72333. * @returns the controller matching the name specified or null if not found
  72334. */
  72335. getControllerByName(name: string): Nullable<WebVRController>;
  72336. private _leftController;
  72337. /**
  72338. * The controller corrisponding to the users left hand.
  72339. */
  72340. readonly leftController: Nullable<WebVRController>;
  72341. private _rightController;
  72342. /**
  72343. * The controller corrisponding to the users right hand.
  72344. */
  72345. readonly rightController: Nullable<WebVRController>;
  72346. /**
  72347. * Casts a ray forward from the vrCamera's gaze.
  72348. * @param length Length of the ray (default: 100)
  72349. * @returns the ray corrisponding to the gaze
  72350. */
  72351. getForwardRay(length?: number): Ray;
  72352. /**
  72353. * @hidden
  72354. * Updates the camera based on device's frame data
  72355. */
  72356. _checkInputs(): void;
  72357. /**
  72358. * Updates the poseControlled values based on the input device pose.
  72359. * @param poseData Pose coming from the device
  72360. */
  72361. updateFromDevice(poseData: DevicePose): void;
  72362. private _htmlElementAttached;
  72363. private _detachIfAttached;
  72364. /**
  72365. * WebVR's attach control will start broadcasting frames to the device.
  72366. * Note that in certain browsers (chrome for example) this function must be called
  72367. * within a user-interaction callback. Example:
  72368. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72369. *
  72370. * @param element html element to attach the vrDevice to
  72371. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72372. */
  72373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72374. /**
  72375. * Detaches the camera from the html element and disables VR
  72376. *
  72377. * @param element html element to detach from
  72378. */
  72379. detachControl(element: HTMLElement): void;
  72380. /**
  72381. * @returns the name of this class
  72382. */
  72383. getClassName(): string;
  72384. /**
  72385. * Calls resetPose on the vrDisplay
  72386. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72387. */
  72388. resetToCurrentRotation(): void;
  72389. /**
  72390. * @hidden
  72391. * Updates the rig cameras (left and right eye)
  72392. */
  72393. _updateRigCameras(): void;
  72394. private _workingVector;
  72395. private _oneVector;
  72396. private _workingMatrix;
  72397. private updateCacheCalled;
  72398. private _correctPositionIfNotTrackPosition;
  72399. /**
  72400. * @hidden
  72401. * Updates the cached values of the camera
  72402. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72403. */
  72404. _updateCache(ignoreParentClass?: boolean): void;
  72405. /**
  72406. * @hidden
  72407. * Get current device position in babylon world
  72408. */
  72409. _computeDevicePosition(): void;
  72410. /**
  72411. * Updates the current device position and rotation in the babylon world
  72412. */
  72413. update(): void;
  72414. /**
  72415. * @hidden
  72416. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72417. * @returns an identity matrix
  72418. */
  72419. _getViewMatrix(): Matrix;
  72420. private _tmpMatrix;
  72421. /**
  72422. * This function is called by the two RIG cameras.
  72423. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72424. * @hidden
  72425. */
  72426. _getWebVRViewMatrix(): Matrix;
  72427. /** @hidden */
  72428. _getWebVRProjectionMatrix(): Matrix;
  72429. private _onGamepadConnectedObserver;
  72430. private _onGamepadDisconnectedObserver;
  72431. private _updateCacheWhenTrackingDisabledObserver;
  72432. /**
  72433. * Initializes the controllers and their meshes
  72434. */
  72435. initControllers(): void;
  72436. }
  72437. }
  72438. declare module BABYLON {
  72439. /**
  72440. * Size options for a post process
  72441. */
  72442. export type PostProcessOptions = {
  72443. width: number;
  72444. height: number;
  72445. };
  72446. /**
  72447. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72448. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72449. */
  72450. export class PostProcess {
  72451. /** Name of the PostProcess. */
  72452. name: string;
  72453. /**
  72454. * Gets or sets the unique id of the post process
  72455. */
  72456. uniqueId: number;
  72457. /**
  72458. * Width of the texture to apply the post process on
  72459. */
  72460. width: number;
  72461. /**
  72462. * Height of the texture to apply the post process on
  72463. */
  72464. height: number;
  72465. /**
  72466. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72467. * @hidden
  72468. */
  72469. _outputTexture: Nullable<InternalTexture>;
  72470. /**
  72471. * Sampling mode used by the shader
  72472. * See https://doc.babylonjs.com/classes/3.1/texture
  72473. */
  72474. renderTargetSamplingMode: number;
  72475. /**
  72476. * Clear color to use when screen clearing
  72477. */
  72478. clearColor: Color4;
  72479. /**
  72480. * If the buffer needs to be cleared before applying the post process. (default: true)
  72481. * Should be set to false if shader will overwrite all previous pixels.
  72482. */
  72483. autoClear: boolean;
  72484. /**
  72485. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72486. */
  72487. alphaMode: number;
  72488. /**
  72489. * Sets the setAlphaBlendConstants of the babylon engine
  72490. */
  72491. alphaConstants: Color4;
  72492. /**
  72493. * Animations to be used for the post processing
  72494. */
  72495. animations: Animation[];
  72496. /**
  72497. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72498. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72499. */
  72500. enablePixelPerfectMode: boolean;
  72501. /**
  72502. * Force the postprocess to be applied without taking in account viewport
  72503. */
  72504. forceFullscreenViewport: boolean;
  72505. /**
  72506. * List of inspectable custom properties (used by the Inspector)
  72507. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72508. */
  72509. inspectableCustomProperties: IInspectable[];
  72510. /**
  72511. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72512. *
  72513. * | Value | Type | Description |
  72514. * | ----- | ----------------------------------- | ----------- |
  72515. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72516. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72517. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72518. *
  72519. */
  72520. scaleMode: number;
  72521. /**
  72522. * Force textures to be a power of two (default: false)
  72523. */
  72524. alwaysForcePOT: boolean;
  72525. private _samples;
  72526. /**
  72527. * Number of sample textures (default: 1)
  72528. */
  72529. samples: number;
  72530. /**
  72531. * Modify the scale of the post process to be the same as the viewport (default: false)
  72532. */
  72533. adaptScaleToCurrentViewport: boolean;
  72534. private _camera;
  72535. private _scene;
  72536. private _engine;
  72537. private _options;
  72538. private _reusable;
  72539. private _textureType;
  72540. /**
  72541. * Smart array of input and output textures for the post process.
  72542. * @hidden
  72543. */
  72544. _textures: SmartArray<InternalTexture>;
  72545. /**
  72546. * The index in _textures that corresponds to the output texture.
  72547. * @hidden
  72548. */
  72549. _currentRenderTextureInd: number;
  72550. private _effect;
  72551. private _samplers;
  72552. private _fragmentUrl;
  72553. private _vertexUrl;
  72554. private _parameters;
  72555. private _scaleRatio;
  72556. protected _indexParameters: any;
  72557. private _shareOutputWithPostProcess;
  72558. private _texelSize;
  72559. private _forcedOutputTexture;
  72560. /**
  72561. * Returns the fragment url or shader name used in the post process.
  72562. * @returns the fragment url or name in the shader store.
  72563. */
  72564. getEffectName(): string;
  72565. /**
  72566. * An event triggered when the postprocess is activated.
  72567. */
  72568. onActivateObservable: Observable<Camera>;
  72569. private _onActivateObserver;
  72570. /**
  72571. * A function that is added to the onActivateObservable
  72572. */
  72573. onActivate: Nullable<(camera: Camera) => void>;
  72574. /**
  72575. * An event triggered when the postprocess changes its size.
  72576. */
  72577. onSizeChangedObservable: Observable<PostProcess>;
  72578. private _onSizeChangedObserver;
  72579. /**
  72580. * A function that is added to the onSizeChangedObservable
  72581. */
  72582. onSizeChanged: (postProcess: PostProcess) => void;
  72583. /**
  72584. * An event triggered when the postprocess applies its effect.
  72585. */
  72586. onApplyObservable: Observable<Effect>;
  72587. private _onApplyObserver;
  72588. /**
  72589. * A function that is added to the onApplyObservable
  72590. */
  72591. onApply: (effect: Effect) => void;
  72592. /**
  72593. * An event triggered before rendering the postprocess
  72594. */
  72595. onBeforeRenderObservable: Observable<Effect>;
  72596. private _onBeforeRenderObserver;
  72597. /**
  72598. * A function that is added to the onBeforeRenderObservable
  72599. */
  72600. onBeforeRender: (effect: Effect) => void;
  72601. /**
  72602. * An event triggered after rendering the postprocess
  72603. */
  72604. onAfterRenderObservable: Observable<Effect>;
  72605. private _onAfterRenderObserver;
  72606. /**
  72607. * A function that is added to the onAfterRenderObservable
  72608. */
  72609. onAfterRender: (efect: Effect) => void;
  72610. /**
  72611. * 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
  72612. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72613. */
  72614. inputTexture: InternalTexture;
  72615. /**
  72616. * Gets the camera which post process is applied to.
  72617. * @returns The camera the post process is applied to.
  72618. */
  72619. getCamera(): Camera;
  72620. /**
  72621. * Gets the texel size of the postprocess.
  72622. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72623. */
  72624. readonly texelSize: Vector2;
  72625. /**
  72626. * Creates a new instance PostProcess
  72627. * @param name The name of the PostProcess.
  72628. * @param fragmentUrl The url of the fragment shader to be used.
  72629. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72630. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72631. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72632. * @param camera The camera to apply the render pass to.
  72633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72634. * @param engine The engine which the post process will be applied. (default: current engine)
  72635. * @param reusable If the post process can be reused on the same frame. (default: false)
  72636. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72637. * @param textureType Type of textures used when performing the post process. (default: 0)
  72638. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72639. * @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
  72640. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72641. */
  72642. constructor(
  72643. /** Name of the PostProcess. */
  72644. 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);
  72645. /**
  72646. * Gets a string idenfifying the name of the class
  72647. * @returns "PostProcess" string
  72648. */
  72649. getClassName(): string;
  72650. /**
  72651. * Gets the engine which this post process belongs to.
  72652. * @returns The engine the post process was enabled with.
  72653. */
  72654. getEngine(): Engine;
  72655. /**
  72656. * The effect that is created when initializing the post process.
  72657. * @returns The created effect corrisponding the the postprocess.
  72658. */
  72659. getEffect(): Effect;
  72660. /**
  72661. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72662. * @param postProcess The post process to share the output with.
  72663. * @returns This post process.
  72664. */
  72665. shareOutputWith(postProcess: PostProcess): PostProcess;
  72666. /**
  72667. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72668. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72669. */
  72670. useOwnOutput(): void;
  72671. /**
  72672. * Updates the effect with the current post process compile time values and recompiles the shader.
  72673. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72674. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72675. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72676. * @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
  72677. * @param onCompiled Called when the shader has been compiled.
  72678. * @param onError Called if there is an error when compiling a shader.
  72679. */
  72680. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72681. /**
  72682. * The post process is reusable if it can be used multiple times within one frame.
  72683. * @returns If the post process is reusable
  72684. */
  72685. isReusable(): boolean;
  72686. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72687. markTextureDirty(): void;
  72688. /**
  72689. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72690. * 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.
  72691. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72692. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72693. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72694. * @returns The target texture that was bound to be written to.
  72695. */
  72696. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72697. /**
  72698. * If the post process is supported.
  72699. */
  72700. readonly isSupported: boolean;
  72701. /**
  72702. * The aspect ratio of the output texture.
  72703. */
  72704. readonly aspectRatio: number;
  72705. /**
  72706. * Get a value indicating if the post-process is ready to be used
  72707. * @returns true if the post-process is ready (shader is compiled)
  72708. */
  72709. isReady(): boolean;
  72710. /**
  72711. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72712. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72713. */
  72714. apply(): Nullable<Effect>;
  72715. private _disposeTextures;
  72716. /**
  72717. * Disposes the post process.
  72718. * @param camera The camera to dispose the post process on.
  72719. */
  72720. dispose(camera?: Camera): void;
  72721. }
  72722. }
  72723. declare module BABYLON {
  72724. /**
  72725. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72726. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72727. */
  72728. export class PostProcessManager {
  72729. private _scene;
  72730. private _indexBuffer;
  72731. private _vertexBuffers;
  72732. /**
  72733. * Creates a new instance PostProcess
  72734. * @param scene The scene that the post process is associated with.
  72735. */
  72736. constructor(scene: Scene);
  72737. private _prepareBuffers;
  72738. private _buildIndexBuffer;
  72739. /**
  72740. * Rebuilds the vertex buffers of the manager.
  72741. * @hidden
  72742. */
  72743. _rebuild(): void;
  72744. /**
  72745. * Prepares a frame to be run through a post process.
  72746. * @param sourceTexture The input texture to the post procesess. (default: null)
  72747. * @param postProcesses An array of post processes to be run. (default: null)
  72748. * @returns True if the post processes were able to be run.
  72749. * @hidden
  72750. */
  72751. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72752. /**
  72753. * Manually render a set of post processes to a texture.
  72754. * @param postProcesses An array of post processes to be run.
  72755. * @param targetTexture The target texture to render to.
  72756. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72757. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72758. * @param lodLevel defines which lod of the texture to render to
  72759. */
  72760. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72761. /**
  72762. * Finalize the result of the output of the postprocesses.
  72763. * @param doNotPresent If true the result will not be displayed to the screen.
  72764. * @param targetTexture The target texture to render to.
  72765. * @param faceIndex The index of the face to bind the target texture to.
  72766. * @param postProcesses The array of post processes to render.
  72767. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72768. * @hidden
  72769. */
  72770. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72771. /**
  72772. * Disposes of the post process manager.
  72773. */
  72774. dispose(): void;
  72775. }
  72776. }
  72777. declare module BABYLON {
  72778. interface AbstractScene {
  72779. /**
  72780. * The list of layers (background and foreground) of the scene
  72781. */
  72782. layers: Array<Layer>;
  72783. }
  72784. /**
  72785. * Defines the layer scene component responsible to manage any layers
  72786. * in a given scene.
  72787. */
  72788. export class LayerSceneComponent implements ISceneComponent {
  72789. /**
  72790. * The component name helpfull to identify the component in the list of scene components.
  72791. */
  72792. readonly name: string;
  72793. /**
  72794. * The scene the component belongs to.
  72795. */
  72796. scene: Scene;
  72797. private _engine;
  72798. /**
  72799. * Creates a new instance of the component for the given scene
  72800. * @param scene Defines the scene to register the component in
  72801. */
  72802. constructor(scene: Scene);
  72803. /**
  72804. * Registers the component in a given scene
  72805. */
  72806. register(): void;
  72807. /**
  72808. * Rebuilds the elements related to this component in case of
  72809. * context lost for instance.
  72810. */
  72811. rebuild(): void;
  72812. /**
  72813. * Disposes the component and the associated ressources.
  72814. */
  72815. dispose(): void;
  72816. private _draw;
  72817. private _drawCameraPredicate;
  72818. private _drawCameraBackground;
  72819. private _drawCameraForeground;
  72820. private _drawRenderTargetPredicate;
  72821. private _drawRenderTargetBackground;
  72822. private _drawRenderTargetForeground;
  72823. }
  72824. }
  72825. declare module BABYLON {
  72826. /** @hidden */
  72827. export var layerPixelShader: {
  72828. name: string;
  72829. shader: string;
  72830. };
  72831. }
  72832. declare module BABYLON {
  72833. /** @hidden */
  72834. export var layerVertexShader: {
  72835. name: string;
  72836. shader: string;
  72837. };
  72838. }
  72839. declare module BABYLON {
  72840. /**
  72841. * This represents a full screen 2d layer.
  72842. * This can be useful to display a picture in the background of your scene for instance.
  72843. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72844. */
  72845. export class Layer {
  72846. /**
  72847. * Define the name of the layer.
  72848. */
  72849. name: string;
  72850. /**
  72851. * Define the texture the layer should display.
  72852. */
  72853. texture: Nullable<Texture>;
  72854. /**
  72855. * Is the layer in background or foreground.
  72856. */
  72857. isBackground: boolean;
  72858. /**
  72859. * Define the color of the layer (instead of texture).
  72860. */
  72861. color: Color4;
  72862. /**
  72863. * Define the scale of the layer in order to zoom in out of the texture.
  72864. */
  72865. scale: Vector2;
  72866. /**
  72867. * Define an offset for the layer in order to shift the texture.
  72868. */
  72869. offset: Vector2;
  72870. /**
  72871. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72872. */
  72873. alphaBlendingMode: number;
  72874. /**
  72875. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72876. * Alpha test will not mix with the background color in case of transparency.
  72877. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72878. */
  72879. alphaTest: boolean;
  72880. /**
  72881. * Define a mask to restrict the layer to only some of the scene cameras.
  72882. */
  72883. layerMask: number;
  72884. /**
  72885. * Define the list of render target the layer is visible into.
  72886. */
  72887. renderTargetTextures: RenderTargetTexture[];
  72888. /**
  72889. * Define if the layer is only used in renderTarget or if it also
  72890. * renders in the main frame buffer of the canvas.
  72891. */
  72892. renderOnlyInRenderTargetTextures: boolean;
  72893. private _scene;
  72894. private _vertexBuffers;
  72895. private _indexBuffer;
  72896. private _effect;
  72897. private _alphaTestEffect;
  72898. /**
  72899. * An event triggered when the layer is disposed.
  72900. */
  72901. onDisposeObservable: Observable<Layer>;
  72902. private _onDisposeObserver;
  72903. /**
  72904. * Back compatibility with callback before the onDisposeObservable existed.
  72905. * The set callback will be triggered when the layer has been disposed.
  72906. */
  72907. onDispose: () => void;
  72908. /**
  72909. * An event triggered before rendering the scene
  72910. */
  72911. onBeforeRenderObservable: Observable<Layer>;
  72912. private _onBeforeRenderObserver;
  72913. /**
  72914. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72915. * The set callback will be triggered just before rendering the layer.
  72916. */
  72917. onBeforeRender: () => void;
  72918. /**
  72919. * An event triggered after rendering the scene
  72920. */
  72921. onAfterRenderObservable: Observable<Layer>;
  72922. private _onAfterRenderObserver;
  72923. /**
  72924. * Back compatibility with callback before the onAfterRenderObservable existed.
  72925. * The set callback will be triggered just after rendering the layer.
  72926. */
  72927. onAfterRender: () => void;
  72928. /**
  72929. * Instantiates a new layer.
  72930. * This represents a full screen 2d layer.
  72931. * This can be useful to display a picture in the background of your scene for instance.
  72932. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72933. * @param name Define the name of the layer in the scene
  72934. * @param imgUrl Define the url of the texture to display in the layer
  72935. * @param scene Define the scene the layer belongs to
  72936. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72937. * @param color Defines a color for the layer
  72938. */
  72939. constructor(
  72940. /**
  72941. * Define the name of the layer.
  72942. */
  72943. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72944. private _createIndexBuffer;
  72945. /** @hidden */
  72946. _rebuild(): void;
  72947. /**
  72948. * Renders the layer in the scene.
  72949. */
  72950. render(): void;
  72951. /**
  72952. * Disposes and releases the associated ressources.
  72953. */
  72954. dispose(): void;
  72955. }
  72956. }
  72957. declare module BABYLON {
  72958. interface AbstractScene {
  72959. /**
  72960. * The list of procedural textures added to the scene
  72961. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72962. */
  72963. proceduralTextures: Array<ProceduralTexture>;
  72964. }
  72965. /**
  72966. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72967. * in a given scene.
  72968. */
  72969. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72970. /**
  72971. * The component name helpfull to identify the component in the list of scene components.
  72972. */
  72973. readonly name: string;
  72974. /**
  72975. * The scene the component belongs to.
  72976. */
  72977. scene: Scene;
  72978. /**
  72979. * Creates a new instance of the component for the given scene
  72980. * @param scene Defines the scene to register the component in
  72981. */
  72982. constructor(scene: Scene);
  72983. /**
  72984. * Registers the component in a given scene
  72985. */
  72986. register(): void;
  72987. /**
  72988. * Rebuilds the elements related to this component in case of
  72989. * context lost for instance.
  72990. */
  72991. rebuild(): void;
  72992. /**
  72993. * Disposes the component and the associated ressources.
  72994. */
  72995. dispose(): void;
  72996. private _beforeClear;
  72997. }
  72998. }
  72999. declare module BABYLON {
  73000. /** @hidden */
  73001. export var proceduralVertexShader: {
  73002. name: string;
  73003. shader: string;
  73004. };
  73005. }
  73006. declare module BABYLON {
  73007. /**
  73008. * 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.
  73009. * This is the base class of any Procedural texture and contains most of the shareable code.
  73010. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73011. */
  73012. export class ProceduralTexture extends Texture {
  73013. isCube: boolean;
  73014. /**
  73015. * Define if the texture is enabled or not (disabled texture will not render)
  73016. */
  73017. isEnabled: boolean;
  73018. /**
  73019. * Define if the texture must be cleared before rendering (default is true)
  73020. */
  73021. autoClear: boolean;
  73022. /**
  73023. * Callback called when the texture is generated
  73024. */
  73025. onGenerated: () => void;
  73026. /**
  73027. * Event raised when the texture is generated
  73028. */
  73029. onGeneratedObservable: Observable<ProceduralTexture>;
  73030. /** @hidden */
  73031. _generateMipMaps: boolean;
  73032. /** @hidden **/
  73033. _effect: Effect;
  73034. /** @hidden */
  73035. _textures: {
  73036. [key: string]: Texture;
  73037. };
  73038. private _size;
  73039. private _currentRefreshId;
  73040. private _refreshRate;
  73041. private _vertexBuffers;
  73042. private _indexBuffer;
  73043. private _uniforms;
  73044. private _samplers;
  73045. private _fragment;
  73046. private _floats;
  73047. private _ints;
  73048. private _floatsArrays;
  73049. private _colors3;
  73050. private _colors4;
  73051. private _vectors2;
  73052. private _vectors3;
  73053. private _matrices;
  73054. private _fallbackTexture;
  73055. private _fallbackTextureUsed;
  73056. private _engine;
  73057. private _cachedDefines;
  73058. private _contentUpdateId;
  73059. private _contentData;
  73060. /**
  73061. * Instantiates a new procedural texture.
  73062. * 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.
  73063. * This is the base class of any Procedural texture and contains most of the shareable code.
  73064. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73065. * @param name Define the name of the texture
  73066. * @param size Define the size of the texture to create
  73067. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73068. * @param scene Define the scene the texture belongs to
  73069. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73070. * @param generateMipMaps Define if the texture should creates mip maps or not
  73071. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73072. */
  73073. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73074. /**
  73075. * The effect that is created when initializing the post process.
  73076. * @returns The created effect corrisponding the the postprocess.
  73077. */
  73078. getEffect(): Effect;
  73079. /**
  73080. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73081. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73082. */
  73083. getContent(): Nullable<ArrayBufferView>;
  73084. private _createIndexBuffer;
  73085. /** @hidden */
  73086. _rebuild(): void;
  73087. /**
  73088. * Resets the texture in order to recreate its associated resources.
  73089. * This can be called in case of context loss
  73090. */
  73091. reset(): void;
  73092. protected _getDefines(): string;
  73093. /**
  73094. * Is the texture ready to be used ? (rendered at least once)
  73095. * @returns true if ready, otherwise, false.
  73096. */
  73097. isReady(): boolean;
  73098. /**
  73099. * Resets the refresh counter of the texture and start bak from scratch.
  73100. * Could be useful to regenerate the texture if it is setup to render only once.
  73101. */
  73102. resetRefreshCounter(): void;
  73103. /**
  73104. * Set the fragment shader to use in order to render the texture.
  73105. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73106. */
  73107. setFragment(fragment: any): void;
  73108. /**
  73109. * Define the refresh rate of the texture or the rendering frequency.
  73110. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73111. */
  73112. refreshRate: number;
  73113. /** @hidden */
  73114. _shouldRender(): boolean;
  73115. /**
  73116. * Get the size the texture is rendering at.
  73117. * @returns the size (texture is always squared)
  73118. */
  73119. getRenderSize(): number;
  73120. /**
  73121. * Resize the texture to new value.
  73122. * @param size Define the new size the texture should have
  73123. * @param generateMipMaps Define whether the new texture should create mip maps
  73124. */
  73125. resize(size: number, generateMipMaps: boolean): void;
  73126. private _checkUniform;
  73127. /**
  73128. * Set a texture in the shader program used to render.
  73129. * @param name Define the name of the uniform samplers as defined in the shader
  73130. * @param texture Define the texture to bind to this sampler
  73131. * @return the texture itself allowing "fluent" like uniform updates
  73132. */
  73133. setTexture(name: string, texture: Texture): ProceduralTexture;
  73134. /**
  73135. * Set a float in the shader.
  73136. * @param name Define the name of the uniform as defined in the shader
  73137. * @param value Define the value to give to the uniform
  73138. * @return the texture itself allowing "fluent" like uniform updates
  73139. */
  73140. setFloat(name: string, value: number): ProceduralTexture;
  73141. /**
  73142. * Set a int in the shader.
  73143. * @param name Define the name of the uniform as defined in the shader
  73144. * @param value Define the value to give to the uniform
  73145. * @return the texture itself allowing "fluent" like uniform updates
  73146. */
  73147. setInt(name: string, value: number): ProceduralTexture;
  73148. /**
  73149. * Set an array of floats in the shader.
  73150. * @param name Define the name of the uniform as defined in the shader
  73151. * @param value Define the value to give to the uniform
  73152. * @return the texture itself allowing "fluent" like uniform updates
  73153. */
  73154. setFloats(name: string, value: number[]): ProceduralTexture;
  73155. /**
  73156. * Set a vec3 in the shader from a Color3.
  73157. * @param name Define the name of the uniform as defined in the shader
  73158. * @param value Define the value to give to the uniform
  73159. * @return the texture itself allowing "fluent" like uniform updates
  73160. */
  73161. setColor3(name: string, value: Color3): ProceduralTexture;
  73162. /**
  73163. * Set a vec4 in the shader from a Color4.
  73164. * @param name Define the name of the uniform as defined in the shader
  73165. * @param value Define the value to give to the uniform
  73166. * @return the texture itself allowing "fluent" like uniform updates
  73167. */
  73168. setColor4(name: string, value: Color4): ProceduralTexture;
  73169. /**
  73170. * Set a vec2 in the shader from a Vector2.
  73171. * @param name Define the name of the uniform as defined in the shader
  73172. * @param value Define the value to give to the uniform
  73173. * @return the texture itself allowing "fluent" like uniform updates
  73174. */
  73175. setVector2(name: string, value: Vector2): ProceduralTexture;
  73176. /**
  73177. * Set a vec3 in the shader from a Vector3.
  73178. * @param name Define the name of the uniform as defined in the shader
  73179. * @param value Define the value to give to the uniform
  73180. * @return the texture itself allowing "fluent" like uniform updates
  73181. */
  73182. setVector3(name: string, value: Vector3): ProceduralTexture;
  73183. /**
  73184. * Set a mat4 in the shader from a MAtrix.
  73185. * @param name Define the name of the uniform as defined in the shader
  73186. * @param value Define the value to give to the uniform
  73187. * @return the texture itself allowing "fluent" like uniform updates
  73188. */
  73189. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73190. /**
  73191. * Render the texture to its associated render target.
  73192. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73193. */
  73194. render(useCameraPostProcess?: boolean): void;
  73195. /**
  73196. * Clone the texture.
  73197. * @returns the cloned texture
  73198. */
  73199. clone(): ProceduralTexture;
  73200. /**
  73201. * Dispose the texture and release its asoociated resources.
  73202. */
  73203. dispose(): void;
  73204. }
  73205. }
  73206. declare module BABYLON {
  73207. /**
  73208. * This represents the base class for particle system in Babylon.
  73209. * 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.
  73210. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73211. * @example https://doc.babylonjs.com/babylon101/particles
  73212. */
  73213. export class BaseParticleSystem {
  73214. /**
  73215. * Source color is added to the destination color without alpha affecting the result
  73216. */
  73217. static BLENDMODE_ONEONE: number;
  73218. /**
  73219. * Blend current color and particle color using particle’s alpha
  73220. */
  73221. static BLENDMODE_STANDARD: number;
  73222. /**
  73223. * Add current color and particle color multiplied by particle’s alpha
  73224. */
  73225. static BLENDMODE_ADD: number;
  73226. /**
  73227. * Multiply current color with particle color
  73228. */
  73229. static BLENDMODE_MULTIPLY: number;
  73230. /**
  73231. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73232. */
  73233. static BLENDMODE_MULTIPLYADD: number;
  73234. /**
  73235. * List of animations used by the particle system.
  73236. */
  73237. animations: Animation[];
  73238. /**
  73239. * The id of the Particle system.
  73240. */
  73241. id: string;
  73242. /**
  73243. * The friendly name of the Particle system.
  73244. */
  73245. name: string;
  73246. /**
  73247. * The rendering group used by the Particle system to chose when to render.
  73248. */
  73249. renderingGroupId: number;
  73250. /**
  73251. * The emitter represents the Mesh or position we are attaching the particle system to.
  73252. */
  73253. emitter: Nullable<AbstractMesh | Vector3>;
  73254. /**
  73255. * The maximum number of particles to emit per frame
  73256. */
  73257. emitRate: number;
  73258. /**
  73259. * If you want to launch only a few particles at once, that can be done, as well.
  73260. */
  73261. manualEmitCount: number;
  73262. /**
  73263. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73264. */
  73265. updateSpeed: number;
  73266. /**
  73267. * The amount of time the particle system is running (depends of the overall update speed).
  73268. */
  73269. targetStopDuration: number;
  73270. /**
  73271. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73272. */
  73273. disposeOnStop: boolean;
  73274. /**
  73275. * Minimum power of emitting particles.
  73276. */
  73277. minEmitPower: number;
  73278. /**
  73279. * Maximum power of emitting particles.
  73280. */
  73281. maxEmitPower: number;
  73282. /**
  73283. * Minimum life time of emitting particles.
  73284. */
  73285. minLifeTime: number;
  73286. /**
  73287. * Maximum life time of emitting particles.
  73288. */
  73289. maxLifeTime: number;
  73290. /**
  73291. * Minimum Size of emitting particles.
  73292. */
  73293. minSize: number;
  73294. /**
  73295. * Maximum Size of emitting particles.
  73296. */
  73297. maxSize: number;
  73298. /**
  73299. * Minimum scale of emitting particles on X axis.
  73300. */
  73301. minScaleX: number;
  73302. /**
  73303. * Maximum scale of emitting particles on X axis.
  73304. */
  73305. maxScaleX: number;
  73306. /**
  73307. * Minimum scale of emitting particles on Y axis.
  73308. */
  73309. minScaleY: number;
  73310. /**
  73311. * Maximum scale of emitting particles on Y axis.
  73312. */
  73313. maxScaleY: number;
  73314. /**
  73315. * Gets or sets the minimal initial rotation in radians.
  73316. */
  73317. minInitialRotation: number;
  73318. /**
  73319. * Gets or sets the maximal initial rotation in radians.
  73320. */
  73321. maxInitialRotation: number;
  73322. /**
  73323. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73324. */
  73325. minAngularSpeed: number;
  73326. /**
  73327. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73328. */
  73329. maxAngularSpeed: number;
  73330. /**
  73331. * The texture used to render each particle. (this can be a spritesheet)
  73332. */
  73333. particleTexture: Nullable<Texture>;
  73334. /**
  73335. * The layer mask we are rendering the particles through.
  73336. */
  73337. layerMask: number;
  73338. /**
  73339. * This can help using your own shader to render the particle system.
  73340. * The according effect will be created
  73341. */
  73342. customShader: any;
  73343. /**
  73344. * By default particle system starts as soon as they are created. This prevents the
  73345. * automatic start to happen and let you decide when to start emitting particles.
  73346. */
  73347. preventAutoStart: boolean;
  73348. private _noiseTexture;
  73349. /**
  73350. * Gets or sets a texture used to add random noise to particle positions
  73351. */
  73352. noiseTexture: Nullable<ProceduralTexture>;
  73353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73354. noiseStrength: Vector3;
  73355. /**
  73356. * Callback triggered when the particle animation is ending.
  73357. */
  73358. onAnimationEnd: Nullable<() => void>;
  73359. /**
  73360. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73361. */
  73362. blendMode: number;
  73363. /**
  73364. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73365. * to override the particles.
  73366. */
  73367. forceDepthWrite: boolean;
  73368. /** 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 */
  73369. preWarmCycles: number;
  73370. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73371. preWarmStepOffset: number;
  73372. /**
  73373. * 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)
  73374. */
  73375. spriteCellChangeSpeed: number;
  73376. /**
  73377. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73378. */
  73379. startSpriteCellID: number;
  73380. /**
  73381. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73382. */
  73383. endSpriteCellID: number;
  73384. /**
  73385. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73386. */
  73387. spriteCellWidth: number;
  73388. /**
  73389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73390. */
  73391. spriteCellHeight: number;
  73392. /**
  73393. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73394. */
  73395. spriteRandomStartCell: boolean;
  73396. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73397. translationPivot: Vector2;
  73398. /** @hidden */
  73399. protected _isAnimationSheetEnabled: boolean;
  73400. /**
  73401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73402. */
  73403. beginAnimationOnStart: boolean;
  73404. /**
  73405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73406. */
  73407. beginAnimationFrom: number;
  73408. /**
  73409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73410. */
  73411. beginAnimationTo: number;
  73412. /**
  73413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73414. */
  73415. beginAnimationLoop: boolean;
  73416. /**
  73417. * Gets or sets a world offset applied to all particles
  73418. */
  73419. worldOffset: Vector3;
  73420. /**
  73421. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73422. */
  73423. isAnimationSheetEnabled: boolean;
  73424. /**
  73425. * Get hosting scene
  73426. * @returns the scene
  73427. */
  73428. getScene(): Scene;
  73429. /**
  73430. * You can use gravity if you want to give an orientation to your particles.
  73431. */
  73432. gravity: Vector3;
  73433. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73434. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73435. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73436. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73437. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73438. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73439. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73440. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73441. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73442. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73443. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73444. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73445. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73446. /**
  73447. * Defines the delay in milliseconds before starting the system (0 by default)
  73448. */
  73449. startDelay: number;
  73450. /**
  73451. * Gets the current list of drag gradients.
  73452. * You must use addDragGradient and removeDragGradient to udpate this list
  73453. * @returns the list of drag gradients
  73454. */
  73455. getDragGradients(): Nullable<Array<FactorGradient>>;
  73456. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73457. limitVelocityDamping: number;
  73458. /**
  73459. * Gets the current list of limit velocity gradients.
  73460. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73461. * @returns the list of limit velocity gradients
  73462. */
  73463. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73464. /**
  73465. * Gets the current list of color gradients.
  73466. * You must use addColorGradient and removeColorGradient to udpate this list
  73467. * @returns the list of color gradients
  73468. */
  73469. getColorGradients(): Nullable<Array<ColorGradient>>;
  73470. /**
  73471. * Gets the current list of size gradients.
  73472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73473. * @returns the list of size gradients
  73474. */
  73475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73476. /**
  73477. * Gets the current list of color remap gradients.
  73478. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73479. * @returns the list of color remap gradients
  73480. */
  73481. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73482. /**
  73483. * Gets the current list of alpha remap gradients.
  73484. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73485. * @returns the list of alpha remap gradients
  73486. */
  73487. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73488. /**
  73489. * Gets the current list of life time gradients.
  73490. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73491. * @returns the list of life time gradients
  73492. */
  73493. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73494. /**
  73495. * Gets the current list of angular speed gradients.
  73496. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73497. * @returns the list of angular speed gradients
  73498. */
  73499. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73500. /**
  73501. * Gets the current list of velocity gradients.
  73502. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73503. * @returns the list of velocity gradients
  73504. */
  73505. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73506. /**
  73507. * Gets the current list of start size gradients.
  73508. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73509. * @returns the list of start size gradients
  73510. */
  73511. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73512. /**
  73513. * Gets the current list of emit rate gradients.
  73514. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73515. * @returns the list of emit rate gradients
  73516. */
  73517. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73518. /**
  73519. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73520. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73521. */
  73522. direction1: Vector3;
  73523. /**
  73524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73526. */
  73527. direction2: Vector3;
  73528. /**
  73529. * 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.
  73530. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73531. */
  73532. minEmitBox: Vector3;
  73533. /**
  73534. * 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.
  73535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73536. */
  73537. maxEmitBox: Vector3;
  73538. /**
  73539. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73540. */
  73541. color1: Color4;
  73542. /**
  73543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73544. */
  73545. color2: Color4;
  73546. /**
  73547. * Color the particle will have at the end of its lifetime
  73548. */
  73549. colorDead: Color4;
  73550. /**
  73551. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73552. */
  73553. textureMask: Color4;
  73554. /**
  73555. * The particle emitter type defines the emitter used by the particle system.
  73556. * It can be for example box, sphere, or cone...
  73557. */
  73558. particleEmitterType: IParticleEmitterType;
  73559. /** @hidden */
  73560. _isSubEmitter: boolean;
  73561. /**
  73562. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73563. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73564. */
  73565. billboardMode: number;
  73566. protected _isBillboardBased: boolean;
  73567. /**
  73568. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73569. */
  73570. isBillboardBased: boolean;
  73571. /**
  73572. * The scene the particle system belongs to.
  73573. */
  73574. protected _scene: Scene;
  73575. /**
  73576. * Local cache of defines for image processing.
  73577. */
  73578. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73579. /**
  73580. * Default configuration related to image processing available in the standard Material.
  73581. */
  73582. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73583. /**
  73584. * Gets the image processing configuration used either in this material.
  73585. */
  73586. /**
  73587. * Sets the Default image processing configuration used either in the this material.
  73588. *
  73589. * If sets to null, the scene one is in use.
  73590. */
  73591. imageProcessingConfiguration: ImageProcessingConfiguration;
  73592. /**
  73593. * Attaches a new image processing configuration to the Standard Material.
  73594. * @param configuration
  73595. */
  73596. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73597. /** @hidden */
  73598. protected _reset(): void;
  73599. /** @hidden */
  73600. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73601. /**
  73602. * Instantiates a particle system.
  73603. * 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.
  73604. * @param name The name of the particle system
  73605. */
  73606. constructor(name: string);
  73607. /**
  73608. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73611. * @returns the emitter
  73612. */
  73613. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73614. /**
  73615. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73616. * @param radius The radius of the hemisphere to emit from
  73617. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73618. * @returns the emitter
  73619. */
  73620. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73621. /**
  73622. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73623. * @param radius The radius of the sphere to emit from
  73624. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73625. * @returns the emitter
  73626. */
  73627. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73628. /**
  73629. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73630. * @param radius The radius of the sphere to emit from
  73631. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73632. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73633. * @returns the emitter
  73634. */
  73635. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73636. /**
  73637. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73638. * @param radius The radius of the emission cylinder
  73639. * @param height The height of the emission cylinder
  73640. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73641. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73642. * @returns the emitter
  73643. */
  73644. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73645. /**
  73646. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73647. * @param radius The radius of the cylinder to emit from
  73648. * @param height The height of the emission cylinder
  73649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73652. * @returns the emitter
  73653. */
  73654. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73655. /**
  73656. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73657. * @param radius The radius of the cone to emit from
  73658. * @param angle The base angle of the cone
  73659. * @returns the emitter
  73660. */
  73661. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73662. /**
  73663. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73666. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73667. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73668. * @returns the emitter
  73669. */
  73670. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73671. }
  73672. }
  73673. declare module BABYLON {
  73674. /**
  73675. * Type of sub emitter
  73676. */
  73677. export enum SubEmitterType {
  73678. /**
  73679. * Attached to the particle over it's lifetime
  73680. */
  73681. ATTACHED = 0,
  73682. /**
  73683. * Created when the particle dies
  73684. */
  73685. END = 1
  73686. }
  73687. /**
  73688. * Sub emitter class used to emit particles from an existing particle
  73689. */
  73690. export class SubEmitter {
  73691. /**
  73692. * the particle system to be used by the sub emitter
  73693. */
  73694. particleSystem: ParticleSystem;
  73695. /**
  73696. * Type of the submitter (Default: END)
  73697. */
  73698. type: SubEmitterType;
  73699. /**
  73700. * 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)
  73701. * Note: This only is supported when using an emitter of type Mesh
  73702. */
  73703. inheritDirection: boolean;
  73704. /**
  73705. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73706. */
  73707. inheritedVelocityAmount: number;
  73708. /**
  73709. * Creates a sub emitter
  73710. * @param particleSystem the particle system to be used by the sub emitter
  73711. */
  73712. constructor(
  73713. /**
  73714. * the particle system to be used by the sub emitter
  73715. */
  73716. particleSystem: ParticleSystem);
  73717. /**
  73718. * Clones the sub emitter
  73719. * @returns the cloned sub emitter
  73720. */
  73721. clone(): SubEmitter;
  73722. /**
  73723. * Serialize current object to a JSON object
  73724. * @returns the serialized object
  73725. */
  73726. serialize(): any;
  73727. /** @hidden */
  73728. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73729. /**
  73730. * Creates a new SubEmitter from a serialized JSON version
  73731. * @param serializationObject defines the JSON object to read from
  73732. * @param scene defines the hosting scene
  73733. * @param rootUrl defines the rootUrl for data loading
  73734. * @returns a new SubEmitter
  73735. */
  73736. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73737. /** Release associated resources */
  73738. dispose(): void;
  73739. }
  73740. }
  73741. declare module BABYLON {
  73742. /** @hidden */
  73743. export var clipPlaneFragmentDeclaration: {
  73744. name: string;
  73745. shader: string;
  73746. };
  73747. }
  73748. declare module BABYLON {
  73749. /** @hidden */
  73750. export var imageProcessingDeclaration: {
  73751. name: string;
  73752. shader: string;
  73753. };
  73754. }
  73755. declare module BABYLON {
  73756. /** @hidden */
  73757. export var imageProcessingFunctions: {
  73758. name: string;
  73759. shader: string;
  73760. };
  73761. }
  73762. declare module BABYLON {
  73763. /** @hidden */
  73764. export var clipPlaneFragment: {
  73765. name: string;
  73766. shader: string;
  73767. };
  73768. }
  73769. declare module BABYLON {
  73770. /** @hidden */
  73771. export var particlesPixelShader: {
  73772. name: string;
  73773. shader: string;
  73774. };
  73775. }
  73776. declare module BABYLON {
  73777. /** @hidden */
  73778. export var clipPlaneVertexDeclaration: {
  73779. name: string;
  73780. shader: string;
  73781. };
  73782. }
  73783. declare module BABYLON {
  73784. /** @hidden */
  73785. export var clipPlaneVertex: {
  73786. name: string;
  73787. shader: string;
  73788. };
  73789. }
  73790. declare module BABYLON {
  73791. /** @hidden */
  73792. export var particlesVertexShader: {
  73793. name: string;
  73794. shader: string;
  73795. };
  73796. }
  73797. declare module BABYLON {
  73798. /**
  73799. * This represents a particle system in Babylon.
  73800. * 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.
  73801. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73802. * @example https://doc.babylonjs.com/babylon101/particles
  73803. */
  73804. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73805. /**
  73806. * Billboard mode will only apply to Y axis
  73807. */
  73808. static readonly BILLBOARDMODE_Y: number;
  73809. /**
  73810. * Billboard mode will apply to all axes
  73811. */
  73812. static readonly BILLBOARDMODE_ALL: number;
  73813. /**
  73814. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73815. */
  73816. static readonly BILLBOARDMODE_STRETCHED: number;
  73817. /**
  73818. * This function can be defined to provide custom update for active particles.
  73819. * This function will be called instead of regular update (age, position, color, etc.).
  73820. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73821. */
  73822. updateFunction: (particles: Particle[]) => void;
  73823. private _emitterWorldMatrix;
  73824. /**
  73825. * This function can be defined to specify initial direction for every new particle.
  73826. * It by default use the emitterType defined function
  73827. */
  73828. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73829. /**
  73830. * This function can be defined to specify initial position for every new particle.
  73831. * It by default use the emitterType defined function
  73832. */
  73833. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73834. /**
  73835. * @hidden
  73836. */
  73837. _inheritedVelocityOffset: Vector3;
  73838. /**
  73839. * An event triggered when the system is disposed
  73840. */
  73841. onDisposeObservable: Observable<ParticleSystem>;
  73842. private _onDisposeObserver;
  73843. /**
  73844. * Sets a callback that will be triggered when the system is disposed
  73845. */
  73846. onDispose: () => void;
  73847. private _particles;
  73848. private _epsilon;
  73849. private _capacity;
  73850. private _stockParticles;
  73851. private _newPartsExcess;
  73852. private _vertexData;
  73853. private _vertexBuffer;
  73854. private _vertexBuffers;
  73855. private _spriteBuffer;
  73856. private _indexBuffer;
  73857. private _effect;
  73858. private _customEffect;
  73859. private _cachedDefines;
  73860. private _scaledColorStep;
  73861. private _colorDiff;
  73862. private _scaledDirection;
  73863. private _scaledGravity;
  73864. private _currentRenderId;
  73865. private _alive;
  73866. private _useInstancing;
  73867. private _started;
  73868. private _stopped;
  73869. private _actualFrame;
  73870. private _scaledUpdateSpeed;
  73871. private _vertexBufferSize;
  73872. /** @hidden */
  73873. _currentEmitRateGradient: Nullable<FactorGradient>;
  73874. /** @hidden */
  73875. _currentEmitRate1: number;
  73876. /** @hidden */
  73877. _currentEmitRate2: number;
  73878. /** @hidden */
  73879. _currentStartSizeGradient: Nullable<FactorGradient>;
  73880. /** @hidden */
  73881. _currentStartSize1: number;
  73882. /** @hidden */
  73883. _currentStartSize2: number;
  73884. private readonly _rawTextureWidth;
  73885. private _rampGradientsTexture;
  73886. private _useRampGradients;
  73887. /** Gets or sets a boolean indicating that ramp gradients must be used
  73888. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73889. */
  73890. useRampGradients: boolean;
  73891. /**
  73892. * 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.
  73893. * 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: [])
  73894. */
  73895. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73896. private _subEmitters;
  73897. /**
  73898. * @hidden
  73899. * If the particle systems emitter should be disposed when the particle system is disposed
  73900. */
  73901. _disposeEmitterOnDispose: boolean;
  73902. /**
  73903. * The current active Sub-systems, this property is used by the root particle system only.
  73904. */
  73905. activeSubSystems: Array<ParticleSystem>;
  73906. private _rootParticleSystem;
  73907. /**
  73908. * Gets the current list of active particles
  73909. */
  73910. readonly particles: Particle[];
  73911. /**
  73912. * Returns the string "ParticleSystem"
  73913. * @returns a string containing the class name
  73914. */
  73915. getClassName(): string;
  73916. /**
  73917. * Instantiates a particle system.
  73918. * 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.
  73919. * @param name The name of the particle system
  73920. * @param capacity The max number of particles alive at the same time
  73921. * @param scene The scene the particle system belongs to
  73922. * @param customEffect a custom effect used to change the way particles are rendered by default
  73923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73924. * @param epsilon Offset used to render the particles
  73925. */
  73926. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73927. private _addFactorGradient;
  73928. private _removeFactorGradient;
  73929. /**
  73930. * Adds a new life time gradient
  73931. * @param gradient defines the gradient to use (between 0 and 1)
  73932. * @param factor defines the life time factor to affect to the specified gradient
  73933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73934. * @returns the current particle system
  73935. */
  73936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73937. /**
  73938. * Remove a specific life time gradient
  73939. * @param gradient defines the gradient to remove
  73940. * @returns the current particle system
  73941. */
  73942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73943. /**
  73944. * Adds a new size gradient
  73945. * @param gradient defines the gradient to use (between 0 and 1)
  73946. * @param factor defines the size factor to affect to the specified gradient
  73947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73948. * @returns the current particle system
  73949. */
  73950. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73951. /**
  73952. * Remove a specific size gradient
  73953. * @param gradient defines the gradient to remove
  73954. * @returns the current particle system
  73955. */
  73956. removeSizeGradient(gradient: number): IParticleSystem;
  73957. /**
  73958. * Adds a new color remap gradient
  73959. * @param gradient defines the gradient to use (between 0 and 1)
  73960. * @param min defines the color remap minimal range
  73961. * @param max defines the color remap maximal range
  73962. * @returns the current particle system
  73963. */
  73964. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73965. /**
  73966. * Remove a specific color remap gradient
  73967. * @param gradient defines the gradient to remove
  73968. * @returns the current particle system
  73969. */
  73970. removeColorRemapGradient(gradient: number): IParticleSystem;
  73971. /**
  73972. * Adds a new alpha remap gradient
  73973. * @param gradient defines the gradient to use (between 0 and 1)
  73974. * @param min defines the alpha remap minimal range
  73975. * @param max defines the alpha remap maximal range
  73976. * @returns the current particle system
  73977. */
  73978. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73979. /**
  73980. * Remove a specific alpha remap gradient
  73981. * @param gradient defines the gradient to remove
  73982. * @returns the current particle system
  73983. */
  73984. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73985. /**
  73986. * Adds a new angular speed gradient
  73987. * @param gradient defines the gradient to use (between 0 and 1)
  73988. * @param factor defines the angular speed to affect to the specified gradient
  73989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73990. * @returns the current particle system
  73991. */
  73992. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73993. /**
  73994. * Remove a specific angular speed gradient
  73995. * @param gradient defines the gradient to remove
  73996. * @returns the current particle system
  73997. */
  73998. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73999. /**
  74000. * Adds a new velocity gradient
  74001. * @param gradient defines the gradient to use (between 0 and 1)
  74002. * @param factor defines the velocity to affect to the specified gradient
  74003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74004. * @returns the current particle system
  74005. */
  74006. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74007. /**
  74008. * Remove a specific velocity gradient
  74009. * @param gradient defines the gradient to remove
  74010. * @returns the current particle system
  74011. */
  74012. removeVelocityGradient(gradient: number): IParticleSystem;
  74013. /**
  74014. * Adds a new limit velocity gradient
  74015. * @param gradient defines the gradient to use (between 0 and 1)
  74016. * @param factor defines the limit velocity value to affect to the specified gradient
  74017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74018. * @returns the current particle system
  74019. */
  74020. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74021. /**
  74022. * Remove a specific limit velocity gradient
  74023. * @param gradient defines the gradient to remove
  74024. * @returns the current particle system
  74025. */
  74026. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74027. /**
  74028. * Adds a new drag gradient
  74029. * @param gradient defines the gradient to use (between 0 and 1)
  74030. * @param factor defines the drag value to affect to the specified gradient
  74031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74032. * @returns the current particle system
  74033. */
  74034. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74035. /**
  74036. * Remove a specific drag gradient
  74037. * @param gradient defines the gradient to remove
  74038. * @returns the current particle system
  74039. */
  74040. removeDragGradient(gradient: number): IParticleSystem;
  74041. /**
  74042. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74043. * @param gradient defines the gradient to use (between 0 and 1)
  74044. * @param factor defines the emit rate value to affect to the specified gradient
  74045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74046. * @returns the current particle system
  74047. */
  74048. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74049. /**
  74050. * Remove a specific emit rate gradient
  74051. * @param gradient defines the gradient to remove
  74052. * @returns the current particle system
  74053. */
  74054. removeEmitRateGradient(gradient: number): IParticleSystem;
  74055. /**
  74056. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74057. * @param gradient defines the gradient to use (between 0 and 1)
  74058. * @param factor defines the start size value to affect to the specified gradient
  74059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74060. * @returns the current particle system
  74061. */
  74062. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74063. /**
  74064. * Remove a specific start size gradient
  74065. * @param gradient defines the gradient to remove
  74066. * @returns the current particle system
  74067. */
  74068. removeStartSizeGradient(gradient: number): IParticleSystem;
  74069. private _createRampGradientTexture;
  74070. /**
  74071. * Gets the current list of ramp gradients.
  74072. * You must use addRampGradient and removeRampGradient to udpate this list
  74073. * @returns the list of ramp gradients
  74074. */
  74075. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74076. /**
  74077. * Adds a new ramp gradient used to remap particle colors
  74078. * @param gradient defines the gradient to use (between 0 and 1)
  74079. * @param color defines the color to affect to the specified gradient
  74080. * @returns the current particle system
  74081. */
  74082. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74083. /**
  74084. * Remove a specific ramp gradient
  74085. * @param gradient defines the gradient to remove
  74086. * @returns the current particle system
  74087. */
  74088. removeRampGradient(gradient: number): ParticleSystem;
  74089. /**
  74090. * Adds a new color gradient
  74091. * @param gradient defines the gradient to use (between 0 and 1)
  74092. * @param color1 defines the color to affect to the specified gradient
  74093. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74094. * @returns this particle system
  74095. */
  74096. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74097. /**
  74098. * Remove a specific color gradient
  74099. * @param gradient defines the gradient to remove
  74100. * @returns this particle system
  74101. */
  74102. removeColorGradient(gradient: number): IParticleSystem;
  74103. private _fetchR;
  74104. protected _reset(): void;
  74105. private _resetEffect;
  74106. private _createVertexBuffers;
  74107. private _createIndexBuffer;
  74108. /**
  74109. * Gets the maximum number of particles active at the same time.
  74110. * @returns The max number of active particles.
  74111. */
  74112. getCapacity(): number;
  74113. /**
  74114. * Gets whether there are still active particles in the system.
  74115. * @returns True if it is alive, otherwise false.
  74116. */
  74117. isAlive(): boolean;
  74118. /**
  74119. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74120. * @returns True if it has been started, otherwise false.
  74121. */
  74122. isStarted(): boolean;
  74123. private _prepareSubEmitterInternalArray;
  74124. /**
  74125. * Starts the particle system and begins to emit
  74126. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74127. */
  74128. start(delay?: number): void;
  74129. /**
  74130. * Stops the particle system.
  74131. * @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.
  74132. */
  74133. stop(stopSubEmitters?: boolean): void;
  74134. /**
  74135. * Remove all active particles
  74136. */
  74137. reset(): void;
  74138. /**
  74139. * @hidden (for internal use only)
  74140. */
  74141. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74142. /**
  74143. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74144. * Its lifetime will start back at 0.
  74145. */
  74146. recycleParticle: (particle: Particle) => void;
  74147. private _stopSubEmitters;
  74148. private _createParticle;
  74149. private _removeFromRoot;
  74150. private _emitFromParticle;
  74151. private _update;
  74152. /** @hidden */
  74153. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74154. /** @hidden */
  74155. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74156. /** @hidden */
  74157. private _getEffect;
  74158. /**
  74159. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74160. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74161. */
  74162. animate(preWarmOnly?: boolean): void;
  74163. private _appendParticleVertices;
  74164. /**
  74165. * Rebuilds the particle system.
  74166. */
  74167. rebuild(): void;
  74168. /**
  74169. * Is this system ready to be used/rendered
  74170. * @return true if the system is ready
  74171. */
  74172. isReady(): boolean;
  74173. private _render;
  74174. /**
  74175. * Renders the particle system in its current state.
  74176. * @returns the current number of particles
  74177. */
  74178. render(): number;
  74179. /**
  74180. * Disposes the particle system and free the associated resources
  74181. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74182. */
  74183. dispose(disposeTexture?: boolean): void;
  74184. /**
  74185. * Clones the particle system.
  74186. * @param name The name of the cloned object
  74187. * @param newEmitter The new emitter to use
  74188. * @returns the cloned particle system
  74189. */
  74190. clone(name: string, newEmitter: any): ParticleSystem;
  74191. /**
  74192. * Serializes the particle system to a JSON object.
  74193. * @returns the JSON object
  74194. */
  74195. serialize(): any;
  74196. /** @hidden */
  74197. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74198. /** @hidden */
  74199. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74200. /**
  74201. * Parses a JSON object to create a particle system.
  74202. * @param parsedParticleSystem The JSON object to parse
  74203. * @param scene The scene to create the particle system in
  74204. * @param rootUrl The root url to use to load external dependencies like texture
  74205. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74206. * @returns the Parsed particle system
  74207. */
  74208. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74209. }
  74210. }
  74211. declare module BABYLON {
  74212. /**
  74213. * A particle represents one of the element emitted by a particle system.
  74214. * This is mainly define by its coordinates, direction, velocity and age.
  74215. */
  74216. export class Particle {
  74217. /**
  74218. * The particle system the particle belongs to.
  74219. */
  74220. particleSystem: ParticleSystem;
  74221. private static _Count;
  74222. /**
  74223. * Unique ID of the particle
  74224. */
  74225. id: number;
  74226. /**
  74227. * The world position of the particle in the scene.
  74228. */
  74229. position: Vector3;
  74230. /**
  74231. * The world direction of the particle in the scene.
  74232. */
  74233. direction: Vector3;
  74234. /**
  74235. * The color of the particle.
  74236. */
  74237. color: Color4;
  74238. /**
  74239. * The color change of the particle per step.
  74240. */
  74241. colorStep: Color4;
  74242. /**
  74243. * Defines how long will the life of the particle be.
  74244. */
  74245. lifeTime: number;
  74246. /**
  74247. * The current age of the particle.
  74248. */
  74249. age: number;
  74250. /**
  74251. * The current size of the particle.
  74252. */
  74253. size: number;
  74254. /**
  74255. * The current scale of the particle.
  74256. */
  74257. scale: Vector2;
  74258. /**
  74259. * The current angle of the particle.
  74260. */
  74261. angle: number;
  74262. /**
  74263. * Defines how fast is the angle changing.
  74264. */
  74265. angularSpeed: number;
  74266. /**
  74267. * Defines the cell index used by the particle to be rendered from a sprite.
  74268. */
  74269. cellIndex: number;
  74270. /**
  74271. * The information required to support color remapping
  74272. */
  74273. remapData: Vector4;
  74274. /** @hidden */
  74275. _randomCellOffset?: number;
  74276. /** @hidden */
  74277. _initialDirection: Nullable<Vector3>;
  74278. /** @hidden */
  74279. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74280. /** @hidden */
  74281. _initialStartSpriteCellID: number;
  74282. /** @hidden */
  74283. _initialEndSpriteCellID: number;
  74284. /** @hidden */
  74285. _currentColorGradient: Nullable<ColorGradient>;
  74286. /** @hidden */
  74287. _currentColor1: Color4;
  74288. /** @hidden */
  74289. _currentColor2: Color4;
  74290. /** @hidden */
  74291. _currentSizeGradient: Nullable<FactorGradient>;
  74292. /** @hidden */
  74293. _currentSize1: number;
  74294. /** @hidden */
  74295. _currentSize2: number;
  74296. /** @hidden */
  74297. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74298. /** @hidden */
  74299. _currentAngularSpeed1: number;
  74300. /** @hidden */
  74301. _currentAngularSpeed2: number;
  74302. /** @hidden */
  74303. _currentVelocityGradient: Nullable<FactorGradient>;
  74304. /** @hidden */
  74305. _currentVelocity1: number;
  74306. /** @hidden */
  74307. _currentVelocity2: number;
  74308. /** @hidden */
  74309. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74310. /** @hidden */
  74311. _currentLimitVelocity1: number;
  74312. /** @hidden */
  74313. _currentLimitVelocity2: number;
  74314. /** @hidden */
  74315. _currentDragGradient: Nullable<FactorGradient>;
  74316. /** @hidden */
  74317. _currentDrag1: number;
  74318. /** @hidden */
  74319. _currentDrag2: number;
  74320. /** @hidden */
  74321. _randomNoiseCoordinates1: Vector3;
  74322. /** @hidden */
  74323. _randomNoiseCoordinates2: Vector3;
  74324. /**
  74325. * Creates a new instance Particle
  74326. * @param particleSystem the particle system the particle belongs to
  74327. */
  74328. constructor(
  74329. /**
  74330. * The particle system the particle belongs to.
  74331. */
  74332. particleSystem: ParticleSystem);
  74333. private updateCellInfoFromSystem;
  74334. /**
  74335. * Defines how the sprite cell index is updated for the particle
  74336. */
  74337. updateCellIndex(): void;
  74338. /** @hidden */
  74339. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74340. /** @hidden */
  74341. _inheritParticleInfoToSubEmitters(): void;
  74342. /** @hidden */
  74343. _reset(): void;
  74344. /**
  74345. * Copy the properties of particle to another one.
  74346. * @param other the particle to copy the information to.
  74347. */
  74348. copyTo(other: Particle): void;
  74349. }
  74350. }
  74351. declare module BABYLON {
  74352. /**
  74353. * Particle emitter represents a volume emitting particles.
  74354. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74355. */
  74356. export interface IParticleEmitterType {
  74357. /**
  74358. * Called by the particle System when the direction is computed for the created particle.
  74359. * @param worldMatrix is the world matrix of the particle system
  74360. * @param directionToUpdate is the direction vector to update with the result
  74361. * @param particle is the particle we are computed the direction for
  74362. */
  74363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74364. /**
  74365. * Called by the particle System when the position is computed for the created particle.
  74366. * @param worldMatrix is the world matrix of the particle system
  74367. * @param positionToUpdate is the position vector to update with the result
  74368. * @param particle is the particle we are computed the position for
  74369. */
  74370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74371. /**
  74372. * Clones the current emitter and returns a copy of it
  74373. * @returns the new emitter
  74374. */
  74375. clone(): IParticleEmitterType;
  74376. /**
  74377. * Called by the GPUParticleSystem to setup the update shader
  74378. * @param effect defines the update shader
  74379. */
  74380. applyToShader(effect: Effect): void;
  74381. /**
  74382. * Returns a string to use to update the GPU particles update shader
  74383. * @returns the effect defines string
  74384. */
  74385. getEffectDefines(): string;
  74386. /**
  74387. * Returns a string representing the class name
  74388. * @returns a string containing the class name
  74389. */
  74390. getClassName(): string;
  74391. /**
  74392. * Serializes the particle system to a JSON object.
  74393. * @returns the JSON object
  74394. */
  74395. serialize(): any;
  74396. /**
  74397. * Parse properties from a JSON object
  74398. * @param serializationObject defines the JSON object
  74399. */
  74400. parse(serializationObject: any): void;
  74401. }
  74402. }
  74403. declare module BABYLON {
  74404. /**
  74405. * Particle emitter emitting particles from the inside of a box.
  74406. * It emits the particles randomly between 2 given directions.
  74407. */
  74408. export class BoxParticleEmitter implements IParticleEmitterType {
  74409. /**
  74410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74411. */
  74412. direction1: Vector3;
  74413. /**
  74414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74415. */
  74416. direction2: Vector3;
  74417. /**
  74418. * 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.
  74419. */
  74420. minEmitBox: Vector3;
  74421. /**
  74422. * 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.
  74423. */
  74424. maxEmitBox: Vector3;
  74425. /**
  74426. * Creates a new instance BoxParticleEmitter
  74427. */
  74428. constructor();
  74429. /**
  74430. * Called by the particle System when the direction is computed for the created particle.
  74431. * @param worldMatrix is the world matrix of the particle system
  74432. * @param directionToUpdate is the direction vector to update with the result
  74433. * @param particle is the particle we are computed the direction for
  74434. */
  74435. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74436. /**
  74437. * Called by the particle System when the position is computed for the created particle.
  74438. * @param worldMatrix is the world matrix of the particle system
  74439. * @param positionToUpdate is the position vector to update with the result
  74440. * @param particle is the particle we are computed the position for
  74441. */
  74442. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74443. /**
  74444. * Clones the current emitter and returns a copy of it
  74445. * @returns the new emitter
  74446. */
  74447. clone(): BoxParticleEmitter;
  74448. /**
  74449. * Called by the GPUParticleSystem to setup the update shader
  74450. * @param effect defines the update shader
  74451. */
  74452. applyToShader(effect: Effect): void;
  74453. /**
  74454. * Returns a string to use to update the GPU particles update shader
  74455. * @returns a string containng the defines string
  74456. */
  74457. getEffectDefines(): string;
  74458. /**
  74459. * Returns the string "BoxParticleEmitter"
  74460. * @returns a string containing the class name
  74461. */
  74462. getClassName(): string;
  74463. /**
  74464. * Serializes the particle system to a JSON object.
  74465. * @returns the JSON object
  74466. */
  74467. serialize(): any;
  74468. /**
  74469. * Parse properties from a JSON object
  74470. * @param serializationObject defines the JSON object
  74471. */
  74472. parse(serializationObject: any): void;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /**
  74477. * Particle emitter emitting particles from the inside of a cone.
  74478. * It emits the particles alongside the cone volume from the base to the particle.
  74479. * The emission direction might be randomized.
  74480. */
  74481. export class ConeParticleEmitter implements IParticleEmitterType {
  74482. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74483. directionRandomizer: number;
  74484. private _radius;
  74485. private _angle;
  74486. private _height;
  74487. /**
  74488. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74489. */
  74490. radiusRange: number;
  74491. /**
  74492. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74493. */
  74494. heightRange: number;
  74495. /**
  74496. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74497. */
  74498. emitFromSpawnPointOnly: boolean;
  74499. /**
  74500. * Gets or sets the radius of the emission cone
  74501. */
  74502. radius: number;
  74503. /**
  74504. * Gets or sets the angle of the emission cone
  74505. */
  74506. angle: number;
  74507. private _buildHeight;
  74508. /**
  74509. * Creates a new instance ConeParticleEmitter
  74510. * @param radius the radius of the emission cone (1 by default)
  74511. * @param angle the cone base angle (PI by default)
  74512. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74513. */
  74514. constructor(radius?: number, angle?: number,
  74515. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74516. directionRandomizer?: number);
  74517. /**
  74518. * Called by the particle System when the direction is computed for the created particle.
  74519. * @param worldMatrix is the world matrix of the particle system
  74520. * @param directionToUpdate is the direction vector to update with the result
  74521. * @param particle is the particle we are computed the direction for
  74522. */
  74523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74524. /**
  74525. * Called by the particle System when the position is computed for the created particle.
  74526. * @param worldMatrix is the world matrix of the particle system
  74527. * @param positionToUpdate is the position vector to update with the result
  74528. * @param particle is the particle we are computed the position for
  74529. */
  74530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74531. /**
  74532. * Clones the current emitter and returns a copy of it
  74533. * @returns the new emitter
  74534. */
  74535. clone(): ConeParticleEmitter;
  74536. /**
  74537. * Called by the GPUParticleSystem to setup the update shader
  74538. * @param effect defines the update shader
  74539. */
  74540. applyToShader(effect: Effect): void;
  74541. /**
  74542. * Returns a string to use to update the GPU particles update shader
  74543. * @returns a string containng the defines string
  74544. */
  74545. getEffectDefines(): string;
  74546. /**
  74547. * Returns the string "ConeParticleEmitter"
  74548. * @returns a string containing the class name
  74549. */
  74550. getClassName(): string;
  74551. /**
  74552. * Serializes the particle system to a JSON object.
  74553. * @returns the JSON object
  74554. */
  74555. serialize(): any;
  74556. /**
  74557. * Parse properties from a JSON object
  74558. * @param serializationObject defines the JSON object
  74559. */
  74560. parse(serializationObject: any): void;
  74561. }
  74562. }
  74563. declare module BABYLON {
  74564. /**
  74565. * Particle emitter emitting particles from the inside of a cylinder.
  74566. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74567. */
  74568. export class CylinderParticleEmitter implements IParticleEmitterType {
  74569. /**
  74570. * The radius of the emission cylinder.
  74571. */
  74572. radius: number;
  74573. /**
  74574. * The height of the emission cylinder.
  74575. */
  74576. height: number;
  74577. /**
  74578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74579. */
  74580. radiusRange: number;
  74581. /**
  74582. * How much to randomize the particle direction [0-1].
  74583. */
  74584. directionRandomizer: number;
  74585. /**
  74586. * Creates a new instance CylinderParticleEmitter
  74587. * @param radius the radius of the emission cylinder (1 by default)
  74588. * @param height the height of the emission cylinder (1 by default)
  74589. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74590. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74591. */
  74592. constructor(
  74593. /**
  74594. * The radius of the emission cylinder.
  74595. */
  74596. radius?: number,
  74597. /**
  74598. * The height of the emission cylinder.
  74599. */
  74600. height?: number,
  74601. /**
  74602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74603. */
  74604. radiusRange?: number,
  74605. /**
  74606. * How much to randomize the particle direction [0-1].
  74607. */
  74608. directionRandomizer?: number);
  74609. /**
  74610. * Called by the particle System when the direction is computed for the created particle.
  74611. * @param worldMatrix is the world matrix of the particle system
  74612. * @param directionToUpdate is the direction vector to update with the result
  74613. * @param particle is the particle we are computed the direction for
  74614. */
  74615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74616. /**
  74617. * Called by the particle System when the position is computed for the created particle.
  74618. * @param worldMatrix is the world matrix of the particle system
  74619. * @param positionToUpdate is the position vector to update with the result
  74620. * @param particle is the particle we are computed the position for
  74621. */
  74622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74623. /**
  74624. * Clones the current emitter and returns a copy of it
  74625. * @returns the new emitter
  74626. */
  74627. clone(): CylinderParticleEmitter;
  74628. /**
  74629. * Called by the GPUParticleSystem to setup the update shader
  74630. * @param effect defines the update shader
  74631. */
  74632. applyToShader(effect: Effect): void;
  74633. /**
  74634. * Returns a string to use to update the GPU particles update shader
  74635. * @returns a string containng the defines string
  74636. */
  74637. getEffectDefines(): string;
  74638. /**
  74639. * Returns the string "CylinderParticleEmitter"
  74640. * @returns a string containing the class name
  74641. */
  74642. getClassName(): string;
  74643. /**
  74644. * Serializes the particle system to a JSON object.
  74645. * @returns the JSON object
  74646. */
  74647. serialize(): any;
  74648. /**
  74649. * Parse properties from a JSON object
  74650. * @param serializationObject defines the JSON object
  74651. */
  74652. parse(serializationObject: any): void;
  74653. }
  74654. /**
  74655. * Particle emitter emitting particles from the inside of a cylinder.
  74656. * It emits the particles randomly between two vectors.
  74657. */
  74658. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74659. /**
  74660. * The min limit of the emission direction.
  74661. */
  74662. direction1: Vector3;
  74663. /**
  74664. * The max limit of the emission direction.
  74665. */
  74666. direction2: Vector3;
  74667. /**
  74668. * Creates a new instance CylinderDirectedParticleEmitter
  74669. * @param radius the radius of the emission cylinder (1 by default)
  74670. * @param height the height of the emission cylinder (1 by default)
  74671. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74672. * @param direction1 the min limit of the emission direction (up vector by default)
  74673. * @param direction2 the max limit of the emission direction (up vector by default)
  74674. */
  74675. constructor(radius?: number, height?: number, radiusRange?: number,
  74676. /**
  74677. * The min limit of the emission direction.
  74678. */
  74679. direction1?: Vector3,
  74680. /**
  74681. * The max limit of the emission direction.
  74682. */
  74683. direction2?: Vector3);
  74684. /**
  74685. * Called by the particle System when the direction is computed for the created particle.
  74686. * @param worldMatrix is the world matrix of the particle system
  74687. * @param directionToUpdate is the direction vector to update with the result
  74688. * @param particle is the particle we are computed the direction for
  74689. */
  74690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74691. /**
  74692. * Clones the current emitter and returns a copy of it
  74693. * @returns the new emitter
  74694. */
  74695. clone(): CylinderDirectedParticleEmitter;
  74696. /**
  74697. * Called by the GPUParticleSystem to setup the update shader
  74698. * @param effect defines the update shader
  74699. */
  74700. applyToShader(effect: Effect): void;
  74701. /**
  74702. * Returns a string to use to update the GPU particles update shader
  74703. * @returns a string containng the defines string
  74704. */
  74705. getEffectDefines(): string;
  74706. /**
  74707. * Returns the string "CylinderDirectedParticleEmitter"
  74708. * @returns a string containing the class name
  74709. */
  74710. getClassName(): string;
  74711. /**
  74712. * Serializes the particle system to a JSON object.
  74713. * @returns the JSON object
  74714. */
  74715. serialize(): any;
  74716. /**
  74717. * Parse properties from a JSON object
  74718. * @param serializationObject defines the JSON object
  74719. */
  74720. parse(serializationObject: any): void;
  74721. }
  74722. }
  74723. declare module BABYLON {
  74724. /**
  74725. * Particle emitter emitting particles from the inside of a hemisphere.
  74726. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74727. */
  74728. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74729. /**
  74730. * The radius of the emission hemisphere.
  74731. */
  74732. radius: number;
  74733. /**
  74734. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74735. */
  74736. radiusRange: number;
  74737. /**
  74738. * How much to randomize the particle direction [0-1].
  74739. */
  74740. directionRandomizer: number;
  74741. /**
  74742. * Creates a new instance HemisphericParticleEmitter
  74743. * @param radius the radius of the emission hemisphere (1 by default)
  74744. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74745. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74746. */
  74747. constructor(
  74748. /**
  74749. * The radius of the emission hemisphere.
  74750. */
  74751. radius?: number,
  74752. /**
  74753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74754. */
  74755. radiusRange?: number,
  74756. /**
  74757. * How much to randomize the particle direction [0-1].
  74758. */
  74759. directionRandomizer?: number);
  74760. /**
  74761. * Called by the particle System when the direction is computed for the created particle.
  74762. * @param worldMatrix is the world matrix of the particle system
  74763. * @param directionToUpdate is the direction vector to update with the result
  74764. * @param particle is the particle we are computed the direction for
  74765. */
  74766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74767. /**
  74768. * Called by the particle System when the position is computed for the created particle.
  74769. * @param worldMatrix is the world matrix of the particle system
  74770. * @param positionToUpdate is the position vector to update with the result
  74771. * @param particle is the particle we are computed the position for
  74772. */
  74773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74774. /**
  74775. * Clones the current emitter and returns a copy of it
  74776. * @returns the new emitter
  74777. */
  74778. clone(): HemisphericParticleEmitter;
  74779. /**
  74780. * Called by the GPUParticleSystem to setup the update shader
  74781. * @param effect defines the update shader
  74782. */
  74783. applyToShader(effect: Effect): void;
  74784. /**
  74785. * Returns a string to use to update the GPU particles update shader
  74786. * @returns a string containng the defines string
  74787. */
  74788. getEffectDefines(): string;
  74789. /**
  74790. * Returns the string "HemisphericParticleEmitter"
  74791. * @returns a string containing the class name
  74792. */
  74793. getClassName(): string;
  74794. /**
  74795. * Serializes the particle system to a JSON object.
  74796. * @returns the JSON object
  74797. */
  74798. serialize(): any;
  74799. /**
  74800. * Parse properties from a JSON object
  74801. * @param serializationObject defines the JSON object
  74802. */
  74803. parse(serializationObject: any): void;
  74804. }
  74805. }
  74806. declare module BABYLON {
  74807. /**
  74808. * Particle emitter emitting particles from a point.
  74809. * It emits the particles randomly between 2 given directions.
  74810. */
  74811. export class PointParticleEmitter implements IParticleEmitterType {
  74812. /**
  74813. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74814. */
  74815. direction1: Vector3;
  74816. /**
  74817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74818. */
  74819. direction2: Vector3;
  74820. /**
  74821. * Creates a new instance PointParticleEmitter
  74822. */
  74823. constructor();
  74824. /**
  74825. * Called by the particle System when the direction is computed for the created particle.
  74826. * @param worldMatrix is the world matrix of the particle system
  74827. * @param directionToUpdate is the direction vector to update with the result
  74828. * @param particle is the particle we are computed the direction for
  74829. */
  74830. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74831. /**
  74832. * Called by the particle System when the position is computed for the created particle.
  74833. * @param worldMatrix is the world matrix of the particle system
  74834. * @param positionToUpdate is the position vector to update with the result
  74835. * @param particle is the particle we are computed the position for
  74836. */
  74837. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74838. /**
  74839. * Clones the current emitter and returns a copy of it
  74840. * @returns the new emitter
  74841. */
  74842. clone(): PointParticleEmitter;
  74843. /**
  74844. * Called by the GPUParticleSystem to setup the update shader
  74845. * @param effect defines the update shader
  74846. */
  74847. applyToShader(effect: Effect): void;
  74848. /**
  74849. * Returns a string to use to update the GPU particles update shader
  74850. * @returns a string containng the defines string
  74851. */
  74852. getEffectDefines(): string;
  74853. /**
  74854. * Returns the string "PointParticleEmitter"
  74855. * @returns a string containing the class name
  74856. */
  74857. getClassName(): string;
  74858. /**
  74859. * Serializes the particle system to a JSON object.
  74860. * @returns the JSON object
  74861. */
  74862. serialize(): any;
  74863. /**
  74864. * Parse properties from a JSON object
  74865. * @param serializationObject defines the JSON object
  74866. */
  74867. parse(serializationObject: any): void;
  74868. }
  74869. }
  74870. declare module BABYLON {
  74871. /**
  74872. * Particle emitter emitting particles from the inside of a sphere.
  74873. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74874. */
  74875. export class SphereParticleEmitter implements IParticleEmitterType {
  74876. /**
  74877. * The radius of the emission sphere.
  74878. */
  74879. radius: number;
  74880. /**
  74881. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74882. */
  74883. radiusRange: number;
  74884. /**
  74885. * How much to randomize the particle direction [0-1].
  74886. */
  74887. directionRandomizer: number;
  74888. /**
  74889. * Creates a new instance SphereParticleEmitter
  74890. * @param radius the radius of the emission sphere (1 by default)
  74891. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74892. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74893. */
  74894. constructor(
  74895. /**
  74896. * The radius of the emission sphere.
  74897. */
  74898. radius?: number,
  74899. /**
  74900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74901. */
  74902. radiusRange?: number,
  74903. /**
  74904. * How much to randomize the particle direction [0-1].
  74905. */
  74906. directionRandomizer?: number);
  74907. /**
  74908. * Called by the particle System when the direction is computed for the created particle.
  74909. * @param worldMatrix is the world matrix of the particle system
  74910. * @param directionToUpdate is the direction vector to update with the result
  74911. * @param particle is the particle we are computed the direction for
  74912. */
  74913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74914. /**
  74915. * Called by the particle System when the position is computed for the created particle.
  74916. * @param worldMatrix is the world matrix of the particle system
  74917. * @param positionToUpdate is the position vector to update with the result
  74918. * @param particle is the particle we are computed the position for
  74919. */
  74920. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74921. /**
  74922. * Clones the current emitter and returns a copy of it
  74923. * @returns the new emitter
  74924. */
  74925. clone(): SphereParticleEmitter;
  74926. /**
  74927. * Called by the GPUParticleSystem to setup the update shader
  74928. * @param effect defines the update shader
  74929. */
  74930. applyToShader(effect: Effect): void;
  74931. /**
  74932. * Returns a string to use to update the GPU particles update shader
  74933. * @returns a string containng the defines string
  74934. */
  74935. getEffectDefines(): string;
  74936. /**
  74937. * Returns the string "SphereParticleEmitter"
  74938. * @returns a string containing the class name
  74939. */
  74940. getClassName(): string;
  74941. /**
  74942. * Serializes the particle system to a JSON object.
  74943. * @returns the JSON object
  74944. */
  74945. serialize(): any;
  74946. /**
  74947. * Parse properties from a JSON object
  74948. * @param serializationObject defines the JSON object
  74949. */
  74950. parse(serializationObject: any): void;
  74951. }
  74952. /**
  74953. * Particle emitter emitting particles from the inside of a sphere.
  74954. * It emits the particles randomly between two vectors.
  74955. */
  74956. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74957. /**
  74958. * The min limit of the emission direction.
  74959. */
  74960. direction1: Vector3;
  74961. /**
  74962. * The max limit of the emission direction.
  74963. */
  74964. direction2: Vector3;
  74965. /**
  74966. * Creates a new instance SphereDirectedParticleEmitter
  74967. * @param radius the radius of the emission sphere (1 by default)
  74968. * @param direction1 the min limit of the emission direction (up vector by default)
  74969. * @param direction2 the max limit of the emission direction (up vector by default)
  74970. */
  74971. constructor(radius?: number,
  74972. /**
  74973. * The min limit of the emission direction.
  74974. */
  74975. direction1?: Vector3,
  74976. /**
  74977. * The max limit of the emission direction.
  74978. */
  74979. direction2?: Vector3);
  74980. /**
  74981. * Called by the particle System when the direction is computed for the created particle.
  74982. * @param worldMatrix is the world matrix of the particle system
  74983. * @param directionToUpdate is the direction vector to update with the result
  74984. * @param particle is the particle we are computed the direction for
  74985. */
  74986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74987. /**
  74988. * Clones the current emitter and returns a copy of it
  74989. * @returns the new emitter
  74990. */
  74991. clone(): SphereDirectedParticleEmitter;
  74992. /**
  74993. * Called by the GPUParticleSystem to setup the update shader
  74994. * @param effect defines the update shader
  74995. */
  74996. applyToShader(effect: Effect): void;
  74997. /**
  74998. * Returns a string to use to update the GPU particles update shader
  74999. * @returns a string containng the defines string
  75000. */
  75001. getEffectDefines(): string;
  75002. /**
  75003. * Returns the string "SphereDirectedParticleEmitter"
  75004. * @returns a string containing the class name
  75005. */
  75006. getClassName(): string;
  75007. /**
  75008. * Serializes the particle system to a JSON object.
  75009. * @returns the JSON object
  75010. */
  75011. serialize(): any;
  75012. /**
  75013. * Parse properties from a JSON object
  75014. * @param serializationObject defines the JSON object
  75015. */
  75016. parse(serializationObject: any): void;
  75017. }
  75018. }
  75019. declare module BABYLON {
  75020. /**
  75021. * Interface representing a particle system in Babylon.js.
  75022. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75023. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75024. */
  75025. export interface IParticleSystem {
  75026. /**
  75027. * List of animations used by the particle system.
  75028. */
  75029. animations: Animation[];
  75030. /**
  75031. * The id of the Particle system.
  75032. */
  75033. id: string;
  75034. /**
  75035. * The name of the Particle system.
  75036. */
  75037. name: string;
  75038. /**
  75039. * The emitter represents the Mesh or position we are attaching the particle system to.
  75040. */
  75041. emitter: Nullable<AbstractMesh | Vector3>;
  75042. /**
  75043. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75044. */
  75045. isBillboardBased: boolean;
  75046. /**
  75047. * The rendering group used by the Particle system to chose when to render.
  75048. */
  75049. renderingGroupId: number;
  75050. /**
  75051. * The layer mask we are rendering the particles through.
  75052. */
  75053. layerMask: number;
  75054. /**
  75055. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75056. */
  75057. updateSpeed: number;
  75058. /**
  75059. * The amount of time the particle system is running (depends of the overall update speed).
  75060. */
  75061. targetStopDuration: number;
  75062. /**
  75063. * The texture used to render each particle. (this can be a spritesheet)
  75064. */
  75065. particleTexture: Nullable<Texture>;
  75066. /**
  75067. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75068. */
  75069. blendMode: number;
  75070. /**
  75071. * Minimum life time of emitting particles.
  75072. */
  75073. minLifeTime: number;
  75074. /**
  75075. * Maximum life time of emitting particles.
  75076. */
  75077. maxLifeTime: number;
  75078. /**
  75079. * Minimum Size of emitting particles.
  75080. */
  75081. minSize: number;
  75082. /**
  75083. * Maximum Size of emitting particles.
  75084. */
  75085. maxSize: number;
  75086. /**
  75087. * Minimum scale of emitting particles on X axis.
  75088. */
  75089. minScaleX: number;
  75090. /**
  75091. * Maximum scale of emitting particles on X axis.
  75092. */
  75093. maxScaleX: number;
  75094. /**
  75095. * Minimum scale of emitting particles on Y axis.
  75096. */
  75097. minScaleY: number;
  75098. /**
  75099. * Maximum scale of emitting particles on Y axis.
  75100. */
  75101. maxScaleY: number;
  75102. /**
  75103. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75104. */
  75105. color1: Color4;
  75106. /**
  75107. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75108. */
  75109. color2: Color4;
  75110. /**
  75111. * Color the particle will have at the end of its lifetime.
  75112. */
  75113. colorDead: Color4;
  75114. /**
  75115. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75116. */
  75117. emitRate: number;
  75118. /**
  75119. * You can use gravity if you want to give an orientation to your particles.
  75120. */
  75121. gravity: Vector3;
  75122. /**
  75123. * Minimum power of emitting particles.
  75124. */
  75125. minEmitPower: number;
  75126. /**
  75127. * Maximum power of emitting particles.
  75128. */
  75129. maxEmitPower: number;
  75130. /**
  75131. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75132. */
  75133. minAngularSpeed: number;
  75134. /**
  75135. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75136. */
  75137. maxAngularSpeed: number;
  75138. /**
  75139. * Gets or sets the minimal initial rotation in radians.
  75140. */
  75141. minInitialRotation: number;
  75142. /**
  75143. * Gets or sets the maximal initial rotation in radians.
  75144. */
  75145. maxInitialRotation: number;
  75146. /**
  75147. * The particle emitter type defines the emitter used by the particle system.
  75148. * It can be for example box, sphere, or cone...
  75149. */
  75150. particleEmitterType: Nullable<IParticleEmitterType>;
  75151. /**
  75152. * Defines the delay in milliseconds before starting the system (0 by default)
  75153. */
  75154. startDelay: number;
  75155. /**
  75156. * 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
  75157. */
  75158. preWarmCycles: number;
  75159. /**
  75160. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75161. */
  75162. preWarmStepOffset: number;
  75163. /**
  75164. * 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)
  75165. */
  75166. spriteCellChangeSpeed: number;
  75167. /**
  75168. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75169. */
  75170. startSpriteCellID: number;
  75171. /**
  75172. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75173. */
  75174. endSpriteCellID: number;
  75175. /**
  75176. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75177. */
  75178. spriteCellWidth: number;
  75179. /**
  75180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75181. */
  75182. spriteCellHeight: number;
  75183. /**
  75184. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75185. */
  75186. spriteRandomStartCell: boolean;
  75187. /**
  75188. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75189. */
  75190. isAnimationSheetEnabled: boolean;
  75191. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75192. translationPivot: Vector2;
  75193. /**
  75194. * Gets or sets a texture used to add random noise to particle positions
  75195. */
  75196. noiseTexture: Nullable<BaseTexture>;
  75197. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75198. noiseStrength: Vector3;
  75199. /**
  75200. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75201. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75202. */
  75203. billboardMode: number;
  75204. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75205. limitVelocityDamping: number;
  75206. /**
  75207. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75208. */
  75209. beginAnimationOnStart: boolean;
  75210. /**
  75211. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75212. */
  75213. beginAnimationFrom: number;
  75214. /**
  75215. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75216. */
  75217. beginAnimationTo: number;
  75218. /**
  75219. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75220. */
  75221. beginAnimationLoop: boolean;
  75222. /**
  75223. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75224. */
  75225. disposeOnStop: boolean;
  75226. /**
  75227. * Gets the maximum number of particles active at the same time.
  75228. * @returns The max number of active particles.
  75229. */
  75230. getCapacity(): number;
  75231. /**
  75232. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75233. * @returns True if it has been started, otherwise false.
  75234. */
  75235. isStarted(): boolean;
  75236. /**
  75237. * Animates the particle system for this frame.
  75238. */
  75239. animate(): void;
  75240. /**
  75241. * Renders the particle system in its current state.
  75242. * @returns the current number of particles
  75243. */
  75244. render(): number;
  75245. /**
  75246. * Dispose the particle system and frees its associated resources.
  75247. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75248. */
  75249. dispose(disposeTexture?: boolean): void;
  75250. /**
  75251. * Clones the particle system.
  75252. * @param name The name of the cloned object
  75253. * @param newEmitter The new emitter to use
  75254. * @returns the cloned particle system
  75255. */
  75256. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75257. /**
  75258. * Serializes the particle system to a JSON object.
  75259. * @returns the JSON object
  75260. */
  75261. serialize(): any;
  75262. /**
  75263. * Rebuild the particle system
  75264. */
  75265. rebuild(): void;
  75266. /**
  75267. * Starts the particle system and begins to emit
  75268. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75269. */
  75270. start(delay?: number): void;
  75271. /**
  75272. * Stops the particle system.
  75273. */
  75274. stop(): void;
  75275. /**
  75276. * Remove all active particles
  75277. */
  75278. reset(): void;
  75279. /**
  75280. * Is this system ready to be used/rendered
  75281. * @return true if the system is ready
  75282. */
  75283. isReady(): boolean;
  75284. /**
  75285. * Adds a new color gradient
  75286. * @param gradient defines the gradient to use (between 0 and 1)
  75287. * @param color1 defines the color to affect to the specified gradient
  75288. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75289. * @returns the current particle system
  75290. */
  75291. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75292. /**
  75293. * Remove a specific color gradient
  75294. * @param gradient defines the gradient to remove
  75295. * @returns the current particle system
  75296. */
  75297. removeColorGradient(gradient: number): IParticleSystem;
  75298. /**
  75299. * Adds a new size gradient
  75300. * @param gradient defines the gradient to use (between 0 and 1)
  75301. * @param factor defines the size factor to affect to the specified gradient
  75302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75303. * @returns the current particle system
  75304. */
  75305. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75306. /**
  75307. * Remove a specific size gradient
  75308. * @param gradient defines the gradient to remove
  75309. * @returns the current particle system
  75310. */
  75311. removeSizeGradient(gradient: number): IParticleSystem;
  75312. /**
  75313. * Gets the current list of color gradients.
  75314. * You must use addColorGradient and removeColorGradient to udpate this list
  75315. * @returns the list of color gradients
  75316. */
  75317. getColorGradients(): Nullable<Array<ColorGradient>>;
  75318. /**
  75319. * Gets the current list of size gradients.
  75320. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75321. * @returns the list of size gradients
  75322. */
  75323. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75324. /**
  75325. * Gets the current list of angular speed gradients.
  75326. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75327. * @returns the list of angular speed gradients
  75328. */
  75329. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75330. /**
  75331. * Adds a new angular speed gradient
  75332. * @param gradient defines the gradient to use (between 0 and 1)
  75333. * @param factor defines the angular speed to affect to the specified gradient
  75334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75335. * @returns the current particle system
  75336. */
  75337. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75338. /**
  75339. * Remove a specific angular speed gradient
  75340. * @param gradient defines the gradient to remove
  75341. * @returns the current particle system
  75342. */
  75343. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75344. /**
  75345. * Gets the current list of velocity gradients.
  75346. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75347. * @returns the list of velocity gradients
  75348. */
  75349. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75350. /**
  75351. * Adds a new velocity gradient
  75352. * @param gradient defines the gradient to use (between 0 and 1)
  75353. * @param factor defines the velocity to affect to the specified gradient
  75354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75355. * @returns the current particle system
  75356. */
  75357. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75358. /**
  75359. * Remove a specific velocity gradient
  75360. * @param gradient defines the gradient to remove
  75361. * @returns the current particle system
  75362. */
  75363. removeVelocityGradient(gradient: number): IParticleSystem;
  75364. /**
  75365. * Gets the current list of limit velocity gradients.
  75366. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75367. * @returns the list of limit velocity gradients
  75368. */
  75369. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75370. /**
  75371. * Adds a new limit velocity gradient
  75372. * @param gradient defines the gradient to use (between 0 and 1)
  75373. * @param factor defines the limit velocity to affect to the specified gradient
  75374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75375. * @returns the current particle system
  75376. */
  75377. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75378. /**
  75379. * Remove a specific limit velocity gradient
  75380. * @param gradient defines the gradient to remove
  75381. * @returns the current particle system
  75382. */
  75383. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75384. /**
  75385. * Adds a new drag gradient
  75386. * @param gradient defines the gradient to use (between 0 and 1)
  75387. * @param factor defines the drag to affect to the specified gradient
  75388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75389. * @returns the current particle system
  75390. */
  75391. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75392. /**
  75393. * Remove a specific drag gradient
  75394. * @param gradient defines the gradient to remove
  75395. * @returns the current particle system
  75396. */
  75397. removeDragGradient(gradient: number): IParticleSystem;
  75398. /**
  75399. * Gets the current list of drag gradients.
  75400. * You must use addDragGradient and removeDragGradient to udpate this list
  75401. * @returns the list of drag gradients
  75402. */
  75403. getDragGradients(): Nullable<Array<FactorGradient>>;
  75404. /**
  75405. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75406. * @param gradient defines the gradient to use (between 0 and 1)
  75407. * @param factor defines the emit rate to affect to the specified gradient
  75408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75409. * @returns the current particle system
  75410. */
  75411. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75412. /**
  75413. * Remove a specific emit rate gradient
  75414. * @param gradient defines the gradient to remove
  75415. * @returns the current particle system
  75416. */
  75417. removeEmitRateGradient(gradient: number): IParticleSystem;
  75418. /**
  75419. * Gets the current list of emit rate gradients.
  75420. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75421. * @returns the list of emit rate gradients
  75422. */
  75423. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75424. /**
  75425. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75426. * @param gradient defines the gradient to use (between 0 and 1)
  75427. * @param factor defines the start size to affect to the specified gradient
  75428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75429. * @returns the current particle system
  75430. */
  75431. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75432. /**
  75433. * Remove a specific start size gradient
  75434. * @param gradient defines the gradient to remove
  75435. * @returns the current particle system
  75436. */
  75437. removeStartSizeGradient(gradient: number): IParticleSystem;
  75438. /**
  75439. * Gets the current list of start size gradients.
  75440. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75441. * @returns the list of start size gradients
  75442. */
  75443. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75444. /**
  75445. * Adds a new life time gradient
  75446. * @param gradient defines the gradient to use (between 0 and 1)
  75447. * @param factor defines the life time factor to affect to the specified gradient
  75448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75449. * @returns the current particle system
  75450. */
  75451. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75452. /**
  75453. * Remove a specific life time gradient
  75454. * @param gradient defines the gradient to remove
  75455. * @returns the current particle system
  75456. */
  75457. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75458. /**
  75459. * Gets the current list of life time gradients.
  75460. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75461. * @returns the list of life time gradients
  75462. */
  75463. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75464. /**
  75465. * Gets the current list of color gradients.
  75466. * You must use addColorGradient and removeColorGradient to udpate this list
  75467. * @returns the list of color gradients
  75468. */
  75469. getColorGradients(): Nullable<Array<ColorGradient>>;
  75470. /**
  75471. * Adds a new ramp gradient used to remap particle colors
  75472. * @param gradient defines the gradient to use (between 0 and 1)
  75473. * @param color defines the color to affect to the specified gradient
  75474. * @returns the current particle system
  75475. */
  75476. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75477. /**
  75478. * Gets the current list of ramp gradients.
  75479. * You must use addRampGradient and removeRampGradient to udpate this list
  75480. * @returns the list of ramp gradients
  75481. */
  75482. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75483. /** Gets or sets a boolean indicating that ramp gradients must be used
  75484. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75485. */
  75486. useRampGradients: boolean;
  75487. /**
  75488. * Adds a new color remap gradient
  75489. * @param gradient defines the gradient to use (between 0 and 1)
  75490. * @param min defines the color remap minimal range
  75491. * @param max defines the color remap maximal range
  75492. * @returns the current particle system
  75493. */
  75494. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75495. /**
  75496. * Gets the current list of color remap gradients.
  75497. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75498. * @returns the list of color remap gradients
  75499. */
  75500. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75501. /**
  75502. * Adds a new alpha remap gradient
  75503. * @param gradient defines the gradient to use (between 0 and 1)
  75504. * @param min defines the alpha remap minimal range
  75505. * @param max defines the alpha remap maximal range
  75506. * @returns the current particle system
  75507. */
  75508. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75509. /**
  75510. * Gets the current list of alpha remap gradients.
  75511. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75512. * @returns the list of alpha remap gradients
  75513. */
  75514. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75515. /**
  75516. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75519. * @returns the emitter
  75520. */
  75521. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75522. /**
  75523. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75524. * @param radius The radius of the hemisphere to emit from
  75525. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75526. * @returns the emitter
  75527. */
  75528. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75529. /**
  75530. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75531. * @param radius The radius of the sphere to emit from
  75532. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75533. * @returns the emitter
  75534. */
  75535. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75536. /**
  75537. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75538. * @param radius The radius of the sphere to emit from
  75539. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75540. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75541. * @returns the emitter
  75542. */
  75543. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75544. /**
  75545. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75546. * @param radius The radius of the emission cylinder
  75547. * @param height The height of the emission cylinder
  75548. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75549. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75550. * @returns the emitter
  75551. */
  75552. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75553. /**
  75554. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75555. * @param radius The radius of the cylinder to emit from
  75556. * @param height The height of the emission cylinder
  75557. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75560. * @returns the emitter
  75561. */
  75562. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75563. /**
  75564. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75565. * @param radius The radius of the cone to emit from
  75566. * @param angle The base angle of the cone
  75567. * @returns the emitter
  75568. */
  75569. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75570. /**
  75571. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75574. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75575. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75576. * @returns the emitter
  75577. */
  75578. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75579. /**
  75580. * Get hosting scene
  75581. * @returns the scene
  75582. */
  75583. getScene(): Scene;
  75584. }
  75585. }
  75586. declare module BABYLON {
  75587. /**
  75588. * Creates an instance based on a source mesh.
  75589. */
  75590. export class InstancedMesh extends AbstractMesh {
  75591. private _sourceMesh;
  75592. private _currentLOD;
  75593. /** @hidden */
  75594. _indexInSourceMeshInstanceArray: number;
  75595. constructor(name: string, source: Mesh);
  75596. /**
  75597. * Returns the string "InstancedMesh".
  75598. */
  75599. getClassName(): string;
  75600. /**
  75601. * If the source mesh receives shadows
  75602. */
  75603. readonly receiveShadows: boolean;
  75604. /**
  75605. * The material of the source mesh
  75606. */
  75607. readonly material: Nullable<Material>;
  75608. /**
  75609. * Visibility of the source mesh
  75610. */
  75611. readonly visibility: number;
  75612. /**
  75613. * Skeleton of the source mesh
  75614. */
  75615. readonly skeleton: Nullable<Skeleton>;
  75616. /**
  75617. * Rendering ground id of the source mesh
  75618. */
  75619. renderingGroupId: number;
  75620. /**
  75621. * Returns the total number of vertices (integer).
  75622. */
  75623. getTotalVertices(): number;
  75624. /**
  75625. * Returns a positive integer : the total number of indices in this mesh geometry.
  75626. * @returns the numner of indices or zero if the mesh has no geometry.
  75627. */
  75628. getTotalIndices(): number;
  75629. /**
  75630. * The source mesh of the instance
  75631. */
  75632. readonly sourceMesh: Mesh;
  75633. /**
  75634. * Is this node ready to be used/rendered
  75635. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75636. * @return {boolean} is it ready
  75637. */
  75638. isReady(completeCheck?: boolean): boolean;
  75639. /**
  75640. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75641. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75642. * @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.
  75643. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75644. */
  75645. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75646. /**
  75647. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75648. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75649. * The `data` are either a numeric array either a Float32Array.
  75650. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75651. * 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).
  75652. * Note that a new underlying VertexBuffer object is created each call.
  75653. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75654. *
  75655. * Possible `kind` values :
  75656. * - VertexBuffer.PositionKind
  75657. * - VertexBuffer.UVKind
  75658. * - VertexBuffer.UV2Kind
  75659. * - VertexBuffer.UV3Kind
  75660. * - VertexBuffer.UV4Kind
  75661. * - VertexBuffer.UV5Kind
  75662. * - VertexBuffer.UV6Kind
  75663. * - VertexBuffer.ColorKind
  75664. * - VertexBuffer.MatricesIndicesKind
  75665. * - VertexBuffer.MatricesIndicesExtraKind
  75666. * - VertexBuffer.MatricesWeightsKind
  75667. * - VertexBuffer.MatricesWeightsExtraKind
  75668. *
  75669. * Returns the Mesh.
  75670. */
  75671. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75672. /**
  75673. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75674. * If the mesh has no geometry, it is simply returned as it is.
  75675. * The `data` are either a numeric array either a Float32Array.
  75676. * No new underlying VertexBuffer object is created.
  75677. * 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.
  75678. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75679. *
  75680. * Possible `kind` values :
  75681. * - VertexBuffer.PositionKind
  75682. * - VertexBuffer.UVKind
  75683. * - VertexBuffer.UV2Kind
  75684. * - VertexBuffer.UV3Kind
  75685. * - VertexBuffer.UV4Kind
  75686. * - VertexBuffer.UV5Kind
  75687. * - VertexBuffer.UV6Kind
  75688. * - VertexBuffer.ColorKind
  75689. * - VertexBuffer.MatricesIndicesKind
  75690. * - VertexBuffer.MatricesIndicesExtraKind
  75691. * - VertexBuffer.MatricesWeightsKind
  75692. * - VertexBuffer.MatricesWeightsExtraKind
  75693. *
  75694. * Returns the Mesh.
  75695. */
  75696. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75697. /**
  75698. * Sets the mesh indices.
  75699. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75700. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75701. * This method creates a new index buffer each call.
  75702. * Returns the Mesh.
  75703. */
  75704. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75705. /**
  75706. * Boolean : True if the mesh owns the requested kind of data.
  75707. */
  75708. isVerticesDataPresent(kind: string): boolean;
  75709. /**
  75710. * Returns an array of indices (IndicesArray).
  75711. */
  75712. getIndices(): Nullable<IndicesArray>;
  75713. readonly _positions: Nullable<Vector3[]>;
  75714. /**
  75715. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75716. * This means the mesh underlying bounding box and sphere are recomputed.
  75717. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75718. * @returns the current mesh
  75719. */
  75720. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75721. /** @hidden */
  75722. _preActivate(): InstancedMesh;
  75723. /** @hidden */
  75724. _activate(renderId: number): InstancedMesh;
  75725. /**
  75726. * Returns the current associated LOD AbstractMesh.
  75727. */
  75728. getLOD(camera: Camera): AbstractMesh;
  75729. /** @hidden */
  75730. _syncSubMeshes(): InstancedMesh;
  75731. /** @hidden */
  75732. _generatePointsArray(): boolean;
  75733. /**
  75734. * Creates a new InstancedMesh from the current mesh.
  75735. * - name (string) : the cloned mesh name
  75736. * - newParent (optional Node) : the optional Node to parent the clone to.
  75737. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75738. *
  75739. * Returns the clone.
  75740. */
  75741. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75742. /**
  75743. * Disposes the InstancedMesh.
  75744. * Returns nothing.
  75745. */
  75746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75747. }
  75748. }
  75749. declare module BABYLON {
  75750. /**
  75751. * Defines the options associated with the creation of a shader material.
  75752. */
  75753. export interface IShaderMaterialOptions {
  75754. /**
  75755. * Does the material work in alpha blend mode
  75756. */
  75757. needAlphaBlending: boolean;
  75758. /**
  75759. * Does the material work in alpha test mode
  75760. */
  75761. needAlphaTesting: boolean;
  75762. /**
  75763. * The list of attribute names used in the shader
  75764. */
  75765. attributes: string[];
  75766. /**
  75767. * The list of unifrom names used in the shader
  75768. */
  75769. uniforms: string[];
  75770. /**
  75771. * The list of UBO names used in the shader
  75772. */
  75773. uniformBuffers: string[];
  75774. /**
  75775. * The list of sampler names used in the shader
  75776. */
  75777. samplers: string[];
  75778. /**
  75779. * The list of defines used in the shader
  75780. */
  75781. defines: string[];
  75782. }
  75783. /**
  75784. * 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.
  75785. *
  75786. * This returned material effects how the mesh will look based on the code in the shaders.
  75787. *
  75788. * @see http://doc.babylonjs.com/how_to/shader_material
  75789. */
  75790. export class ShaderMaterial extends Material {
  75791. private _shaderPath;
  75792. private _options;
  75793. private _textures;
  75794. private _textureArrays;
  75795. private _floats;
  75796. private _ints;
  75797. private _floatsArrays;
  75798. private _colors3;
  75799. private _colors3Arrays;
  75800. private _colors4;
  75801. private _vectors2;
  75802. private _vectors3;
  75803. private _vectors4;
  75804. private _matrices;
  75805. private _matrices3x3;
  75806. private _matrices2x2;
  75807. private _vectors2Arrays;
  75808. private _vectors3Arrays;
  75809. private _cachedWorldViewMatrix;
  75810. private _renderId;
  75811. /**
  75812. * Instantiate a new shader material.
  75813. * 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.
  75814. * This returned material effects how the mesh will look based on the code in the shaders.
  75815. * @see http://doc.babylonjs.com/how_to/shader_material
  75816. * @param name Define the name of the material in the scene
  75817. * @param scene Define the scene the material belongs to
  75818. * @param shaderPath Defines the route to the shader code in one of three ways:
  75819. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75820. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75821. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75822. * @param options Define the options used to create the shader
  75823. */
  75824. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75825. /**
  75826. * Gets the options used to compile the shader.
  75827. * They can be modified to trigger a new compilation
  75828. */
  75829. readonly options: IShaderMaterialOptions;
  75830. /**
  75831. * Gets the current class name of the material e.g. "ShaderMaterial"
  75832. * Mainly use in serialization.
  75833. * @returns the class name
  75834. */
  75835. getClassName(): string;
  75836. /**
  75837. * Specifies if the material will require alpha blending
  75838. * @returns a boolean specifying if alpha blending is needed
  75839. */
  75840. needAlphaBlending(): boolean;
  75841. /**
  75842. * Specifies if this material should be rendered in alpha test mode
  75843. * @returns a boolean specifying if an alpha test is needed.
  75844. */
  75845. needAlphaTesting(): boolean;
  75846. private _checkUniform;
  75847. /**
  75848. * Set a texture in the shader.
  75849. * @param name Define the name of the uniform samplers as defined in the shader
  75850. * @param texture Define the texture to bind to this sampler
  75851. * @return the material itself allowing "fluent" like uniform updates
  75852. */
  75853. setTexture(name: string, texture: Texture): ShaderMaterial;
  75854. /**
  75855. * Set a texture array in the shader.
  75856. * @param name Define the name of the uniform sampler array as defined in the shader
  75857. * @param textures Define the list of textures to bind to this sampler
  75858. * @return the material itself allowing "fluent" like uniform updates
  75859. */
  75860. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75861. /**
  75862. * Set a float in the shader.
  75863. * @param name Define the name of the uniform as defined in the shader
  75864. * @param value Define the value to give to the uniform
  75865. * @return the material itself allowing "fluent" like uniform updates
  75866. */
  75867. setFloat(name: string, value: number): ShaderMaterial;
  75868. /**
  75869. * Set a int in the shader.
  75870. * @param name Define the name of the uniform as defined in the shader
  75871. * @param value Define the value to give to the uniform
  75872. * @return the material itself allowing "fluent" like uniform updates
  75873. */
  75874. setInt(name: string, value: number): ShaderMaterial;
  75875. /**
  75876. * Set an array of floats in the shader.
  75877. * @param name Define the name of the uniform as defined in the shader
  75878. * @param value Define the value to give to the uniform
  75879. * @return the material itself allowing "fluent" like uniform updates
  75880. */
  75881. setFloats(name: string, value: number[]): ShaderMaterial;
  75882. /**
  75883. * Set a vec3 in the shader from a Color3.
  75884. * @param name Define the name of the uniform as defined in the shader
  75885. * @param value Define the value to give to the uniform
  75886. * @return the material itself allowing "fluent" like uniform updates
  75887. */
  75888. setColor3(name: string, value: Color3): ShaderMaterial;
  75889. /**
  75890. * Set a vec3 array in the shader from a Color3 array.
  75891. * @param name Define the name of the uniform as defined in the shader
  75892. * @param value Define the value to give to the uniform
  75893. * @return the material itself allowing "fluent" like uniform updates
  75894. */
  75895. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75896. /**
  75897. * Set a vec4 in the shader from a Color4.
  75898. * @param name Define the name of the uniform as defined in the shader
  75899. * @param value Define the value to give to the uniform
  75900. * @return the material itself allowing "fluent" like uniform updates
  75901. */
  75902. setColor4(name: string, value: Color4): ShaderMaterial;
  75903. /**
  75904. * Set a vec2 in the shader from a Vector2.
  75905. * @param name Define the name of the uniform as defined in the shader
  75906. * @param value Define the value to give to the uniform
  75907. * @return the material itself allowing "fluent" like uniform updates
  75908. */
  75909. setVector2(name: string, value: Vector2): ShaderMaterial;
  75910. /**
  75911. * Set a vec3 in the shader from a Vector3.
  75912. * @param name Define the name of the uniform as defined in the shader
  75913. * @param value Define the value to give to the uniform
  75914. * @return the material itself allowing "fluent" like uniform updates
  75915. */
  75916. setVector3(name: string, value: Vector3): ShaderMaterial;
  75917. /**
  75918. * Set a vec4 in the shader from a Vector4.
  75919. * @param name Define the name of the uniform as defined in the shader
  75920. * @param value Define the value to give to the uniform
  75921. * @return the material itself allowing "fluent" like uniform updates
  75922. */
  75923. setVector4(name: string, value: Vector4): ShaderMaterial;
  75924. /**
  75925. * Set a mat4 in the shader from a Matrix.
  75926. * @param name Define the name of the uniform as defined in the shader
  75927. * @param value Define the value to give to the uniform
  75928. * @return the material itself allowing "fluent" like uniform updates
  75929. */
  75930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75931. /**
  75932. * Set a mat3 in the shader from a Float32Array.
  75933. * @param name Define the name of the uniform as defined in the shader
  75934. * @param value Define the value to give to the uniform
  75935. * @return the material itself allowing "fluent" like uniform updates
  75936. */
  75937. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75938. /**
  75939. * Set a mat2 in the shader from a Float32Array.
  75940. * @param name Define the name of the uniform as defined in the shader
  75941. * @param value Define the value to give to the uniform
  75942. * @return the material itself allowing "fluent" like uniform updates
  75943. */
  75944. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75945. /**
  75946. * Set a vec2 array in the shader from a number array.
  75947. * @param name Define the name of the uniform as defined in the shader
  75948. * @param value Define the value to give to the uniform
  75949. * @return the material itself allowing "fluent" like uniform updates
  75950. */
  75951. setArray2(name: string, value: number[]): ShaderMaterial;
  75952. /**
  75953. * Set a vec3 array in the shader from a number array.
  75954. * @param name Define the name of the uniform as defined in the shader
  75955. * @param value Define the value to give to the uniform
  75956. * @return the material itself allowing "fluent" like uniform updates
  75957. */
  75958. setArray3(name: string, value: number[]): ShaderMaterial;
  75959. private _checkCache;
  75960. /**
  75961. * Specifies that the submesh is ready to be used
  75962. * @param mesh defines the mesh to check
  75963. * @param subMesh defines which submesh to check
  75964. * @param useInstances specifies that instances should be used
  75965. * @returns a boolean indicating that the submesh is ready or not
  75966. */
  75967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75968. /**
  75969. * Checks if the material is ready to render the requested mesh
  75970. * @param mesh Define the mesh to render
  75971. * @param useInstances Define whether or not the material is used with instances
  75972. * @returns true if ready, otherwise false
  75973. */
  75974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75975. /**
  75976. * Binds the world matrix to the material
  75977. * @param world defines the world transformation matrix
  75978. */
  75979. bindOnlyWorldMatrix(world: Matrix): void;
  75980. /**
  75981. * Binds the material to the mesh
  75982. * @param world defines the world transformation matrix
  75983. * @param mesh defines the mesh to bind the material to
  75984. */
  75985. bind(world: Matrix, mesh?: Mesh): void;
  75986. /**
  75987. * Gets the active textures from the material
  75988. * @returns an array of textures
  75989. */
  75990. getActiveTextures(): BaseTexture[];
  75991. /**
  75992. * Specifies if the material uses a texture
  75993. * @param texture defines the texture to check against the material
  75994. * @returns a boolean specifying if the material uses the texture
  75995. */
  75996. hasTexture(texture: BaseTexture): boolean;
  75997. /**
  75998. * Makes a duplicate of the material, and gives it a new name
  75999. * @param name defines the new name for the duplicated material
  76000. * @returns the cloned material
  76001. */
  76002. clone(name: string): ShaderMaterial;
  76003. /**
  76004. * Disposes the material
  76005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76007. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76008. */
  76009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76010. /**
  76011. * Serializes this material in a JSON representation
  76012. * @returns the serialized material object
  76013. */
  76014. serialize(): any;
  76015. /**
  76016. * Creates a shader material from parsed shader material data
  76017. * @param source defines the JSON represnetation of the material
  76018. * @param scene defines the hosting scene
  76019. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76020. * @returns a new material
  76021. */
  76022. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76023. }
  76024. }
  76025. declare module BABYLON {
  76026. /** @hidden */
  76027. export var colorPixelShader: {
  76028. name: string;
  76029. shader: string;
  76030. };
  76031. }
  76032. declare module BABYLON {
  76033. /** @hidden */
  76034. export var colorVertexShader: {
  76035. name: string;
  76036. shader: string;
  76037. };
  76038. }
  76039. declare module BABYLON {
  76040. /**
  76041. * Line mesh
  76042. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76043. */
  76044. export class LinesMesh extends Mesh {
  76045. /**
  76046. * If vertex color should be applied to the mesh
  76047. */
  76048. useVertexColor?: boolean | undefined;
  76049. /**
  76050. * If vertex alpha should be applied to the mesh
  76051. */
  76052. useVertexAlpha?: boolean | undefined;
  76053. /**
  76054. * Color of the line (Default: White)
  76055. */
  76056. color: Color3;
  76057. /**
  76058. * Alpha of the line (Default: 1)
  76059. */
  76060. alpha: number;
  76061. /**
  76062. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76063. * This margin is expressed in world space coordinates, so its value may vary.
  76064. * Default value is 0.1
  76065. */
  76066. intersectionThreshold: number;
  76067. private _colorShader;
  76068. /**
  76069. * Creates a new LinesMesh
  76070. * @param name defines the name
  76071. * @param scene defines the hosting scene
  76072. * @param parent defines the parent mesh if any
  76073. * @param source defines the optional source LinesMesh used to clone data from
  76074. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76075. * When false, achieved by calling a clone(), also passing False.
  76076. * This will make creation of children, recursive.
  76077. * @param useVertexColor defines if this LinesMesh supports vertex color
  76078. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76079. */
  76080. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76081. /**
  76082. * If vertex color should be applied to the mesh
  76083. */
  76084. useVertexColor?: boolean | undefined,
  76085. /**
  76086. * If vertex alpha should be applied to the mesh
  76087. */
  76088. useVertexAlpha?: boolean | undefined);
  76089. private _addClipPlaneDefine;
  76090. private _removeClipPlaneDefine;
  76091. isReady(): boolean;
  76092. /**
  76093. * Returns the string "LineMesh"
  76094. */
  76095. getClassName(): string;
  76096. /**
  76097. * @hidden
  76098. */
  76099. /**
  76100. * @hidden
  76101. */
  76102. material: Material;
  76103. /**
  76104. * @hidden
  76105. */
  76106. readonly checkCollisions: boolean;
  76107. /** @hidden */
  76108. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76109. /** @hidden */
  76110. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76111. /**
  76112. * Disposes of the line mesh
  76113. * @param doNotRecurse If children should be disposed
  76114. */
  76115. dispose(doNotRecurse?: boolean): void;
  76116. /**
  76117. * Returns a new LineMesh object cloned from the current one.
  76118. */
  76119. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76120. /**
  76121. * Creates a new InstancedLinesMesh object from the mesh model.
  76122. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76123. * @param name defines the name of the new instance
  76124. * @returns a new InstancedLinesMesh
  76125. */
  76126. createInstance(name: string): InstancedLinesMesh;
  76127. }
  76128. /**
  76129. * Creates an instance based on a source LinesMesh
  76130. */
  76131. export class InstancedLinesMesh extends InstancedMesh {
  76132. /**
  76133. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76134. * This margin is expressed in world space coordinates, so its value may vary.
  76135. * Initilized with the intersectionThreshold value of the source LinesMesh
  76136. */
  76137. intersectionThreshold: number;
  76138. constructor(name: string, source: LinesMesh);
  76139. /**
  76140. * Returns the string "InstancedLinesMesh".
  76141. */
  76142. getClassName(): string;
  76143. }
  76144. }
  76145. declare module BABYLON {
  76146. /** @hidden */
  76147. export var linePixelShader: {
  76148. name: string;
  76149. shader: string;
  76150. };
  76151. }
  76152. declare module BABYLON {
  76153. /** @hidden */
  76154. export var lineVertexShader: {
  76155. name: string;
  76156. shader: string;
  76157. };
  76158. }
  76159. declare module BABYLON {
  76160. interface AbstractMesh {
  76161. /**
  76162. * Disables the mesh edge rendering mode
  76163. * @returns the currentAbstractMesh
  76164. */
  76165. disableEdgesRendering(): AbstractMesh;
  76166. /**
  76167. * Enables the edge rendering mode on the mesh.
  76168. * This mode makes the mesh edges visible
  76169. * @param epsilon defines the maximal distance between two angles to detect a face
  76170. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76171. * @returns the currentAbstractMesh
  76172. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76173. */
  76174. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76175. /**
  76176. * Gets the edgesRenderer associated with the mesh
  76177. */
  76178. edgesRenderer: Nullable<EdgesRenderer>;
  76179. }
  76180. interface LinesMesh {
  76181. /**
  76182. * Enables the edge rendering mode on the mesh.
  76183. * This mode makes the mesh edges visible
  76184. * @param epsilon defines the maximal distance between two angles to detect a face
  76185. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76186. * @returns the currentAbstractMesh
  76187. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76188. */
  76189. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76190. }
  76191. interface InstancedLinesMesh {
  76192. /**
  76193. * Enables the edge rendering mode on the mesh.
  76194. * This mode makes the mesh edges visible
  76195. * @param epsilon defines the maximal distance between two angles to detect a face
  76196. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76197. * @returns the current InstancedLinesMesh
  76198. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76199. */
  76200. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76201. }
  76202. /**
  76203. * Defines the minimum contract an Edges renderer should follow.
  76204. */
  76205. export interface IEdgesRenderer extends IDisposable {
  76206. /**
  76207. * Gets or sets a boolean indicating if the edgesRenderer is active
  76208. */
  76209. isEnabled: boolean;
  76210. /**
  76211. * Renders the edges of the attached mesh,
  76212. */
  76213. render(): void;
  76214. /**
  76215. * Checks wether or not the edges renderer is ready to render.
  76216. * @return true if ready, otherwise false.
  76217. */
  76218. isReady(): boolean;
  76219. }
  76220. /**
  76221. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76222. */
  76223. export class EdgesRenderer implements IEdgesRenderer {
  76224. /**
  76225. * Define the size of the edges with an orthographic camera
  76226. */
  76227. edgesWidthScalerForOrthographic: number;
  76228. /**
  76229. * Define the size of the edges with a perspective camera
  76230. */
  76231. edgesWidthScalerForPerspective: number;
  76232. protected _source: AbstractMesh;
  76233. protected _linesPositions: number[];
  76234. protected _linesNormals: number[];
  76235. protected _linesIndices: number[];
  76236. protected _epsilon: number;
  76237. protected _indicesCount: number;
  76238. protected _lineShader: ShaderMaterial;
  76239. protected _ib: WebGLBuffer;
  76240. protected _buffers: {
  76241. [key: string]: Nullable<VertexBuffer>;
  76242. };
  76243. protected _checkVerticesInsteadOfIndices: boolean;
  76244. private _meshRebuildObserver;
  76245. private _meshDisposeObserver;
  76246. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76247. isEnabled: boolean;
  76248. /**
  76249. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76250. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76251. * @param source Mesh used to create edges
  76252. * @param epsilon sum of angles in adjacency to check for edge
  76253. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76254. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76255. */
  76256. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76257. protected _prepareRessources(): void;
  76258. /** @hidden */
  76259. _rebuild(): void;
  76260. /**
  76261. * Releases the required resources for the edges renderer
  76262. */
  76263. dispose(): void;
  76264. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76265. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76266. /**
  76267. * Checks if the pair of p0 and p1 is en edge
  76268. * @param faceIndex
  76269. * @param edge
  76270. * @param faceNormals
  76271. * @param p0
  76272. * @param p1
  76273. * @private
  76274. */
  76275. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76276. /**
  76277. * push line into the position, normal and index buffer
  76278. * @protected
  76279. */
  76280. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76281. /**
  76282. * Generates lines edges from adjacencjes
  76283. * @private
  76284. */
  76285. _generateEdgesLines(): void;
  76286. /**
  76287. * Checks wether or not the edges renderer is ready to render.
  76288. * @return true if ready, otherwise false.
  76289. */
  76290. isReady(): boolean;
  76291. /**
  76292. * Renders the edges of the attached mesh,
  76293. */
  76294. render(): void;
  76295. }
  76296. /**
  76297. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76298. */
  76299. export class LineEdgesRenderer extends EdgesRenderer {
  76300. /**
  76301. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76302. * @param source LineMesh used to generate edges
  76303. * @param epsilon not important (specified angle for edge detection)
  76304. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76305. */
  76306. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76307. /**
  76308. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76309. */
  76310. _generateEdgesLines(): void;
  76311. }
  76312. }
  76313. declare module BABYLON {
  76314. /**
  76315. * This represents the object necessary to create a rendering group.
  76316. * This is exclusively used and created by the rendering manager.
  76317. * To modify the behavior, you use the available helpers in your scene or meshes.
  76318. * @hidden
  76319. */
  76320. export class RenderingGroup {
  76321. index: number;
  76322. private _scene;
  76323. private _opaqueSubMeshes;
  76324. private _transparentSubMeshes;
  76325. private _alphaTestSubMeshes;
  76326. private _depthOnlySubMeshes;
  76327. private _particleSystems;
  76328. private _spriteManagers;
  76329. private _opaqueSortCompareFn;
  76330. private _alphaTestSortCompareFn;
  76331. private _transparentSortCompareFn;
  76332. private _renderOpaque;
  76333. private _renderAlphaTest;
  76334. private _renderTransparent;
  76335. private _edgesRenderers;
  76336. onBeforeTransparentRendering: () => void;
  76337. /**
  76338. * Set the opaque sort comparison function.
  76339. * If null the sub meshes will be render in the order they were created
  76340. */
  76341. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76342. /**
  76343. * Set the alpha test sort comparison function.
  76344. * If null the sub meshes will be render in the order they were created
  76345. */
  76346. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76347. /**
  76348. * Set the transparent sort comparison function.
  76349. * If null the sub meshes will be render in the order they were created
  76350. */
  76351. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76352. /**
  76353. * Creates a new rendering group.
  76354. * @param index The rendering group index
  76355. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76356. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76357. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76358. */
  76359. 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>);
  76360. /**
  76361. * Render all the sub meshes contained in the group.
  76362. * @param customRenderFunction Used to override the default render behaviour of the group.
  76363. * @returns true if rendered some submeshes.
  76364. */
  76365. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76366. /**
  76367. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76368. * @param subMeshes The submeshes to render
  76369. */
  76370. private renderOpaqueSorted;
  76371. /**
  76372. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76373. * @param subMeshes The submeshes to render
  76374. */
  76375. private renderAlphaTestSorted;
  76376. /**
  76377. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76378. * @param subMeshes The submeshes to render
  76379. */
  76380. private renderTransparentSorted;
  76381. /**
  76382. * Renders the submeshes in a specified order.
  76383. * @param subMeshes The submeshes to sort before render
  76384. * @param sortCompareFn The comparison function use to sort
  76385. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76386. * @param transparent Specifies to activate blending if true
  76387. */
  76388. private static renderSorted;
  76389. /**
  76390. * Renders the submeshes in the order they were dispatched (no sort applied).
  76391. * @param subMeshes The submeshes to render
  76392. */
  76393. private static renderUnsorted;
  76394. /**
  76395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76396. * are rendered back to front if in the same alpha index.
  76397. *
  76398. * @param a The first submesh
  76399. * @param b The second submesh
  76400. * @returns The result of the comparison
  76401. */
  76402. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76403. /**
  76404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76405. * are rendered back to front.
  76406. *
  76407. * @param a The first submesh
  76408. * @param b The second submesh
  76409. * @returns The result of the comparison
  76410. */
  76411. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76412. /**
  76413. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76414. * are rendered front to back (prevent overdraw).
  76415. *
  76416. * @param a The first submesh
  76417. * @param b The second submesh
  76418. * @returns The result of the comparison
  76419. */
  76420. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76421. /**
  76422. * Resets the different lists of submeshes to prepare a new frame.
  76423. */
  76424. prepare(): void;
  76425. dispose(): void;
  76426. /**
  76427. * Inserts the submesh in its correct queue depending on its material.
  76428. * @param subMesh The submesh to dispatch
  76429. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76430. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76431. */
  76432. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76433. dispatchSprites(spriteManager: ISpriteManager): void;
  76434. dispatchParticles(particleSystem: IParticleSystem): void;
  76435. private _renderParticles;
  76436. private _renderSprites;
  76437. }
  76438. }
  76439. declare module BABYLON {
  76440. /**
  76441. * Interface describing the different options available in the rendering manager
  76442. * regarding Auto Clear between groups.
  76443. */
  76444. export interface IRenderingManagerAutoClearSetup {
  76445. /**
  76446. * Defines whether or not autoclear is enable.
  76447. */
  76448. autoClear: boolean;
  76449. /**
  76450. * Defines whether or not to autoclear the depth buffer.
  76451. */
  76452. depth: boolean;
  76453. /**
  76454. * Defines whether or not to autoclear the stencil buffer.
  76455. */
  76456. stencil: boolean;
  76457. }
  76458. /**
  76459. * This class is used by the onRenderingGroupObservable
  76460. */
  76461. export class RenderingGroupInfo {
  76462. /**
  76463. * The Scene that being rendered
  76464. */
  76465. scene: Scene;
  76466. /**
  76467. * The camera currently used for the rendering pass
  76468. */
  76469. camera: Nullable<Camera>;
  76470. /**
  76471. * The ID of the renderingGroup being processed
  76472. */
  76473. renderingGroupId: number;
  76474. }
  76475. /**
  76476. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76477. * It is enable to manage the different groups as well as the different necessary sort functions.
  76478. * This should not be used directly aside of the few static configurations
  76479. */
  76480. export class RenderingManager {
  76481. /**
  76482. * The max id used for rendering groups (not included)
  76483. */
  76484. static MAX_RENDERINGGROUPS: number;
  76485. /**
  76486. * The min id used for rendering groups (included)
  76487. */
  76488. static MIN_RENDERINGGROUPS: number;
  76489. /**
  76490. * Used to globally prevent autoclearing scenes.
  76491. */
  76492. static AUTOCLEAR: boolean;
  76493. /**
  76494. * @hidden
  76495. */
  76496. _useSceneAutoClearSetup: boolean;
  76497. private _scene;
  76498. private _renderingGroups;
  76499. private _depthStencilBufferAlreadyCleaned;
  76500. private _autoClearDepthStencil;
  76501. private _customOpaqueSortCompareFn;
  76502. private _customAlphaTestSortCompareFn;
  76503. private _customTransparentSortCompareFn;
  76504. private _renderingGroupInfo;
  76505. /**
  76506. * Instantiates a new rendering group for a particular scene
  76507. * @param scene Defines the scene the groups belongs to
  76508. */
  76509. constructor(scene: Scene);
  76510. private _clearDepthStencilBuffer;
  76511. /**
  76512. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76513. * @hidden
  76514. */
  76515. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76516. /**
  76517. * Resets the different information of the group to prepare a new frame
  76518. * @hidden
  76519. */
  76520. reset(): void;
  76521. /**
  76522. * Dispose and release the group and its associated resources.
  76523. * @hidden
  76524. */
  76525. dispose(): void;
  76526. /**
  76527. * Clear the info related to rendering groups preventing retention points during dispose.
  76528. */
  76529. freeRenderingGroups(): void;
  76530. private _prepareRenderingGroup;
  76531. /**
  76532. * Add a sprite manager to the rendering manager in order to render it this frame.
  76533. * @param spriteManager Define the sprite manager to render
  76534. */
  76535. dispatchSprites(spriteManager: ISpriteManager): void;
  76536. /**
  76537. * Add a particle system to the rendering manager in order to render it this frame.
  76538. * @param particleSystem Define the particle system to render
  76539. */
  76540. dispatchParticles(particleSystem: IParticleSystem): void;
  76541. /**
  76542. * Add a submesh to the manager in order to render it this frame
  76543. * @param subMesh The submesh to dispatch
  76544. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76545. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76546. */
  76547. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76548. /**
  76549. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76550. * This allowed control for front to back rendering or reversly depending of the special needs.
  76551. *
  76552. * @param renderingGroupId The rendering group id corresponding to its index
  76553. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76554. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76555. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76556. */
  76557. 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;
  76558. /**
  76559. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76560. *
  76561. * @param renderingGroupId The rendering group id corresponding to its index
  76562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76563. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76564. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76565. */
  76566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76567. /**
  76568. * Gets the current auto clear configuration for one rendering group of the rendering
  76569. * manager.
  76570. * @param index the rendering group index to get the information for
  76571. * @returns The auto clear setup for the requested rendering group
  76572. */
  76573. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76574. }
  76575. }
  76576. declare module BABYLON {
  76577. /**
  76578. * This Helps creating a texture that will be created from a camera in your scene.
  76579. * It is basically a dynamic texture that could be used to create special effects for instance.
  76580. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76581. */
  76582. export class RenderTargetTexture extends Texture {
  76583. isCube: boolean;
  76584. /**
  76585. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76586. */
  76587. static readonly REFRESHRATE_RENDER_ONCE: number;
  76588. /**
  76589. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76590. */
  76591. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76592. /**
  76593. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76594. * the central point of your effect and can save a lot of performances.
  76595. */
  76596. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76597. /**
  76598. * Use this predicate to dynamically define the list of mesh you want to render.
  76599. * If set, the renderList property will be overwritten.
  76600. */
  76601. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76602. private _renderList;
  76603. /**
  76604. * Use this list to define the list of mesh you want to render.
  76605. */
  76606. renderList: Nullable<Array<AbstractMesh>>;
  76607. private _hookArray;
  76608. /**
  76609. * Define if particles should be rendered in your texture.
  76610. */
  76611. renderParticles: boolean;
  76612. /**
  76613. * Define if sprites should be rendered in your texture.
  76614. */
  76615. renderSprites: boolean;
  76616. /**
  76617. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76618. */
  76619. coordinatesMode: number;
  76620. /**
  76621. * Define the camera used to render the texture.
  76622. */
  76623. activeCamera: Nullable<Camera>;
  76624. /**
  76625. * Override the render function of the texture with your own one.
  76626. */
  76627. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76628. /**
  76629. * Define if camera post processes should be use while rendering the texture.
  76630. */
  76631. useCameraPostProcesses: boolean;
  76632. /**
  76633. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76634. */
  76635. ignoreCameraViewport: boolean;
  76636. private _postProcessManager;
  76637. private _postProcesses;
  76638. private _resizeObserver;
  76639. /**
  76640. * An event triggered when the texture is unbind.
  76641. */
  76642. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76643. /**
  76644. * An event triggered when the texture is unbind.
  76645. */
  76646. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76647. private _onAfterUnbindObserver;
  76648. /**
  76649. * Set a after unbind callback in the texture.
  76650. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76651. */
  76652. onAfterUnbind: () => void;
  76653. /**
  76654. * An event triggered before rendering the texture
  76655. */
  76656. onBeforeRenderObservable: Observable<number>;
  76657. private _onBeforeRenderObserver;
  76658. /**
  76659. * Set a before render callback in the texture.
  76660. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76661. */
  76662. onBeforeRender: (faceIndex: number) => void;
  76663. /**
  76664. * An event triggered after rendering the texture
  76665. */
  76666. onAfterRenderObservable: Observable<number>;
  76667. private _onAfterRenderObserver;
  76668. /**
  76669. * Set a after render callback in the texture.
  76670. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76671. */
  76672. onAfterRender: (faceIndex: number) => void;
  76673. /**
  76674. * An event triggered after the texture clear
  76675. */
  76676. onClearObservable: Observable<Engine>;
  76677. private _onClearObserver;
  76678. /**
  76679. * Set a clear callback in the texture.
  76680. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76681. */
  76682. onClear: (Engine: Engine) => void;
  76683. /**
  76684. * Define the clear color of the Render Target if it should be different from the scene.
  76685. */
  76686. clearColor: Color4;
  76687. protected _size: number | {
  76688. width: number;
  76689. height: number;
  76690. };
  76691. protected _initialSizeParameter: number | {
  76692. width: number;
  76693. height: number;
  76694. } | {
  76695. ratio: number;
  76696. };
  76697. protected _sizeRatio: Nullable<number>;
  76698. /** @hidden */
  76699. _generateMipMaps: boolean;
  76700. protected _renderingManager: RenderingManager;
  76701. /** @hidden */
  76702. _waitingRenderList: string[];
  76703. protected _doNotChangeAspectRatio: boolean;
  76704. protected _currentRefreshId: number;
  76705. protected _refreshRate: number;
  76706. protected _textureMatrix: Matrix;
  76707. protected _samples: number;
  76708. protected _renderTargetOptions: RenderTargetCreationOptions;
  76709. /**
  76710. * Gets render target creation options that were used.
  76711. */
  76712. readonly renderTargetOptions: RenderTargetCreationOptions;
  76713. protected _engine: Engine;
  76714. protected _onRatioRescale(): void;
  76715. /**
  76716. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76717. * It must define where the camera used to render the texture is set
  76718. */
  76719. boundingBoxPosition: Vector3;
  76720. private _boundingBoxSize;
  76721. /**
  76722. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76723. * When defined, the cubemap will switch to local mode
  76724. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76725. * @example https://www.babylonjs-playground.com/#RNASML
  76726. */
  76727. boundingBoxSize: Vector3;
  76728. /**
  76729. * In case the RTT has been created with a depth texture, get the associated
  76730. * depth texture.
  76731. * Otherwise, return null.
  76732. */
  76733. depthStencilTexture: Nullable<InternalTexture>;
  76734. /**
  76735. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76736. * or used a shadow, depth texture...
  76737. * @param name The friendly name of the texture
  76738. * @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)
  76739. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76740. * @param generateMipMaps True if mip maps need to be generated after render.
  76741. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76742. * @param type The type of the buffer in the RTT (int, half float, float...)
  76743. * @param isCube True if a cube texture needs to be created
  76744. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76745. * @param generateDepthBuffer True to generate a depth buffer
  76746. * @param generateStencilBuffer True to generate a stencil buffer
  76747. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76748. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76749. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76750. */
  76751. constructor(name: string, size: number | {
  76752. width: number;
  76753. height: number;
  76754. } | {
  76755. ratio: number;
  76756. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76757. /**
  76758. * Creates a depth stencil texture.
  76759. * This is only available in WebGL 2 or with the depth texture extension available.
  76760. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76761. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76762. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76763. */
  76764. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76765. private _processSizeParameter;
  76766. /**
  76767. * Define the number of samples to use in case of MSAA.
  76768. * It defaults to one meaning no MSAA has been enabled.
  76769. */
  76770. samples: number;
  76771. /**
  76772. * Resets the refresh counter of the texture and start bak from scratch.
  76773. * Could be useful to regenerate the texture if it is setup to render only once.
  76774. */
  76775. resetRefreshCounter(): void;
  76776. /**
  76777. * Define the refresh rate of the texture or the rendering frequency.
  76778. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76779. */
  76780. refreshRate: number;
  76781. /**
  76782. * Adds a post process to the render target rendering passes.
  76783. * @param postProcess define the post process to add
  76784. */
  76785. addPostProcess(postProcess: PostProcess): void;
  76786. /**
  76787. * Clear all the post processes attached to the render target
  76788. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76789. */
  76790. clearPostProcesses(dispose?: boolean): void;
  76791. /**
  76792. * Remove one of the post process from the list of attached post processes to the texture
  76793. * @param postProcess define the post process to remove from the list
  76794. */
  76795. removePostProcess(postProcess: PostProcess): void;
  76796. /** @hidden */
  76797. _shouldRender(): boolean;
  76798. /**
  76799. * Gets the actual render size of the texture.
  76800. * @returns the width of the render size
  76801. */
  76802. getRenderSize(): number;
  76803. /**
  76804. * Gets the actual render width of the texture.
  76805. * @returns the width of the render size
  76806. */
  76807. getRenderWidth(): number;
  76808. /**
  76809. * Gets the actual render height of the texture.
  76810. * @returns the height of the render size
  76811. */
  76812. getRenderHeight(): number;
  76813. /**
  76814. * Get if the texture can be rescaled or not.
  76815. */
  76816. readonly canRescale: boolean;
  76817. /**
  76818. * Resize the texture using a ratio.
  76819. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76820. */
  76821. scale(ratio: number): void;
  76822. /**
  76823. * Get the texture reflection matrix used to rotate/transform the reflection.
  76824. * @returns the reflection matrix
  76825. */
  76826. getReflectionTextureMatrix(): Matrix;
  76827. /**
  76828. * Resize the texture to a new desired size.
  76829. * Be carrefull as it will recreate all the data in the new texture.
  76830. * @param size Define the new size. It can be:
  76831. * - a number for squared texture,
  76832. * - an object containing { width: number, height: number }
  76833. * - or an object containing a ratio { ratio: number }
  76834. */
  76835. resize(size: number | {
  76836. width: number;
  76837. height: number;
  76838. } | {
  76839. ratio: number;
  76840. }): void;
  76841. /**
  76842. * Renders all the objects from the render list into the texture.
  76843. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76844. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76845. */
  76846. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76847. private _bestReflectionRenderTargetDimension;
  76848. /**
  76849. * @hidden
  76850. * @param faceIndex face index to bind to if this is a cubetexture
  76851. */
  76852. _bindFrameBuffer(faceIndex?: number): void;
  76853. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76854. private renderToTarget;
  76855. /**
  76856. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76857. * This allowed control for front to back rendering or reversly depending of the special needs.
  76858. *
  76859. * @param renderingGroupId The rendering group id corresponding to its index
  76860. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76861. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76862. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76863. */
  76864. 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;
  76865. /**
  76866. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76867. *
  76868. * @param renderingGroupId The rendering group id corresponding to its index
  76869. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76870. */
  76871. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76872. /**
  76873. * Clones the texture.
  76874. * @returns the cloned texture
  76875. */
  76876. clone(): RenderTargetTexture;
  76877. /**
  76878. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76879. * @returns The JSON representation of the texture
  76880. */
  76881. serialize(): any;
  76882. /**
  76883. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76884. */
  76885. disposeFramebufferObjects(): void;
  76886. /**
  76887. * Dispose the texture and release its associated resources.
  76888. */
  76889. dispose(): void;
  76890. /** @hidden */
  76891. _rebuild(): void;
  76892. /**
  76893. * Clear the info related to rendering groups preventing retention point in material dispose.
  76894. */
  76895. freeRenderingGroups(): void;
  76896. /**
  76897. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76898. * @returns the view count
  76899. */
  76900. getViewCount(): number;
  76901. }
  76902. }
  76903. declare module BABYLON {
  76904. /**
  76905. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76906. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76907. * You can then easily use it as a reflectionTexture on a flat surface.
  76908. * In case the surface is not a plane, please consider relying on reflection probes.
  76909. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76910. */
  76911. export class MirrorTexture extends RenderTargetTexture {
  76912. private scene;
  76913. /**
  76914. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76915. * 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.
  76916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76917. */
  76918. mirrorPlane: Plane;
  76919. /**
  76920. * Define the blur ratio used to blur the reflection if needed.
  76921. */
  76922. blurRatio: number;
  76923. /**
  76924. * Define the adaptive blur kernel used to blur the reflection if needed.
  76925. * This will autocompute the closest best match for the `blurKernel`
  76926. */
  76927. adaptiveBlurKernel: number;
  76928. /**
  76929. * Define the blur kernel used to blur the reflection if needed.
  76930. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76931. */
  76932. blurKernel: number;
  76933. /**
  76934. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76935. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76936. */
  76937. blurKernelX: number;
  76938. /**
  76939. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76940. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76941. */
  76942. blurKernelY: number;
  76943. private _autoComputeBlurKernel;
  76944. protected _onRatioRescale(): void;
  76945. private _updateGammaSpace;
  76946. private _imageProcessingConfigChangeObserver;
  76947. private _transformMatrix;
  76948. private _mirrorMatrix;
  76949. private _savedViewMatrix;
  76950. private _blurX;
  76951. private _blurY;
  76952. private _adaptiveBlurKernel;
  76953. private _blurKernelX;
  76954. private _blurKernelY;
  76955. private _blurRatio;
  76956. /**
  76957. * Instantiates a Mirror Texture.
  76958. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76959. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76960. * You can then easily use it as a reflectionTexture on a flat surface.
  76961. * In case the surface is not a plane, please consider relying on reflection probes.
  76962. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76963. * @param name
  76964. * @param size
  76965. * @param scene
  76966. * @param generateMipMaps
  76967. * @param type
  76968. * @param samplingMode
  76969. * @param generateDepthBuffer
  76970. */
  76971. constructor(name: string, size: number | {
  76972. width: number;
  76973. height: number;
  76974. } | {
  76975. ratio: number;
  76976. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76977. private _preparePostProcesses;
  76978. /**
  76979. * Clone the mirror texture.
  76980. * @returns the cloned texture
  76981. */
  76982. clone(): MirrorTexture;
  76983. /**
  76984. * Serialize the texture to a JSON representation you could use in Parse later on
  76985. * @returns the serialized JSON representation
  76986. */
  76987. serialize(): any;
  76988. /**
  76989. * Dispose the texture and release its associated resources.
  76990. */
  76991. dispose(): void;
  76992. }
  76993. }
  76994. declare module BABYLON {
  76995. /**
  76996. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76997. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76998. */
  76999. export class Texture extends BaseTexture {
  77000. /** @hidden */
  77001. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77002. /** @hidden */
  77003. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77004. /** @hidden */
  77005. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77006. /** nearest is mag = nearest and min = nearest and mip = linear */
  77007. static readonly NEAREST_SAMPLINGMODE: number;
  77008. /** nearest is mag = nearest and min = nearest and mip = linear */
  77009. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77010. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77011. static readonly BILINEAR_SAMPLINGMODE: number;
  77012. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77013. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77014. /** Trilinear is mag = linear and min = linear and mip = linear */
  77015. static readonly TRILINEAR_SAMPLINGMODE: number;
  77016. /** Trilinear is mag = linear and min = linear and mip = linear */
  77017. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77018. /** mag = nearest and min = nearest and mip = nearest */
  77019. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77020. /** mag = nearest and min = linear and mip = nearest */
  77021. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77022. /** mag = nearest and min = linear and mip = linear */
  77023. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77024. /** mag = nearest and min = linear and mip = none */
  77025. static readonly NEAREST_LINEAR: number;
  77026. /** mag = nearest and min = nearest and mip = none */
  77027. static readonly NEAREST_NEAREST: number;
  77028. /** mag = linear and min = nearest and mip = nearest */
  77029. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77030. /** mag = linear and min = nearest and mip = linear */
  77031. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77032. /** mag = linear and min = linear and mip = none */
  77033. static readonly LINEAR_LINEAR: number;
  77034. /** mag = linear and min = nearest and mip = none */
  77035. static readonly LINEAR_NEAREST: number;
  77036. /** Explicit coordinates mode */
  77037. static readonly EXPLICIT_MODE: number;
  77038. /** Spherical coordinates mode */
  77039. static readonly SPHERICAL_MODE: number;
  77040. /** Planar coordinates mode */
  77041. static readonly PLANAR_MODE: number;
  77042. /** Cubic coordinates mode */
  77043. static readonly CUBIC_MODE: number;
  77044. /** Projection coordinates mode */
  77045. static readonly PROJECTION_MODE: number;
  77046. /** Inverse Cubic coordinates mode */
  77047. static readonly SKYBOX_MODE: number;
  77048. /** Inverse Cubic coordinates mode */
  77049. static readonly INVCUBIC_MODE: number;
  77050. /** Equirectangular coordinates mode */
  77051. static readonly EQUIRECTANGULAR_MODE: number;
  77052. /** Equirectangular Fixed coordinates mode */
  77053. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77054. /** Equirectangular Fixed Mirrored coordinates mode */
  77055. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77056. /** Texture is not repeating outside of 0..1 UVs */
  77057. static readonly CLAMP_ADDRESSMODE: number;
  77058. /** Texture is repeating outside of 0..1 UVs */
  77059. static readonly WRAP_ADDRESSMODE: number;
  77060. /** Texture is repeating and mirrored */
  77061. static readonly MIRROR_ADDRESSMODE: number;
  77062. /**
  77063. * 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
  77064. */
  77065. static UseSerializedUrlIfAny: boolean;
  77066. /**
  77067. * Define the url of the texture.
  77068. */
  77069. url: Nullable<string>;
  77070. /**
  77071. * Define an offset on the texture to offset the u coordinates of the UVs
  77072. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77073. */
  77074. uOffset: number;
  77075. /**
  77076. * Define an offset on the texture to offset the v coordinates of the UVs
  77077. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77078. */
  77079. vOffset: number;
  77080. /**
  77081. * Define an offset on the texture to scale the u coordinates of the UVs
  77082. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77083. */
  77084. uScale: number;
  77085. /**
  77086. * Define an offset on the texture to scale the v coordinates of the UVs
  77087. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77088. */
  77089. vScale: number;
  77090. /**
  77091. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77092. * @see http://doc.babylonjs.com/how_to/more_materials
  77093. */
  77094. uAng: number;
  77095. /**
  77096. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77097. * @see http://doc.babylonjs.com/how_to/more_materials
  77098. */
  77099. vAng: number;
  77100. /**
  77101. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77102. * @see http://doc.babylonjs.com/how_to/more_materials
  77103. */
  77104. wAng: number;
  77105. /**
  77106. * Defines the center of rotation (U)
  77107. */
  77108. uRotationCenter: number;
  77109. /**
  77110. * Defines the center of rotation (V)
  77111. */
  77112. vRotationCenter: number;
  77113. /**
  77114. * Defines the center of rotation (W)
  77115. */
  77116. wRotationCenter: number;
  77117. /**
  77118. * Are mip maps generated for this texture or not.
  77119. */
  77120. readonly noMipmap: boolean;
  77121. /**
  77122. * List of inspectable custom properties (used by the Inspector)
  77123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77124. */
  77125. inspectableCustomProperties: IInspectable[];
  77126. private _noMipmap;
  77127. /** @hidden */
  77128. _invertY: boolean;
  77129. private _rowGenerationMatrix;
  77130. private _cachedTextureMatrix;
  77131. private _projectionModeMatrix;
  77132. private _t0;
  77133. private _t1;
  77134. private _t2;
  77135. private _cachedUOffset;
  77136. private _cachedVOffset;
  77137. private _cachedUScale;
  77138. private _cachedVScale;
  77139. private _cachedUAng;
  77140. private _cachedVAng;
  77141. private _cachedWAng;
  77142. private _cachedProjectionMatrixId;
  77143. private _cachedCoordinatesMode;
  77144. /** @hidden */
  77145. protected _initialSamplingMode: number;
  77146. /** @hidden */
  77147. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77148. private _deleteBuffer;
  77149. protected _format: Nullable<number>;
  77150. private _delayedOnLoad;
  77151. private _delayedOnError;
  77152. /**
  77153. * Observable triggered once the texture has been loaded.
  77154. */
  77155. onLoadObservable: Observable<Texture>;
  77156. protected _isBlocking: boolean;
  77157. /**
  77158. * Is the texture preventing material to render while loading.
  77159. * If false, a default texture will be used instead of the loading one during the preparation step.
  77160. */
  77161. isBlocking: boolean;
  77162. /**
  77163. * Get the current sampling mode associated with the texture.
  77164. */
  77165. readonly samplingMode: number;
  77166. /**
  77167. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77168. */
  77169. readonly invertY: boolean;
  77170. /**
  77171. * Instantiates a new texture.
  77172. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77173. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77174. * @param url define the url of the picture to load as a texture
  77175. * @param scene define the scene the texture will belong to
  77176. * @param noMipmap define if the texture will require mip maps or not
  77177. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77178. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77179. * @param onLoad define a callback triggered when the texture has been loaded
  77180. * @param onError define a callback triggered when an error occurred during the loading session
  77181. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77182. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77183. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77184. */
  77185. 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);
  77186. /**
  77187. * Update the url (and optional buffer) of this texture if url was null during construction.
  77188. * @param url the url of the texture
  77189. * @param buffer the buffer of the texture (defaults to null)
  77190. * @param onLoad callback called when the texture is loaded (defaults to null)
  77191. */
  77192. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77193. /**
  77194. * Finish the loading sequence of a texture flagged as delayed load.
  77195. * @hidden
  77196. */
  77197. delayLoad(): void;
  77198. private _prepareRowForTextureGeneration;
  77199. /**
  77200. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77201. * @returns the transform matrix of the texture.
  77202. */
  77203. getTextureMatrix(): Matrix;
  77204. /**
  77205. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77206. * @returns The reflection texture transform
  77207. */
  77208. getReflectionTextureMatrix(): Matrix;
  77209. /**
  77210. * Clones the texture.
  77211. * @returns the cloned texture
  77212. */
  77213. clone(): Texture;
  77214. /**
  77215. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77216. * @returns The JSON representation of the texture
  77217. */
  77218. serialize(): any;
  77219. /**
  77220. * Get the current class name of the texture useful for serialization or dynamic coding.
  77221. * @returns "Texture"
  77222. */
  77223. getClassName(): string;
  77224. /**
  77225. * Dispose the texture and release its associated resources.
  77226. */
  77227. dispose(): void;
  77228. /**
  77229. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77230. * @param parsedTexture Define the JSON representation of the texture
  77231. * @param scene Define the scene the parsed texture should be instantiated in
  77232. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77233. * @returns The parsed texture if successful
  77234. */
  77235. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77236. /**
  77237. * Creates a texture from its base 64 representation.
  77238. * @param data Define the base64 payload without the data: prefix
  77239. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77240. * @param scene Define the scene the texture should belong to
  77241. * @param noMipmap Forces the texture to not create mip map information if true
  77242. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77243. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77244. * @param onLoad define a callback triggered when the texture has been loaded
  77245. * @param onError define a callback triggered when an error occurred during the loading session
  77246. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77247. * @returns the created texture
  77248. */
  77249. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77250. /**
  77251. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77252. * @param data Define the base64 payload without the data: prefix
  77253. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77254. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77255. * @param scene Define the scene the texture should belong to
  77256. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77257. * @param noMipmap Forces the texture to not create mip map information if true
  77258. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77259. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77260. * @param onLoad define a callback triggered when the texture has been loaded
  77261. * @param onError define a callback triggered when an error occurred during the loading session
  77262. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77263. * @returns the created texture
  77264. */
  77265. 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;
  77266. }
  77267. }
  77268. declare module BABYLON {
  77269. /**
  77270. * Raw texture can help creating a texture directly from an array of data.
  77271. * This can be super useful if you either get the data from an uncompressed source or
  77272. * if you wish to create your texture pixel by pixel.
  77273. */
  77274. export class RawTexture extends Texture {
  77275. /**
  77276. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77277. */
  77278. format: number;
  77279. private _engine;
  77280. /**
  77281. * Instantiates a new RawTexture.
  77282. * Raw texture can help creating a texture directly from an array of data.
  77283. * This can be super useful if you either get the data from an uncompressed source or
  77284. * if you wish to create your texture pixel by pixel.
  77285. * @param data define the array of data to use to create the texture
  77286. * @param width define the width of the texture
  77287. * @param height define the height of the texture
  77288. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77289. * @param scene define the scene the texture belongs to
  77290. * @param generateMipMaps define whether mip maps should be generated or not
  77291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77293. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77294. */
  77295. constructor(data: ArrayBufferView, width: number, height: number,
  77296. /**
  77297. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77298. */
  77299. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77300. /**
  77301. * Updates the texture underlying data.
  77302. * @param data Define the new data of the texture
  77303. */
  77304. update(data: ArrayBufferView): void;
  77305. /**
  77306. * Creates a luminance texture from some data.
  77307. * @param data Define the texture data
  77308. * @param width Define the width of the texture
  77309. * @param height Define the height of the texture
  77310. * @param scene Define the scene the texture belongs to
  77311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77314. * @returns the luminance texture
  77315. */
  77316. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77317. /**
  77318. * Creates a luminance alpha texture from some data.
  77319. * @param data Define the texture data
  77320. * @param width Define the width of the texture
  77321. * @param height Define the height of the texture
  77322. * @param scene Define the scene the texture belongs to
  77323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77326. * @returns the luminance alpha texture
  77327. */
  77328. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77329. /**
  77330. * Creates an alpha texture from some data.
  77331. * @param data Define the texture data
  77332. * @param width Define the width of the texture
  77333. * @param height Define the height of the texture
  77334. * @param scene Define the scene the texture belongs to
  77335. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77338. * @returns the alpha texture
  77339. */
  77340. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77341. /**
  77342. * Creates a RGB texture from some data.
  77343. * @param data Define the texture data
  77344. * @param width Define the width of the texture
  77345. * @param height Define the height of the texture
  77346. * @param scene Define the scene the texture belongs to
  77347. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77351. * @returns the RGB alpha texture
  77352. */
  77353. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77354. /**
  77355. * Creates a RGBA texture from some data.
  77356. * @param data Define the texture data
  77357. * @param width Define the width of the texture
  77358. * @param height Define the height of the texture
  77359. * @param scene Define the scene the texture belongs to
  77360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77363. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77364. * @returns the RGBA texture
  77365. */
  77366. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77367. /**
  77368. * Creates a R texture from some data.
  77369. * @param data Define the texture data
  77370. * @param width Define the width of the texture
  77371. * @param height Define the height of the texture
  77372. * @param scene Define the scene the texture belongs to
  77373. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77374. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77375. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77376. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77377. * @returns the R texture
  77378. */
  77379. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77380. }
  77381. }
  77382. declare module BABYLON {
  77383. /**
  77384. * Defines a runtime animation
  77385. */
  77386. export class RuntimeAnimation {
  77387. private _events;
  77388. /**
  77389. * The current frame of the runtime animation
  77390. */
  77391. private _currentFrame;
  77392. /**
  77393. * The animation used by the runtime animation
  77394. */
  77395. private _animation;
  77396. /**
  77397. * The target of the runtime animation
  77398. */
  77399. private _target;
  77400. /**
  77401. * The initiating animatable
  77402. */
  77403. private _host;
  77404. /**
  77405. * The original value of the runtime animation
  77406. */
  77407. private _originalValue;
  77408. /**
  77409. * The original blend value of the runtime animation
  77410. */
  77411. private _originalBlendValue;
  77412. /**
  77413. * The offsets cache of the runtime animation
  77414. */
  77415. private _offsetsCache;
  77416. /**
  77417. * The high limits cache of the runtime animation
  77418. */
  77419. private _highLimitsCache;
  77420. /**
  77421. * Specifies if the runtime animation has been stopped
  77422. */
  77423. private _stopped;
  77424. /**
  77425. * The blending factor of the runtime animation
  77426. */
  77427. private _blendingFactor;
  77428. /**
  77429. * The BabylonJS scene
  77430. */
  77431. private _scene;
  77432. /**
  77433. * The current value of the runtime animation
  77434. */
  77435. private _currentValue;
  77436. /** @hidden */
  77437. _workValue: any;
  77438. /**
  77439. * The active target of the runtime animation
  77440. */
  77441. private _activeTarget;
  77442. /**
  77443. * The target path of the runtime animation
  77444. */
  77445. private _targetPath;
  77446. /**
  77447. * The weight of the runtime animation
  77448. */
  77449. private _weight;
  77450. /**
  77451. * The ratio offset of the runtime animation
  77452. */
  77453. private _ratioOffset;
  77454. /**
  77455. * The previous delay of the runtime animation
  77456. */
  77457. private _previousDelay;
  77458. /**
  77459. * The previous ratio of the runtime animation
  77460. */
  77461. private _previousRatio;
  77462. /**
  77463. * Gets the current frame of the runtime animation
  77464. */
  77465. readonly currentFrame: number;
  77466. /**
  77467. * Gets the weight of the runtime animation
  77468. */
  77469. readonly weight: number;
  77470. /**
  77471. * Gets the current value of the runtime animation
  77472. */
  77473. readonly currentValue: any;
  77474. /**
  77475. * Gets the target path of the runtime animation
  77476. */
  77477. readonly targetPath: string;
  77478. /**
  77479. * Gets the actual target of the runtime animation
  77480. */
  77481. readonly target: any;
  77482. /**
  77483. * Create a new RuntimeAnimation object
  77484. * @param target defines the target of the animation
  77485. * @param animation defines the source animation object
  77486. * @param scene defines the hosting scene
  77487. * @param host defines the initiating Animatable
  77488. */
  77489. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77490. /**
  77491. * Gets the animation from the runtime animation
  77492. */
  77493. readonly animation: Animation;
  77494. /**
  77495. * Resets the runtime animation to the beginning
  77496. * @param restoreOriginal defines whether to restore the target property to the original value
  77497. */
  77498. reset(restoreOriginal?: boolean): void;
  77499. /**
  77500. * Specifies if the runtime animation is stopped
  77501. * @returns Boolean specifying if the runtime animation is stopped
  77502. */
  77503. isStopped(): boolean;
  77504. /**
  77505. * Disposes of the runtime animation
  77506. */
  77507. dispose(): void;
  77508. /**
  77509. * Interpolates the animation from the current frame
  77510. * @param currentFrame The frame to interpolate the animation to
  77511. * @param repeatCount The number of times that the animation should loop
  77512. * @param loopMode The type of looping mode to use
  77513. * @param offsetValue Animation offset value
  77514. * @param highLimitValue The high limit value
  77515. * @returns The interpolated value
  77516. */
  77517. private _interpolate;
  77518. /**
  77519. * Apply the interpolated value to the target
  77520. * @param currentValue defines the value computed by the animation
  77521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77522. */
  77523. setValue(currentValue: any, weight?: number): void;
  77524. private _setValue;
  77525. /**
  77526. * Gets the loop pmode of the runtime animation
  77527. * @returns Loop Mode
  77528. */
  77529. private _getCorrectLoopMode;
  77530. /**
  77531. * Move the current animation to a given frame
  77532. * @param frame defines the frame to move to
  77533. */
  77534. goToFrame(frame: number): void;
  77535. /**
  77536. * @hidden Internal use only
  77537. */
  77538. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77539. /**
  77540. * Execute the current animation
  77541. * @param delay defines the delay to add to the current frame
  77542. * @param from defines the lower bound of the animation range
  77543. * @param to defines the upper bound of the animation range
  77544. * @param loop defines if the current animation must loop
  77545. * @param speedRatio defines the current speed ratio
  77546. * @param weight defines the weight of the animation (default is -1 so no weight)
  77547. * @param onLoop optional callback called when animation loops
  77548. * @returns a boolean indicating if the animation is running
  77549. */
  77550. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77551. }
  77552. }
  77553. declare module BABYLON {
  77554. /**
  77555. * Class used to store an actual running animation
  77556. */
  77557. export class Animatable {
  77558. /** defines the target object */
  77559. target: any;
  77560. /** defines the starting frame number (default is 0) */
  77561. fromFrame: number;
  77562. /** defines the ending frame number (default is 100) */
  77563. toFrame: number;
  77564. /** defines if the animation must loop (default is false) */
  77565. loopAnimation: boolean;
  77566. /** defines a callback to call when animation ends if it is not looping */
  77567. onAnimationEnd?: (() => void) | null | undefined;
  77568. /** defines a callback to call when animation loops */
  77569. onAnimationLoop?: (() => void) | null | undefined;
  77570. private _localDelayOffset;
  77571. private _pausedDelay;
  77572. private _runtimeAnimations;
  77573. private _paused;
  77574. private _scene;
  77575. private _speedRatio;
  77576. private _weight;
  77577. private _syncRoot;
  77578. /**
  77579. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77580. * This will only apply for non looping animation (default is true)
  77581. */
  77582. disposeOnEnd: boolean;
  77583. /**
  77584. * Gets a boolean indicating if the animation has started
  77585. */
  77586. animationStarted: boolean;
  77587. /**
  77588. * Observer raised when the animation ends
  77589. */
  77590. onAnimationEndObservable: Observable<Animatable>;
  77591. /**
  77592. * Observer raised when the animation loops
  77593. */
  77594. onAnimationLoopObservable: Observable<Animatable>;
  77595. /**
  77596. * Gets the root Animatable used to synchronize and normalize animations
  77597. */
  77598. readonly syncRoot: Animatable;
  77599. /**
  77600. * Gets the current frame of the first RuntimeAnimation
  77601. * Used to synchronize Animatables
  77602. */
  77603. readonly masterFrame: number;
  77604. /**
  77605. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77606. */
  77607. weight: number;
  77608. /**
  77609. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77610. */
  77611. speedRatio: number;
  77612. /**
  77613. * Creates a new Animatable
  77614. * @param scene defines the hosting scene
  77615. * @param target defines the target object
  77616. * @param fromFrame defines the starting frame number (default is 0)
  77617. * @param toFrame defines the ending frame number (default is 100)
  77618. * @param loopAnimation defines if the animation must loop (default is false)
  77619. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77620. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77621. * @param animations defines a group of animation to add to the new Animatable
  77622. * @param onAnimationLoop defines a callback to call when animation loops
  77623. */
  77624. constructor(scene: Scene,
  77625. /** defines the target object */
  77626. target: any,
  77627. /** defines the starting frame number (default is 0) */
  77628. fromFrame?: number,
  77629. /** defines the ending frame number (default is 100) */
  77630. toFrame?: number,
  77631. /** defines if the animation must loop (default is false) */
  77632. loopAnimation?: boolean, speedRatio?: number,
  77633. /** defines a callback to call when animation ends if it is not looping */
  77634. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77635. /** defines a callback to call when animation loops */
  77636. onAnimationLoop?: (() => void) | null | undefined);
  77637. /**
  77638. * Synchronize and normalize current Animatable with a source Animatable
  77639. * This is useful when using animation weights and when animations are not of the same length
  77640. * @param root defines the root Animatable to synchronize with
  77641. * @returns the current Animatable
  77642. */
  77643. syncWith(root: Animatable): Animatable;
  77644. /**
  77645. * Gets the list of runtime animations
  77646. * @returns an array of RuntimeAnimation
  77647. */
  77648. getAnimations(): RuntimeAnimation[];
  77649. /**
  77650. * Adds more animations to the current animatable
  77651. * @param target defines the target of the animations
  77652. * @param animations defines the new animations to add
  77653. */
  77654. appendAnimations(target: any, animations: Animation[]): void;
  77655. /**
  77656. * Gets the source animation for a specific property
  77657. * @param property defines the propertyu to look for
  77658. * @returns null or the source animation for the given property
  77659. */
  77660. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77661. /**
  77662. * Gets the runtime animation for a specific property
  77663. * @param property defines the propertyu to look for
  77664. * @returns null or the runtime animation for the given property
  77665. */
  77666. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77667. /**
  77668. * Resets the animatable to its original state
  77669. */
  77670. reset(): void;
  77671. /**
  77672. * Allows the animatable to blend with current running animations
  77673. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77674. * @param blendingSpeed defines the blending speed to use
  77675. */
  77676. enableBlending(blendingSpeed: number): void;
  77677. /**
  77678. * Disable animation blending
  77679. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77680. */
  77681. disableBlending(): void;
  77682. /**
  77683. * Jump directly to a given frame
  77684. * @param frame defines the frame to jump to
  77685. */
  77686. goToFrame(frame: number): void;
  77687. /**
  77688. * Pause the animation
  77689. */
  77690. pause(): void;
  77691. /**
  77692. * Restart the animation
  77693. */
  77694. restart(): void;
  77695. private _raiseOnAnimationEnd;
  77696. /**
  77697. * Stop and delete the current animation
  77698. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77699. * @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)
  77700. */
  77701. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77702. /**
  77703. * Wait asynchronously for the animation to end
  77704. * @returns a promise which will be fullfilled when the animation ends
  77705. */
  77706. waitAsync(): Promise<Animatable>;
  77707. /** @hidden */
  77708. _animate(delay: number): boolean;
  77709. }
  77710. interface Scene {
  77711. /** @hidden */
  77712. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77713. /** @hidden */
  77714. _processLateAnimationBindingsForMatrices(holder: {
  77715. totalWeight: number;
  77716. animations: RuntimeAnimation[];
  77717. originalValue: Matrix;
  77718. }): any;
  77719. /** @hidden */
  77720. _processLateAnimationBindingsForQuaternions(holder: {
  77721. totalWeight: number;
  77722. animations: RuntimeAnimation[];
  77723. originalValue: Quaternion;
  77724. }, refQuaternion: Quaternion): Quaternion;
  77725. /** @hidden */
  77726. _processLateAnimationBindings(): void;
  77727. /**
  77728. * Will start the animation sequence of a given target
  77729. * @param target defines the target
  77730. * @param from defines from which frame should animation start
  77731. * @param to defines until which frame should animation run.
  77732. * @param weight defines the weight to apply to the animation (1.0 by default)
  77733. * @param loop defines if the animation loops
  77734. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77735. * @param onAnimationEnd defines the function to be executed when the animation ends
  77736. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77737. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77738. * @param onAnimationLoop defines the callback to call when an animation loops
  77739. * @returns the animatable object created for this animation
  77740. */
  77741. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77742. /**
  77743. * Will start the animation sequence of a given target
  77744. * @param target defines the target
  77745. * @param from defines from which frame should animation start
  77746. * @param to defines until which frame should animation run.
  77747. * @param loop defines if the animation loops
  77748. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77749. * @param onAnimationEnd defines the function to be executed when the animation ends
  77750. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77751. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77752. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77753. * @param onAnimationLoop defines the callback to call when an animation loops
  77754. * @returns the animatable object created for this animation
  77755. */
  77756. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77757. /**
  77758. * Will start the animation sequence of a given target and its hierarchy
  77759. * @param target defines the target
  77760. * @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.
  77761. * @param from defines from which frame should animation start
  77762. * @param to defines until which frame should animation run.
  77763. * @param loop defines if the animation loops
  77764. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77765. * @param onAnimationEnd defines the function to be executed when the animation ends
  77766. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77767. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77769. * @param onAnimationLoop defines the callback to call when an animation loops
  77770. * @returns the list of created animatables
  77771. */
  77772. 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[];
  77773. /**
  77774. * Begin a new animation on a given node
  77775. * @param target defines the target where the animation will take place
  77776. * @param animations defines the list of animations to start
  77777. * @param from defines the initial value
  77778. * @param to defines the final value
  77779. * @param loop defines if you want animation to loop (off by default)
  77780. * @param speedRatio defines the speed ratio to apply to all animations
  77781. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77782. * @param onAnimationLoop defines the callback to call when an animation loops
  77783. * @returns the list of created animatables
  77784. */
  77785. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77786. /**
  77787. * Begin a new animation on a given node and its hierarchy
  77788. * @param target defines the root node where the animation will take place
  77789. * @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.
  77790. * @param animations defines the list of animations to start
  77791. * @param from defines the initial value
  77792. * @param to defines the final value
  77793. * @param loop defines if you want animation to loop (off by default)
  77794. * @param speedRatio defines the speed ratio to apply to all animations
  77795. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77796. * @param onAnimationLoop defines the callback to call when an animation loops
  77797. * @returns the list of animatables created for all nodes
  77798. */
  77799. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77800. /**
  77801. * Gets the animatable associated with a specific target
  77802. * @param target defines the target of the animatable
  77803. * @returns the required animatable if found
  77804. */
  77805. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77806. /**
  77807. * Gets all animatables associated with a given target
  77808. * @param target defines the target to look animatables for
  77809. * @returns an array of Animatables
  77810. */
  77811. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77812. /**
  77813. * Will stop the animation of the given target
  77814. * @param target - the target
  77815. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77816. * @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)
  77817. */
  77818. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77819. /**
  77820. * Stops and removes all animations that have been applied to the scene
  77821. */
  77822. stopAllAnimations(): void;
  77823. }
  77824. interface Bone {
  77825. /**
  77826. * Copy an animation range from another bone
  77827. * @param source defines the source bone
  77828. * @param rangeName defines the range name to copy
  77829. * @param frameOffset defines the frame offset
  77830. * @param rescaleAsRequired defines if rescaling must be applied if required
  77831. * @param skelDimensionsRatio defines the scaling ratio
  77832. * @returns true if operation was successful
  77833. */
  77834. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77835. }
  77836. }
  77837. declare module BABYLON {
  77838. /**
  77839. * Class used to handle skinning animations
  77840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77841. */
  77842. export class Skeleton implements IAnimatable {
  77843. /** defines the skeleton name */
  77844. name: string;
  77845. /** defines the skeleton Id */
  77846. id: string;
  77847. /**
  77848. * Defines the list of child bones
  77849. */
  77850. bones: Bone[];
  77851. /**
  77852. * Defines an estimate of the dimension of the skeleton at rest
  77853. */
  77854. dimensionsAtRest: Vector3;
  77855. /**
  77856. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77857. */
  77858. needInitialSkinMatrix: boolean;
  77859. /**
  77860. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77861. */
  77862. overrideMesh: Nullable<AbstractMesh>;
  77863. /**
  77864. * Gets the list of animations attached to this skeleton
  77865. */
  77866. animations: Array<Animation>;
  77867. private _scene;
  77868. private _isDirty;
  77869. private _transformMatrices;
  77870. private _transformMatrixTexture;
  77871. private _meshesWithPoseMatrix;
  77872. private _animatables;
  77873. private _identity;
  77874. private _synchronizedWithMesh;
  77875. private _ranges;
  77876. private _lastAbsoluteTransformsUpdateId;
  77877. private _canUseTextureForBones;
  77878. private _uniqueId;
  77879. /** @hidden */
  77880. _numBonesWithLinkedTransformNode: number;
  77881. /**
  77882. * Specifies if the skeleton should be serialized
  77883. */
  77884. doNotSerialize: boolean;
  77885. private _useTextureToStoreBoneMatrices;
  77886. /**
  77887. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77888. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77889. */
  77890. useTextureToStoreBoneMatrices: boolean;
  77891. private _animationPropertiesOverride;
  77892. /**
  77893. * Gets or sets the animation properties override
  77894. */
  77895. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77896. /**
  77897. * List of inspectable custom properties (used by the Inspector)
  77898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77899. */
  77900. inspectableCustomProperties: IInspectable[];
  77901. /**
  77902. * An observable triggered before computing the skeleton's matrices
  77903. */
  77904. onBeforeComputeObservable: Observable<Skeleton>;
  77905. /**
  77906. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77907. */
  77908. readonly isUsingTextureForMatrices: boolean;
  77909. /**
  77910. * Gets the unique ID of this skeleton
  77911. */
  77912. readonly uniqueId: number;
  77913. /**
  77914. * Creates a new skeleton
  77915. * @param name defines the skeleton name
  77916. * @param id defines the skeleton Id
  77917. * @param scene defines the hosting scene
  77918. */
  77919. constructor(
  77920. /** defines the skeleton name */
  77921. name: string,
  77922. /** defines the skeleton Id */
  77923. id: string, scene: Scene);
  77924. /**
  77925. * Gets the current object class name.
  77926. * @return the class name
  77927. */
  77928. getClassName(): string;
  77929. /**
  77930. * Returns an array containing the root bones
  77931. * @returns an array containing the root bones
  77932. */
  77933. getChildren(): Array<Bone>;
  77934. /**
  77935. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77936. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77937. * @returns a Float32Array containing matrices data
  77938. */
  77939. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77940. /**
  77941. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77942. * @returns a raw texture containing the data
  77943. */
  77944. getTransformMatrixTexture(): Nullable<RawTexture>;
  77945. /**
  77946. * Gets the current hosting scene
  77947. * @returns a scene object
  77948. */
  77949. getScene(): Scene;
  77950. /**
  77951. * Gets a string representing the current skeleton data
  77952. * @param fullDetails defines a boolean indicating if we want a verbose version
  77953. * @returns a string representing the current skeleton data
  77954. */
  77955. toString(fullDetails?: boolean): string;
  77956. /**
  77957. * Get bone's index searching by name
  77958. * @param name defines bone's name to search for
  77959. * @return the indice of the bone. Returns -1 if not found
  77960. */
  77961. getBoneIndexByName(name: string): number;
  77962. /**
  77963. * Creater a new animation range
  77964. * @param name defines the name of the range
  77965. * @param from defines the start key
  77966. * @param to defines the end key
  77967. */
  77968. createAnimationRange(name: string, from: number, to: number): void;
  77969. /**
  77970. * Delete a specific animation range
  77971. * @param name defines the name of the range
  77972. * @param deleteFrames defines if frames must be removed as well
  77973. */
  77974. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77975. /**
  77976. * Gets a specific animation range
  77977. * @param name defines the name of the range to look for
  77978. * @returns the requested animation range or null if not found
  77979. */
  77980. getAnimationRange(name: string): Nullable<AnimationRange>;
  77981. /**
  77982. * Gets the list of all animation ranges defined on this skeleton
  77983. * @returns an array
  77984. */
  77985. getAnimationRanges(): Nullable<AnimationRange>[];
  77986. /**
  77987. * Copy animation range from a source skeleton.
  77988. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77989. * @param source defines the source skeleton
  77990. * @param name defines the name of the range to copy
  77991. * @param rescaleAsRequired defines if rescaling must be applied if required
  77992. * @returns true if operation was successful
  77993. */
  77994. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77995. /**
  77996. * Forces the skeleton to go to rest pose
  77997. */
  77998. returnToRest(): void;
  77999. private _getHighestAnimationFrame;
  78000. /**
  78001. * Begin a specific animation range
  78002. * @param name defines the name of the range to start
  78003. * @param loop defines if looping must be turned on (false by default)
  78004. * @param speedRatio defines the speed ratio to apply (1 by default)
  78005. * @param onAnimationEnd defines a callback which will be called when animation will end
  78006. * @returns a new animatable
  78007. */
  78008. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78009. /** @hidden */
  78010. _markAsDirty(): void;
  78011. /** @hidden */
  78012. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78013. /** @hidden */
  78014. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78015. private _computeTransformMatrices;
  78016. /**
  78017. * Build all resources required to render a skeleton
  78018. */
  78019. prepare(): void;
  78020. /**
  78021. * Gets the list of animatables currently running for this skeleton
  78022. * @returns an array of animatables
  78023. */
  78024. getAnimatables(): IAnimatable[];
  78025. /**
  78026. * Clone the current skeleton
  78027. * @param name defines the name of the new skeleton
  78028. * @param id defines the id of the enw skeleton
  78029. * @returns the new skeleton
  78030. */
  78031. clone(name: string, id: string): Skeleton;
  78032. /**
  78033. * Enable animation blending for this skeleton
  78034. * @param blendingSpeed defines the blending speed to apply
  78035. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78036. */
  78037. enableBlending(blendingSpeed?: number): void;
  78038. /**
  78039. * Releases all resources associated with the current skeleton
  78040. */
  78041. dispose(): void;
  78042. /**
  78043. * Serialize the skeleton in a JSON object
  78044. * @returns a JSON object
  78045. */
  78046. serialize(): any;
  78047. /**
  78048. * Creates a new skeleton from serialized data
  78049. * @param parsedSkeleton defines the serialized data
  78050. * @param scene defines the hosting scene
  78051. * @returns a new skeleton
  78052. */
  78053. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78054. /**
  78055. * Compute all node absolute transforms
  78056. * @param forceUpdate defines if computation must be done even if cache is up to date
  78057. */
  78058. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78059. /**
  78060. * Gets the root pose matrix
  78061. * @returns a matrix
  78062. */
  78063. getPoseMatrix(): Nullable<Matrix>;
  78064. /**
  78065. * Sorts bones per internal index
  78066. */
  78067. sortBones(): void;
  78068. private _sortBones;
  78069. }
  78070. }
  78071. declare module BABYLON {
  78072. /**
  78073. * Defines a target to use with MorphTargetManager
  78074. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78075. */
  78076. export class MorphTarget implements IAnimatable {
  78077. /** defines the name of the target */
  78078. name: string;
  78079. /**
  78080. * Gets or sets the list of animations
  78081. */
  78082. animations: Animation[];
  78083. private _scene;
  78084. private _positions;
  78085. private _normals;
  78086. private _tangents;
  78087. private _influence;
  78088. /**
  78089. * Observable raised when the influence changes
  78090. */
  78091. onInfluenceChanged: Observable<boolean>;
  78092. /** @hidden */
  78093. _onDataLayoutChanged: Observable<void>;
  78094. /**
  78095. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78096. */
  78097. influence: number;
  78098. /**
  78099. * Gets or sets the id of the morph Target
  78100. */
  78101. id: string;
  78102. private _animationPropertiesOverride;
  78103. /**
  78104. * Gets or sets the animation properties override
  78105. */
  78106. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78107. /**
  78108. * Creates a new MorphTarget
  78109. * @param name defines the name of the target
  78110. * @param influence defines the influence to use
  78111. * @param scene defines the scene the morphtarget belongs to
  78112. */
  78113. constructor(
  78114. /** defines the name of the target */
  78115. name: string, influence?: number, scene?: Nullable<Scene>);
  78116. /**
  78117. * Gets a boolean defining if the target contains position data
  78118. */
  78119. readonly hasPositions: boolean;
  78120. /**
  78121. * Gets a boolean defining if the target contains normal data
  78122. */
  78123. readonly hasNormals: boolean;
  78124. /**
  78125. * Gets a boolean defining if the target contains tangent data
  78126. */
  78127. readonly hasTangents: boolean;
  78128. /**
  78129. * Affects position data to this target
  78130. * @param data defines the position data to use
  78131. */
  78132. setPositions(data: Nullable<FloatArray>): void;
  78133. /**
  78134. * Gets the position data stored in this target
  78135. * @returns a FloatArray containing the position data (or null if not present)
  78136. */
  78137. getPositions(): Nullable<FloatArray>;
  78138. /**
  78139. * Affects normal data to this target
  78140. * @param data defines the normal data to use
  78141. */
  78142. setNormals(data: Nullable<FloatArray>): void;
  78143. /**
  78144. * Gets the normal data stored in this target
  78145. * @returns a FloatArray containing the normal data (or null if not present)
  78146. */
  78147. getNormals(): Nullable<FloatArray>;
  78148. /**
  78149. * Affects tangent data to this target
  78150. * @param data defines the tangent data to use
  78151. */
  78152. setTangents(data: Nullable<FloatArray>): void;
  78153. /**
  78154. * Gets the tangent data stored in this target
  78155. * @returns a FloatArray containing the tangent data (or null if not present)
  78156. */
  78157. getTangents(): Nullable<FloatArray>;
  78158. /**
  78159. * Serializes the current target into a Serialization object
  78160. * @returns the serialized object
  78161. */
  78162. serialize(): any;
  78163. /**
  78164. * Returns the string "MorphTarget"
  78165. * @returns "MorphTarget"
  78166. */
  78167. getClassName(): string;
  78168. /**
  78169. * Creates a new target from serialized data
  78170. * @param serializationObject defines the serialized data to use
  78171. * @returns a new MorphTarget
  78172. */
  78173. static Parse(serializationObject: any): MorphTarget;
  78174. /**
  78175. * Creates a MorphTarget from mesh data
  78176. * @param mesh defines the source mesh
  78177. * @param name defines the name to use for the new target
  78178. * @param influence defines the influence to attach to the target
  78179. * @returns a new MorphTarget
  78180. */
  78181. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78182. }
  78183. }
  78184. declare module BABYLON {
  78185. /**
  78186. * This class is used to deform meshes using morphing between different targets
  78187. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78188. */
  78189. export class MorphTargetManager {
  78190. private _targets;
  78191. private _targetInfluenceChangedObservers;
  78192. private _targetDataLayoutChangedObservers;
  78193. private _activeTargets;
  78194. private _scene;
  78195. private _influences;
  78196. private _supportsNormals;
  78197. private _supportsTangents;
  78198. private _vertexCount;
  78199. private _uniqueId;
  78200. private _tempInfluences;
  78201. /**
  78202. * Creates a new MorphTargetManager
  78203. * @param scene defines the current scene
  78204. */
  78205. constructor(scene?: Nullable<Scene>);
  78206. /**
  78207. * Gets the unique ID of this manager
  78208. */
  78209. readonly uniqueId: number;
  78210. /**
  78211. * Gets the number of vertices handled by this manager
  78212. */
  78213. readonly vertexCount: number;
  78214. /**
  78215. * Gets a boolean indicating if this manager supports morphing of normals
  78216. */
  78217. readonly supportsNormals: boolean;
  78218. /**
  78219. * Gets a boolean indicating if this manager supports morphing of tangents
  78220. */
  78221. readonly supportsTangents: boolean;
  78222. /**
  78223. * Gets the number of targets stored in this manager
  78224. */
  78225. readonly numTargets: number;
  78226. /**
  78227. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78228. */
  78229. readonly numInfluencers: number;
  78230. /**
  78231. * Gets the list of influences (one per target)
  78232. */
  78233. readonly influences: Float32Array;
  78234. /**
  78235. * Gets the active target at specified index. An active target is a target with an influence > 0
  78236. * @param index defines the index to check
  78237. * @returns the requested target
  78238. */
  78239. getActiveTarget(index: number): MorphTarget;
  78240. /**
  78241. * Gets the target at specified index
  78242. * @param index defines the index to check
  78243. * @returns the requested target
  78244. */
  78245. getTarget(index: number): MorphTarget;
  78246. /**
  78247. * Add a new target to this manager
  78248. * @param target defines the target to add
  78249. */
  78250. addTarget(target: MorphTarget): void;
  78251. /**
  78252. * Removes a target from the manager
  78253. * @param target defines the target to remove
  78254. */
  78255. removeTarget(target: MorphTarget): void;
  78256. /**
  78257. * Serializes the current manager into a Serialization object
  78258. * @returns the serialized object
  78259. */
  78260. serialize(): any;
  78261. private _syncActiveTargets;
  78262. /**
  78263. * Syncrhonize the targets with all the meshes using this morph target manager
  78264. */
  78265. synchronize(): void;
  78266. /**
  78267. * Creates a new MorphTargetManager from serialized data
  78268. * @param serializationObject defines the serialized data
  78269. * @param scene defines the hosting scene
  78270. * @returns the new MorphTargetManager
  78271. */
  78272. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78273. }
  78274. }
  78275. declare module BABYLON {
  78276. /**
  78277. * Mesh representing the gorund
  78278. */
  78279. export class GroundMesh extends Mesh {
  78280. /** If octree should be generated */
  78281. generateOctree: boolean;
  78282. private _heightQuads;
  78283. /** @hidden */
  78284. _subdivisionsX: number;
  78285. /** @hidden */
  78286. _subdivisionsY: number;
  78287. /** @hidden */
  78288. _width: number;
  78289. /** @hidden */
  78290. _height: number;
  78291. /** @hidden */
  78292. _minX: number;
  78293. /** @hidden */
  78294. _maxX: number;
  78295. /** @hidden */
  78296. _minZ: number;
  78297. /** @hidden */
  78298. _maxZ: number;
  78299. constructor(name: string, scene: Scene);
  78300. /**
  78301. * "GroundMesh"
  78302. * @returns "GroundMesh"
  78303. */
  78304. getClassName(): string;
  78305. /**
  78306. * The minimum of x and y subdivisions
  78307. */
  78308. readonly subdivisions: number;
  78309. /**
  78310. * X subdivisions
  78311. */
  78312. readonly subdivisionsX: number;
  78313. /**
  78314. * Y subdivisions
  78315. */
  78316. readonly subdivisionsY: number;
  78317. /**
  78318. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78319. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78320. * @param chunksCount the number of subdivisions for x and y
  78321. * @param octreeBlocksSize (Default: 32)
  78322. */
  78323. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78324. /**
  78325. * Returns a height (y) value in the Worl system :
  78326. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78327. * @param x x coordinate
  78328. * @param z z coordinate
  78329. * @returns the ground y position if (x, z) are outside the ground surface.
  78330. */
  78331. getHeightAtCoordinates(x: number, z: number): number;
  78332. /**
  78333. * Returns a normalized vector (Vector3) orthogonal to the ground
  78334. * at the ground coordinates (x, z) expressed in the World system.
  78335. * @param x x coordinate
  78336. * @param z z coordinate
  78337. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78338. */
  78339. getNormalAtCoordinates(x: number, z: number): Vector3;
  78340. /**
  78341. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78342. * at the ground coordinates (x, z) expressed in the World system.
  78343. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78344. * @param x x coordinate
  78345. * @param z z coordinate
  78346. * @param ref vector to store the result
  78347. * @returns the GroundMesh.
  78348. */
  78349. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78350. /**
  78351. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78352. * if the ground has been updated.
  78353. * This can be used in the render loop.
  78354. * @returns the GroundMesh.
  78355. */
  78356. updateCoordinateHeights(): GroundMesh;
  78357. private _getFacetAt;
  78358. private _initHeightQuads;
  78359. private _computeHeightQuads;
  78360. /**
  78361. * Serializes this ground mesh
  78362. * @param serializationObject object to write serialization to
  78363. */
  78364. serialize(serializationObject: any): void;
  78365. /**
  78366. * Parses a serialized ground mesh
  78367. * @param parsedMesh the serialized mesh
  78368. * @param scene the scene to create the ground mesh in
  78369. * @returns the created ground mesh
  78370. */
  78371. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78372. }
  78373. }
  78374. declare module BABYLON {
  78375. /**
  78376. * Interface for Physics-Joint data
  78377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78378. */
  78379. export interface PhysicsJointData {
  78380. /**
  78381. * The main pivot of the joint
  78382. */
  78383. mainPivot?: Vector3;
  78384. /**
  78385. * The connected pivot of the joint
  78386. */
  78387. connectedPivot?: Vector3;
  78388. /**
  78389. * The main axis of the joint
  78390. */
  78391. mainAxis?: Vector3;
  78392. /**
  78393. * The connected axis of the joint
  78394. */
  78395. connectedAxis?: Vector3;
  78396. /**
  78397. * The collision of the joint
  78398. */
  78399. collision?: boolean;
  78400. /**
  78401. * Native Oimo/Cannon/Energy data
  78402. */
  78403. nativeParams?: any;
  78404. }
  78405. /**
  78406. * This is a holder class for the physics joint created by the physics plugin
  78407. * It holds a set of functions to control the underlying joint
  78408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78409. */
  78410. export class PhysicsJoint {
  78411. /**
  78412. * The type of the physics joint
  78413. */
  78414. type: number;
  78415. /**
  78416. * The data for the physics joint
  78417. */
  78418. jointData: PhysicsJointData;
  78419. private _physicsJoint;
  78420. protected _physicsPlugin: IPhysicsEnginePlugin;
  78421. /**
  78422. * Initializes the physics joint
  78423. * @param type The type of the physics joint
  78424. * @param jointData The data for the physics joint
  78425. */
  78426. constructor(
  78427. /**
  78428. * The type of the physics joint
  78429. */
  78430. type: number,
  78431. /**
  78432. * The data for the physics joint
  78433. */
  78434. jointData: PhysicsJointData);
  78435. /**
  78436. * Gets the physics joint
  78437. */
  78438. /**
  78439. * Sets the physics joint
  78440. */
  78441. physicsJoint: any;
  78442. /**
  78443. * Sets the physics plugin
  78444. */
  78445. physicsPlugin: IPhysicsEnginePlugin;
  78446. /**
  78447. * Execute a function that is physics-plugin specific.
  78448. * @param {Function} func the function that will be executed.
  78449. * It accepts two parameters: the physics world and the physics joint
  78450. */
  78451. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78452. /**
  78453. * Distance-Joint type
  78454. */
  78455. static DistanceJoint: number;
  78456. /**
  78457. * Hinge-Joint type
  78458. */
  78459. static HingeJoint: number;
  78460. /**
  78461. * Ball-and-Socket joint type
  78462. */
  78463. static BallAndSocketJoint: number;
  78464. /**
  78465. * Wheel-Joint type
  78466. */
  78467. static WheelJoint: number;
  78468. /**
  78469. * Slider-Joint type
  78470. */
  78471. static SliderJoint: number;
  78472. /**
  78473. * Prismatic-Joint type
  78474. */
  78475. static PrismaticJoint: number;
  78476. /**
  78477. * Universal-Joint type
  78478. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78479. */
  78480. static UniversalJoint: number;
  78481. /**
  78482. * Hinge-Joint 2 type
  78483. */
  78484. static Hinge2Joint: number;
  78485. /**
  78486. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78487. */
  78488. static PointToPointJoint: number;
  78489. /**
  78490. * Spring-Joint type
  78491. */
  78492. static SpringJoint: number;
  78493. /**
  78494. * Lock-Joint type
  78495. */
  78496. static LockJoint: number;
  78497. }
  78498. /**
  78499. * A class representing a physics distance joint
  78500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78501. */
  78502. export class DistanceJoint extends PhysicsJoint {
  78503. /**
  78504. *
  78505. * @param jointData The data for the Distance-Joint
  78506. */
  78507. constructor(jointData: DistanceJointData);
  78508. /**
  78509. * Update the predefined distance.
  78510. * @param maxDistance The maximum preferred distance
  78511. * @param minDistance The minimum preferred distance
  78512. */
  78513. updateDistance(maxDistance: number, minDistance?: number): void;
  78514. }
  78515. /**
  78516. * Represents a Motor-Enabled Joint
  78517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78518. */
  78519. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78520. /**
  78521. * Initializes the Motor-Enabled Joint
  78522. * @param type The type of the joint
  78523. * @param jointData The physica joint data for the joint
  78524. */
  78525. constructor(type: number, jointData: PhysicsJointData);
  78526. /**
  78527. * Set the motor values.
  78528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78529. * @param force the force to apply
  78530. * @param maxForce max force for this motor.
  78531. */
  78532. setMotor(force?: number, maxForce?: number): void;
  78533. /**
  78534. * Set the motor's limits.
  78535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78536. * @param upperLimit The upper limit of the motor
  78537. * @param lowerLimit The lower limit of the motor
  78538. */
  78539. setLimit(upperLimit: number, lowerLimit?: number): void;
  78540. }
  78541. /**
  78542. * This class represents a single physics Hinge-Joint
  78543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78544. */
  78545. export class HingeJoint extends MotorEnabledJoint {
  78546. /**
  78547. * Initializes the Hinge-Joint
  78548. * @param jointData The joint data for the Hinge-Joint
  78549. */
  78550. constructor(jointData: PhysicsJointData);
  78551. /**
  78552. * Set the motor values.
  78553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78554. * @param {number} force the force to apply
  78555. * @param {number} maxForce max force for this motor.
  78556. */
  78557. setMotor(force?: number, maxForce?: number): void;
  78558. /**
  78559. * Set the motor's limits.
  78560. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78561. * @param upperLimit The upper limit of the motor
  78562. * @param lowerLimit The lower limit of the motor
  78563. */
  78564. setLimit(upperLimit: number, lowerLimit?: number): void;
  78565. }
  78566. /**
  78567. * This class represents a dual hinge physics joint (same as wheel joint)
  78568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78569. */
  78570. export class Hinge2Joint extends MotorEnabledJoint {
  78571. /**
  78572. * Initializes the Hinge2-Joint
  78573. * @param jointData The joint data for the Hinge2-Joint
  78574. */
  78575. constructor(jointData: PhysicsJointData);
  78576. /**
  78577. * Set the motor values.
  78578. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78579. * @param {number} targetSpeed the speed the motor is to reach
  78580. * @param {number} maxForce max force for this motor.
  78581. * @param {motorIndex} the motor's index, 0 or 1.
  78582. */
  78583. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78584. /**
  78585. * Set the motor limits.
  78586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78587. * @param {number} upperLimit the upper limit
  78588. * @param {number} lowerLimit lower limit
  78589. * @param {motorIndex} the motor's index, 0 or 1.
  78590. */
  78591. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78592. }
  78593. /**
  78594. * Interface for a motor enabled joint
  78595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78596. */
  78597. export interface IMotorEnabledJoint {
  78598. /**
  78599. * Physics joint
  78600. */
  78601. physicsJoint: any;
  78602. /**
  78603. * Sets the motor of the motor-enabled joint
  78604. * @param force The force of the motor
  78605. * @param maxForce The maximum force of the motor
  78606. * @param motorIndex The index of the motor
  78607. */
  78608. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78609. /**
  78610. * Sets the limit of the motor
  78611. * @param upperLimit The upper limit of the motor
  78612. * @param lowerLimit The lower limit of the motor
  78613. * @param motorIndex The index of the motor
  78614. */
  78615. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78616. }
  78617. /**
  78618. * Joint data for a Distance-Joint
  78619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78620. */
  78621. export interface DistanceJointData extends PhysicsJointData {
  78622. /**
  78623. * Max distance the 2 joint objects can be apart
  78624. */
  78625. maxDistance: number;
  78626. }
  78627. /**
  78628. * Joint data from a spring joint
  78629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78630. */
  78631. export interface SpringJointData extends PhysicsJointData {
  78632. /**
  78633. * Length of the spring
  78634. */
  78635. length: number;
  78636. /**
  78637. * Stiffness of the spring
  78638. */
  78639. stiffness: number;
  78640. /**
  78641. * Damping of the spring
  78642. */
  78643. damping: number;
  78644. /** this callback will be called when applying the force to the impostors. */
  78645. forceApplicationCallback: () => void;
  78646. }
  78647. }
  78648. declare module BABYLON {
  78649. /**
  78650. * Holds the data for the raycast result
  78651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78652. */
  78653. export class PhysicsRaycastResult {
  78654. private _hasHit;
  78655. private _hitDistance;
  78656. private _hitNormalWorld;
  78657. private _hitPointWorld;
  78658. private _rayFromWorld;
  78659. private _rayToWorld;
  78660. /**
  78661. * Gets if there was a hit
  78662. */
  78663. readonly hasHit: boolean;
  78664. /**
  78665. * Gets the distance from the hit
  78666. */
  78667. readonly hitDistance: number;
  78668. /**
  78669. * Gets the hit normal/direction in the world
  78670. */
  78671. readonly hitNormalWorld: Vector3;
  78672. /**
  78673. * Gets the hit point in the world
  78674. */
  78675. readonly hitPointWorld: Vector3;
  78676. /**
  78677. * Gets the ray "start point" of the ray in the world
  78678. */
  78679. readonly rayFromWorld: Vector3;
  78680. /**
  78681. * Gets the ray "end point" of the ray in the world
  78682. */
  78683. readonly rayToWorld: Vector3;
  78684. /**
  78685. * Sets the hit data (normal & point in world space)
  78686. * @param hitNormalWorld defines the normal in world space
  78687. * @param hitPointWorld defines the point in world space
  78688. */
  78689. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78690. /**
  78691. * Sets the distance from the start point to the hit point
  78692. * @param distance
  78693. */
  78694. setHitDistance(distance: number): void;
  78695. /**
  78696. * Calculates the distance manually
  78697. */
  78698. calculateHitDistance(): void;
  78699. /**
  78700. * Resets all the values to default
  78701. * @param from The from point on world space
  78702. * @param to The to point on world space
  78703. */
  78704. reset(from?: Vector3, to?: Vector3): void;
  78705. }
  78706. /**
  78707. * Interface for the size containing width and height
  78708. */
  78709. interface IXYZ {
  78710. /**
  78711. * X
  78712. */
  78713. x: number;
  78714. /**
  78715. * Y
  78716. */
  78717. y: number;
  78718. /**
  78719. * Z
  78720. */
  78721. z: number;
  78722. }
  78723. }
  78724. declare module BABYLON {
  78725. /**
  78726. * Interface used to describe a physics joint
  78727. */
  78728. export interface PhysicsImpostorJoint {
  78729. /** Defines the main impostor to which the joint is linked */
  78730. mainImpostor: PhysicsImpostor;
  78731. /** Defines the impostor that is connected to the main impostor using this joint */
  78732. connectedImpostor: PhysicsImpostor;
  78733. /** Defines the joint itself */
  78734. joint: PhysicsJoint;
  78735. }
  78736. /** @hidden */
  78737. export interface IPhysicsEnginePlugin {
  78738. world: any;
  78739. name: string;
  78740. setGravity(gravity: Vector3): void;
  78741. setTimeStep(timeStep: number): void;
  78742. getTimeStep(): number;
  78743. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78744. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78745. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78746. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78747. removePhysicsBody(impostor: PhysicsImpostor): void;
  78748. generateJoint(joint: PhysicsImpostorJoint): void;
  78749. removeJoint(joint: PhysicsImpostorJoint): void;
  78750. isSupported(): boolean;
  78751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78753. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78754. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78755. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78756. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78757. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78758. getBodyMass(impostor: PhysicsImpostor): number;
  78759. getBodyFriction(impostor: PhysicsImpostor): number;
  78760. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78761. getBodyRestitution(impostor: PhysicsImpostor): number;
  78762. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78763. getBodyPressure?(impostor: PhysicsImpostor): number;
  78764. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78765. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78766. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78767. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78768. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78769. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78770. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78771. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78772. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78773. sleepBody(impostor: PhysicsImpostor): void;
  78774. wakeUpBody(impostor: PhysicsImpostor): void;
  78775. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78776. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78777. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78778. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78779. getRadius(impostor: PhysicsImpostor): number;
  78780. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78781. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78782. dispose(): void;
  78783. }
  78784. /**
  78785. * Interface used to define a physics engine
  78786. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78787. */
  78788. export interface IPhysicsEngine {
  78789. /**
  78790. * Gets the gravity vector used by the simulation
  78791. */
  78792. gravity: Vector3;
  78793. /**
  78794. * Sets the gravity vector used by the simulation
  78795. * @param gravity defines the gravity vector to use
  78796. */
  78797. setGravity(gravity: Vector3): void;
  78798. /**
  78799. * Set the time step of the physics engine.
  78800. * Default is 1/60.
  78801. * To slow it down, enter 1/600 for example.
  78802. * To speed it up, 1/30
  78803. * @param newTimeStep the new timestep to apply to this world.
  78804. */
  78805. setTimeStep(newTimeStep: number): void;
  78806. /**
  78807. * Get the time step of the physics engine.
  78808. * @returns the current time step
  78809. */
  78810. getTimeStep(): number;
  78811. /**
  78812. * Release all resources
  78813. */
  78814. dispose(): void;
  78815. /**
  78816. * Gets the name of the current physics plugin
  78817. * @returns the name of the plugin
  78818. */
  78819. getPhysicsPluginName(): string;
  78820. /**
  78821. * Adding a new impostor for the impostor tracking.
  78822. * This will be done by the impostor itself.
  78823. * @param impostor the impostor to add
  78824. */
  78825. addImpostor(impostor: PhysicsImpostor): void;
  78826. /**
  78827. * Remove an impostor from the engine.
  78828. * This impostor and its mesh will not longer be updated by the physics engine.
  78829. * @param impostor the impostor to remove
  78830. */
  78831. removeImpostor(impostor: PhysicsImpostor): void;
  78832. /**
  78833. * Add a joint to the physics engine
  78834. * @param mainImpostor defines the main impostor to which the joint is added.
  78835. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78836. * @param joint defines the joint that will connect both impostors.
  78837. */
  78838. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78839. /**
  78840. * Removes a joint from the simulation
  78841. * @param mainImpostor defines the impostor used with the joint
  78842. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78843. * @param joint defines the joint to remove
  78844. */
  78845. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78846. /**
  78847. * Gets the current plugin used to run the simulation
  78848. * @returns current plugin
  78849. */
  78850. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78851. /**
  78852. * Gets the list of physic impostors
  78853. * @returns an array of PhysicsImpostor
  78854. */
  78855. getImpostors(): Array<PhysicsImpostor>;
  78856. /**
  78857. * Gets the impostor for a physics enabled object
  78858. * @param object defines the object impersonated by the impostor
  78859. * @returns the PhysicsImpostor or null if not found
  78860. */
  78861. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78862. /**
  78863. * Gets the impostor for a physics body object
  78864. * @param body defines physics body used by the impostor
  78865. * @returns the PhysicsImpostor or null if not found
  78866. */
  78867. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78868. /**
  78869. * Does a raycast in the physics world
  78870. * @param from when should the ray start?
  78871. * @param to when should the ray end?
  78872. * @returns PhysicsRaycastResult
  78873. */
  78874. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78875. /**
  78876. * Called by the scene. No need to call it.
  78877. * @param delta defines the timespam between frames
  78878. */
  78879. _step(delta: number): void;
  78880. }
  78881. }
  78882. declare module BABYLON {
  78883. /**
  78884. * The interface for the physics imposter parameters
  78885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78886. */
  78887. export interface PhysicsImpostorParameters {
  78888. /**
  78889. * The mass of the physics imposter
  78890. */
  78891. mass: number;
  78892. /**
  78893. * The friction of the physics imposter
  78894. */
  78895. friction?: number;
  78896. /**
  78897. * The coefficient of restitution of the physics imposter
  78898. */
  78899. restitution?: number;
  78900. /**
  78901. * The native options of the physics imposter
  78902. */
  78903. nativeOptions?: any;
  78904. /**
  78905. * Specifies if the parent should be ignored
  78906. */
  78907. ignoreParent?: boolean;
  78908. /**
  78909. * Specifies if bi-directional transformations should be disabled
  78910. */
  78911. disableBidirectionalTransformation?: boolean;
  78912. /**
  78913. * The pressure inside the physics imposter, soft object only
  78914. */
  78915. pressure?: number;
  78916. /**
  78917. * The stiffness the physics imposter, soft object only
  78918. */
  78919. stiffness?: number;
  78920. /**
  78921. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78922. */
  78923. velocityIterations?: number;
  78924. /**
  78925. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78926. */
  78927. positionIterations?: number;
  78928. /**
  78929. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78930. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78931. * Add to fix multiple points
  78932. */
  78933. fixedPoints?: number;
  78934. /**
  78935. * The collision margin around a soft object
  78936. */
  78937. margin?: number;
  78938. /**
  78939. * The collision margin around a soft object
  78940. */
  78941. damping?: number;
  78942. /**
  78943. * The path for a rope based on an extrusion
  78944. */
  78945. path?: any;
  78946. /**
  78947. * The shape of an extrusion used for a rope based on an extrusion
  78948. */
  78949. shape?: any;
  78950. }
  78951. /**
  78952. * Interface for a physics-enabled object
  78953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78954. */
  78955. export interface IPhysicsEnabledObject {
  78956. /**
  78957. * The position of the physics-enabled object
  78958. */
  78959. position: Vector3;
  78960. /**
  78961. * The rotation of the physics-enabled object
  78962. */
  78963. rotationQuaternion: Nullable<Quaternion>;
  78964. /**
  78965. * The scale of the physics-enabled object
  78966. */
  78967. scaling: Vector3;
  78968. /**
  78969. * The rotation of the physics-enabled object
  78970. */
  78971. rotation?: Vector3;
  78972. /**
  78973. * The parent of the physics-enabled object
  78974. */
  78975. parent?: any;
  78976. /**
  78977. * The bounding info of the physics-enabled object
  78978. * @returns The bounding info of the physics-enabled object
  78979. */
  78980. getBoundingInfo(): BoundingInfo;
  78981. /**
  78982. * Computes the world matrix
  78983. * @param force Specifies if the world matrix should be computed by force
  78984. * @returns A world matrix
  78985. */
  78986. computeWorldMatrix(force: boolean): Matrix;
  78987. /**
  78988. * Gets the world matrix
  78989. * @returns A world matrix
  78990. */
  78991. getWorldMatrix?(): Matrix;
  78992. /**
  78993. * Gets the child meshes
  78994. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78995. * @returns An array of abstract meshes
  78996. */
  78997. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78998. /**
  78999. * Gets the vertex data
  79000. * @param kind The type of vertex data
  79001. * @returns A nullable array of numbers, or a float32 array
  79002. */
  79003. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79004. /**
  79005. * Gets the indices from the mesh
  79006. * @returns A nullable array of index arrays
  79007. */
  79008. getIndices?(): Nullable<IndicesArray>;
  79009. /**
  79010. * Gets the scene from the mesh
  79011. * @returns the indices array or null
  79012. */
  79013. getScene?(): Scene;
  79014. /**
  79015. * Gets the absolute position from the mesh
  79016. * @returns the absolute position
  79017. */
  79018. getAbsolutePosition(): Vector3;
  79019. /**
  79020. * Gets the absolute pivot point from the mesh
  79021. * @returns the absolute pivot point
  79022. */
  79023. getAbsolutePivotPoint(): Vector3;
  79024. /**
  79025. * Rotates the mesh
  79026. * @param axis The axis of rotation
  79027. * @param amount The amount of rotation
  79028. * @param space The space of the rotation
  79029. * @returns The rotation transform node
  79030. */
  79031. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79032. /**
  79033. * Translates the mesh
  79034. * @param axis The axis of translation
  79035. * @param distance The distance of translation
  79036. * @param space The space of the translation
  79037. * @returns The transform node
  79038. */
  79039. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79040. /**
  79041. * Sets the absolute position of the mesh
  79042. * @param absolutePosition The absolute position of the mesh
  79043. * @returns The transform node
  79044. */
  79045. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79046. /**
  79047. * Gets the class name of the mesh
  79048. * @returns The class name
  79049. */
  79050. getClassName(): string;
  79051. }
  79052. /**
  79053. * Represents a physics imposter
  79054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79055. */
  79056. export class PhysicsImpostor {
  79057. /**
  79058. * The physics-enabled object used as the physics imposter
  79059. */
  79060. object: IPhysicsEnabledObject;
  79061. /**
  79062. * The type of the physics imposter
  79063. */
  79064. type: number;
  79065. private _options;
  79066. private _scene?;
  79067. /**
  79068. * The default object size of the imposter
  79069. */
  79070. static DEFAULT_OBJECT_SIZE: Vector3;
  79071. /**
  79072. * The identity quaternion of the imposter
  79073. */
  79074. static IDENTITY_QUATERNION: Quaternion;
  79075. /** @hidden */
  79076. _pluginData: any;
  79077. private _physicsEngine;
  79078. private _physicsBody;
  79079. private _bodyUpdateRequired;
  79080. private _onBeforePhysicsStepCallbacks;
  79081. private _onAfterPhysicsStepCallbacks;
  79082. /** @hidden */
  79083. _onPhysicsCollideCallbacks: Array<{
  79084. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79085. otherImpostors: Array<PhysicsImpostor>;
  79086. }>;
  79087. private _deltaPosition;
  79088. private _deltaRotation;
  79089. private _deltaRotationConjugated;
  79090. /** hidden */
  79091. _isFromLine: boolean;
  79092. private _parent;
  79093. private _isDisposed;
  79094. private static _tmpVecs;
  79095. private static _tmpQuat;
  79096. /**
  79097. * Specifies if the physics imposter is disposed
  79098. */
  79099. readonly isDisposed: boolean;
  79100. /**
  79101. * Gets the mass of the physics imposter
  79102. */
  79103. mass: number;
  79104. /**
  79105. * Gets the coefficient of friction
  79106. */
  79107. /**
  79108. * Sets the coefficient of friction
  79109. */
  79110. friction: number;
  79111. /**
  79112. * Gets the coefficient of restitution
  79113. */
  79114. /**
  79115. * Sets the coefficient of restitution
  79116. */
  79117. restitution: number;
  79118. /**
  79119. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79120. */
  79121. /**
  79122. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79123. */
  79124. pressure: number;
  79125. /**
  79126. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79127. */
  79128. /**
  79129. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79130. */
  79131. stiffness: number;
  79132. /**
  79133. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79134. */
  79135. /**
  79136. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79137. */
  79138. velocityIterations: number;
  79139. /**
  79140. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79141. */
  79142. /**
  79143. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79144. */
  79145. positionIterations: number;
  79146. /**
  79147. * The unique id of the physics imposter
  79148. * set by the physics engine when adding this impostor to the array
  79149. */
  79150. uniqueId: number;
  79151. /**
  79152. * @hidden
  79153. */
  79154. soft: boolean;
  79155. /**
  79156. * @hidden
  79157. */
  79158. segments: number;
  79159. private _joints;
  79160. /**
  79161. * Initializes the physics imposter
  79162. * @param object The physics-enabled object used as the physics imposter
  79163. * @param type The type of the physics imposter
  79164. * @param _options The options for the physics imposter
  79165. * @param _scene The Babylon scene
  79166. */
  79167. constructor(
  79168. /**
  79169. * The physics-enabled object used as the physics imposter
  79170. */
  79171. object: IPhysicsEnabledObject,
  79172. /**
  79173. * The type of the physics imposter
  79174. */
  79175. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79176. /**
  79177. * This function will completly initialize this impostor.
  79178. * It will create a new body - but only if this mesh has no parent.
  79179. * If it has, this impostor will not be used other than to define the impostor
  79180. * of the child mesh.
  79181. * @hidden
  79182. */
  79183. _init(): void;
  79184. private _getPhysicsParent;
  79185. /**
  79186. * Should a new body be generated.
  79187. * @returns boolean specifying if body initialization is required
  79188. */
  79189. isBodyInitRequired(): boolean;
  79190. /**
  79191. * Sets the updated scaling
  79192. * @param updated Specifies if the scaling is updated
  79193. */
  79194. setScalingUpdated(): void;
  79195. /**
  79196. * Force a regeneration of this or the parent's impostor's body.
  79197. * Use under cautious - This will remove all joints already implemented.
  79198. */
  79199. forceUpdate(): void;
  79200. /**
  79201. * Gets the body that holds this impostor. Either its own, or its parent.
  79202. */
  79203. /**
  79204. * Set the physics body. Used mainly by the physics engine/plugin
  79205. */
  79206. physicsBody: any;
  79207. /**
  79208. * Get the parent of the physics imposter
  79209. * @returns Physics imposter or null
  79210. */
  79211. /**
  79212. * Sets the parent of the physics imposter
  79213. */
  79214. parent: Nullable<PhysicsImpostor>;
  79215. /**
  79216. * Resets the update flags
  79217. */
  79218. resetUpdateFlags(): void;
  79219. /**
  79220. * Gets the object extend size
  79221. * @returns the object extend size
  79222. */
  79223. getObjectExtendSize(): Vector3;
  79224. /**
  79225. * Gets the object center
  79226. * @returns The object center
  79227. */
  79228. getObjectCenter(): Vector3;
  79229. /**
  79230. * Get a specific parametes from the options parameter
  79231. * @param paramName The object parameter name
  79232. * @returns The object parameter
  79233. */
  79234. getParam(paramName: string): any;
  79235. /**
  79236. * Sets a specific parameter in the options given to the physics plugin
  79237. * @param paramName The parameter name
  79238. * @param value The value of the parameter
  79239. */
  79240. setParam(paramName: string, value: number): void;
  79241. /**
  79242. * Specifically change the body's mass option. Won't recreate the physics body object
  79243. * @param mass The mass of the physics imposter
  79244. */
  79245. setMass(mass: number): void;
  79246. /**
  79247. * Gets the linear velocity
  79248. * @returns linear velocity or null
  79249. */
  79250. getLinearVelocity(): Nullable<Vector3>;
  79251. /**
  79252. * Sets the linear velocity
  79253. * @param velocity linear velocity or null
  79254. */
  79255. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79256. /**
  79257. * Gets the angular velocity
  79258. * @returns angular velocity or null
  79259. */
  79260. getAngularVelocity(): Nullable<Vector3>;
  79261. /**
  79262. * Sets the angular velocity
  79263. * @param velocity The velocity or null
  79264. */
  79265. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79266. /**
  79267. * Execute a function with the physics plugin native code
  79268. * Provide a function the will have two variables - the world object and the physics body object
  79269. * @param func The function to execute with the physics plugin native code
  79270. */
  79271. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79272. /**
  79273. * Register a function that will be executed before the physics world is stepping forward
  79274. * @param func The function to execute before the physics world is stepped forward
  79275. */
  79276. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79277. /**
  79278. * Unregister a function that will be executed before the physics world is stepping forward
  79279. * @param func The function to execute before the physics world is stepped forward
  79280. */
  79281. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79282. /**
  79283. * Register a function that will be executed after the physics step
  79284. * @param func The function to execute after physics step
  79285. */
  79286. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79287. /**
  79288. * Unregisters a function that will be executed after the physics step
  79289. * @param func The function to execute after physics step
  79290. */
  79291. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79292. /**
  79293. * register a function that will be executed when this impostor collides against a different body
  79294. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79295. * @param func Callback that is executed on collision
  79296. */
  79297. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79298. /**
  79299. * Unregisters the physics imposter on contact
  79300. * @param collideAgainst The physics object to collide against
  79301. * @param func Callback to execute on collision
  79302. */
  79303. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79304. private _tmpQuat;
  79305. private _tmpQuat2;
  79306. /**
  79307. * Get the parent rotation
  79308. * @returns The parent rotation
  79309. */
  79310. getParentsRotation(): Quaternion;
  79311. /**
  79312. * this function is executed by the physics engine.
  79313. */
  79314. beforeStep: () => void;
  79315. /**
  79316. * this function is executed by the physics engine
  79317. */
  79318. afterStep: () => void;
  79319. /**
  79320. * Legacy collision detection event support
  79321. */
  79322. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79323. /**
  79324. * event and body object due to cannon's event-based architecture.
  79325. */
  79326. onCollide: (e: {
  79327. body: any;
  79328. }) => void;
  79329. /**
  79330. * Apply a force
  79331. * @param force The force to apply
  79332. * @param contactPoint The contact point for the force
  79333. * @returns The physics imposter
  79334. */
  79335. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79336. /**
  79337. * Apply an impulse
  79338. * @param force The impulse force
  79339. * @param contactPoint The contact point for the impulse force
  79340. * @returns The physics imposter
  79341. */
  79342. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79343. /**
  79344. * A help function to create a joint
  79345. * @param otherImpostor A physics imposter used to create a joint
  79346. * @param jointType The type of joint
  79347. * @param jointData The data for the joint
  79348. * @returns The physics imposter
  79349. */
  79350. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79351. /**
  79352. * Add a joint to this impostor with a different impostor
  79353. * @param otherImpostor A physics imposter used to add a joint
  79354. * @param joint The joint to add
  79355. * @returns The physics imposter
  79356. */
  79357. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79358. /**
  79359. * Add an anchor to a cloth impostor
  79360. * @param otherImpostor rigid impostor to anchor to
  79361. * @param width ratio across width from 0 to 1
  79362. * @param height ratio up height from 0 to 1
  79363. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79364. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79365. * @returns impostor the soft imposter
  79366. */
  79367. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79368. /**
  79369. * Add a hook to a rope impostor
  79370. * @param otherImpostor rigid impostor to anchor to
  79371. * @param length ratio across rope from 0 to 1
  79372. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79373. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79374. * @returns impostor the rope imposter
  79375. */
  79376. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79377. /**
  79378. * Will keep this body still, in a sleep mode.
  79379. * @returns the physics imposter
  79380. */
  79381. sleep(): PhysicsImpostor;
  79382. /**
  79383. * Wake the body up.
  79384. * @returns The physics imposter
  79385. */
  79386. wakeUp(): PhysicsImpostor;
  79387. /**
  79388. * Clones the physics imposter
  79389. * @param newObject The physics imposter clones to this physics-enabled object
  79390. * @returns A nullable physics imposter
  79391. */
  79392. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79393. /**
  79394. * Disposes the physics imposter
  79395. */
  79396. dispose(): void;
  79397. /**
  79398. * Sets the delta position
  79399. * @param position The delta position amount
  79400. */
  79401. setDeltaPosition(position: Vector3): void;
  79402. /**
  79403. * Sets the delta rotation
  79404. * @param rotation The delta rotation amount
  79405. */
  79406. setDeltaRotation(rotation: Quaternion): void;
  79407. /**
  79408. * Gets the box size of the physics imposter and stores the result in the input parameter
  79409. * @param result Stores the box size
  79410. * @returns The physics imposter
  79411. */
  79412. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79413. /**
  79414. * Gets the radius of the physics imposter
  79415. * @returns Radius of the physics imposter
  79416. */
  79417. getRadius(): number;
  79418. /**
  79419. * Sync a bone with this impostor
  79420. * @param bone The bone to sync to the impostor.
  79421. * @param boneMesh The mesh that the bone is influencing.
  79422. * @param jointPivot The pivot of the joint / bone in local space.
  79423. * @param distToJoint Optional distance from the impostor to the joint.
  79424. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79425. */
  79426. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79427. /**
  79428. * Sync impostor to a bone
  79429. * @param bone The bone that the impostor will be synced to.
  79430. * @param boneMesh The mesh that the bone is influencing.
  79431. * @param jointPivot The pivot of the joint / bone in local space.
  79432. * @param distToJoint Optional distance from the impostor to the joint.
  79433. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79434. * @param boneAxis Optional vector3 axis the bone is aligned with
  79435. */
  79436. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79437. /**
  79438. * No-Imposter type
  79439. */
  79440. static NoImpostor: number;
  79441. /**
  79442. * Sphere-Imposter type
  79443. */
  79444. static SphereImpostor: number;
  79445. /**
  79446. * Box-Imposter type
  79447. */
  79448. static BoxImpostor: number;
  79449. /**
  79450. * Plane-Imposter type
  79451. */
  79452. static PlaneImpostor: number;
  79453. /**
  79454. * Mesh-imposter type
  79455. */
  79456. static MeshImpostor: number;
  79457. /**
  79458. * Cylinder-Imposter type
  79459. */
  79460. static CylinderImpostor: number;
  79461. /**
  79462. * Particle-Imposter type
  79463. */
  79464. static ParticleImpostor: number;
  79465. /**
  79466. * Heightmap-Imposter type
  79467. */
  79468. static HeightmapImpostor: number;
  79469. /**
  79470. * ConvexHull-Impostor type (Ammo.js plugin only)
  79471. */
  79472. static ConvexHullImpostor: number;
  79473. /**
  79474. * Rope-Imposter type
  79475. */
  79476. static RopeImpostor: number;
  79477. /**
  79478. * Cloth-Imposter type
  79479. */
  79480. static ClothImpostor: number;
  79481. /**
  79482. * Softbody-Imposter type
  79483. */
  79484. static SoftbodyImpostor: number;
  79485. }
  79486. }
  79487. declare module BABYLON {
  79488. /**
  79489. * Class used to represent a specific level of detail of a mesh
  79490. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79491. */
  79492. export class MeshLODLevel {
  79493. /** Defines the distance where this level should star being displayed */
  79494. distance: number;
  79495. /** Defines the mesh to use to render this level */
  79496. mesh: Nullable<Mesh>;
  79497. /**
  79498. * Creates a new LOD level
  79499. * @param distance defines the distance where this level should star being displayed
  79500. * @param mesh defines the mesh to use to render this level
  79501. */
  79502. constructor(
  79503. /** Defines the distance where this level should star being displayed */
  79504. distance: number,
  79505. /** Defines the mesh to use to render this level */
  79506. mesh: Nullable<Mesh>);
  79507. }
  79508. /**
  79509. * @hidden
  79510. **/
  79511. export class _CreationDataStorage {
  79512. closePath?: boolean;
  79513. closeArray?: boolean;
  79514. idx: number[];
  79515. dashSize: number;
  79516. gapSize: number;
  79517. path3D: Path3D;
  79518. pathArray: Vector3[][];
  79519. arc: number;
  79520. radius: number;
  79521. cap: number;
  79522. tessellation: number;
  79523. }
  79524. /**
  79525. * @hidden
  79526. **/
  79527. class _InstanceDataStorage {
  79528. visibleInstances: any;
  79529. renderIdForInstances: number[];
  79530. batchCache: _InstancesBatch;
  79531. instancesBufferSize: number;
  79532. instancesBuffer: Nullable<Buffer>;
  79533. instancesData: Float32Array;
  79534. overridenInstanceCount: number;
  79535. }
  79536. /**
  79537. * @hidden
  79538. **/
  79539. export class _InstancesBatch {
  79540. mustReturn: boolean;
  79541. visibleInstances: Nullable<InstancedMesh[]>[];
  79542. renderSelf: boolean[];
  79543. }
  79544. /**
  79545. * Class used to represent renderable models
  79546. */
  79547. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79548. /**
  79549. * Mesh side orientation : usually the external or front surface
  79550. */
  79551. static readonly FRONTSIDE: number;
  79552. /**
  79553. * Mesh side orientation : usually the internal or back surface
  79554. */
  79555. static readonly BACKSIDE: number;
  79556. /**
  79557. * Mesh side orientation : both internal and external or front and back surfaces
  79558. */
  79559. static readonly DOUBLESIDE: number;
  79560. /**
  79561. * Mesh side orientation : by default, `FRONTSIDE`
  79562. */
  79563. static readonly DEFAULTSIDE: number;
  79564. /**
  79565. * Mesh cap setting : no cap
  79566. */
  79567. static readonly NO_CAP: number;
  79568. /**
  79569. * Mesh cap setting : one cap at the beginning of the mesh
  79570. */
  79571. static readonly CAP_START: number;
  79572. /**
  79573. * Mesh cap setting : one cap at the end of the mesh
  79574. */
  79575. static readonly CAP_END: number;
  79576. /**
  79577. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79578. */
  79579. static readonly CAP_ALL: number;
  79580. /**
  79581. * Gets the default side orientation.
  79582. * @param orientation the orientation to value to attempt to get
  79583. * @returns the default orientation
  79584. * @hidden
  79585. */
  79586. static _GetDefaultSideOrientation(orientation?: number): number;
  79587. private _onBeforeRenderObservable;
  79588. private _onBeforeBindObservable;
  79589. private _onAfterRenderObservable;
  79590. private _onBeforeDrawObservable;
  79591. /**
  79592. * An event triggered before rendering the mesh
  79593. */
  79594. readonly onBeforeRenderObservable: Observable<Mesh>;
  79595. /**
  79596. * An event triggered before binding the mesh
  79597. */
  79598. readonly onBeforeBindObservable: Observable<Mesh>;
  79599. /**
  79600. * An event triggered after rendering the mesh
  79601. */
  79602. readonly onAfterRenderObservable: Observable<Mesh>;
  79603. /**
  79604. * An event triggered before drawing the mesh
  79605. */
  79606. readonly onBeforeDrawObservable: Observable<Mesh>;
  79607. private _onBeforeDrawObserver;
  79608. /**
  79609. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79610. */
  79611. onBeforeDraw: () => void;
  79612. /**
  79613. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79614. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79615. */
  79616. delayLoadState: number;
  79617. /**
  79618. * Gets the list of instances created from this mesh
  79619. * it is not supposed to be modified manually.
  79620. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79621. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79622. */
  79623. instances: InstancedMesh[];
  79624. /**
  79625. * Gets the file containing delay loading data for this mesh
  79626. */
  79627. delayLoadingFile: string;
  79628. /** @hidden */
  79629. _binaryInfo: any;
  79630. private _LODLevels;
  79631. /**
  79632. * User defined function used to change how LOD level selection is done
  79633. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79634. */
  79635. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79636. private _morphTargetManager;
  79637. /**
  79638. * Gets or sets the morph target manager
  79639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79640. */
  79641. morphTargetManager: Nullable<MorphTargetManager>;
  79642. /** @hidden */
  79643. _creationDataStorage: Nullable<_CreationDataStorage>;
  79644. /** @hidden */
  79645. _geometry: Nullable<Geometry>;
  79646. /** @hidden */
  79647. _delayInfo: Array<string>;
  79648. /** @hidden */
  79649. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79650. /** @hidden */
  79651. _instanceDataStorage: _InstanceDataStorage;
  79652. private _effectiveMaterial;
  79653. /** @hidden */
  79654. _shouldGenerateFlatShading: boolean;
  79655. private _preActivateId;
  79656. /** @hidden */
  79657. _originalBuilderSideOrientation: number;
  79658. /**
  79659. * Use this property to change the original side orientation defined at construction time
  79660. */
  79661. overrideMaterialSideOrientation: Nullable<number>;
  79662. private _areNormalsFrozen;
  79663. private _sourcePositions;
  79664. private _sourceNormals;
  79665. private _source;
  79666. private meshMap;
  79667. /**
  79668. * Gets the source mesh (the one used to clone this one from)
  79669. */
  79670. readonly source: Nullable<Mesh>;
  79671. /**
  79672. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79673. */
  79674. isUnIndexed: boolean;
  79675. /**
  79676. * @constructor
  79677. * @param name The value used by scene.getMeshByName() to do a lookup.
  79678. * @param scene The scene to add this mesh to.
  79679. * @param parent The parent of this mesh, if it has one
  79680. * @param source An optional Mesh from which geometry is shared, cloned.
  79681. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79682. * When false, achieved by calling a clone(), also passing False.
  79683. * This will make creation of children, recursive.
  79684. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79685. */
  79686. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79687. /**
  79688. * Gets the class name
  79689. * @returns the string "Mesh".
  79690. */
  79691. getClassName(): string;
  79692. /** @hidden */
  79693. readonly _isMesh: boolean;
  79694. /**
  79695. * Returns a description of this mesh
  79696. * @param fullDetails define if full details about this mesh must be used
  79697. * @returns a descriptive string representing this mesh
  79698. */
  79699. toString(fullDetails?: boolean): string;
  79700. /** @hidden */
  79701. _unBindEffect(): void;
  79702. /**
  79703. * Gets a boolean indicating if this mesh has LOD
  79704. */
  79705. readonly hasLODLevels: boolean;
  79706. /**
  79707. * Gets the list of MeshLODLevel associated with the current mesh
  79708. * @returns an array of MeshLODLevel
  79709. */
  79710. getLODLevels(): MeshLODLevel[];
  79711. private _sortLODLevels;
  79712. /**
  79713. * Add a mesh as LOD level triggered at the given distance.
  79714. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79715. * @param distance The distance from the center of the object to show this level
  79716. * @param mesh The mesh to be added as LOD level (can be null)
  79717. * @return This mesh (for chaining)
  79718. */
  79719. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79720. /**
  79721. * Returns the LOD level mesh at the passed distance or null if not found.
  79722. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79723. * @param distance The distance from the center of the object to show this level
  79724. * @returns a Mesh or `null`
  79725. */
  79726. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79727. /**
  79728. * Remove a mesh from the LOD array
  79729. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79730. * @param mesh defines the mesh to be removed
  79731. * @return This mesh (for chaining)
  79732. */
  79733. removeLODLevel(mesh: Mesh): Mesh;
  79734. /**
  79735. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79736. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79737. * @param camera defines the camera to use to compute distance
  79738. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79739. * @return This mesh (for chaining)
  79740. */
  79741. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79742. /**
  79743. * Gets the mesh internal Geometry object
  79744. */
  79745. readonly geometry: Nullable<Geometry>;
  79746. /**
  79747. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79748. * @returns the total number of vertices
  79749. */
  79750. getTotalVertices(): number;
  79751. /**
  79752. * Returns the content of an associated vertex buffer
  79753. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79754. * - VertexBuffer.PositionKind
  79755. * - VertexBuffer.UVKind
  79756. * - VertexBuffer.UV2Kind
  79757. * - VertexBuffer.UV3Kind
  79758. * - VertexBuffer.UV4Kind
  79759. * - VertexBuffer.UV5Kind
  79760. * - VertexBuffer.UV6Kind
  79761. * - VertexBuffer.ColorKind
  79762. * - VertexBuffer.MatricesIndicesKind
  79763. * - VertexBuffer.MatricesIndicesExtraKind
  79764. * - VertexBuffer.MatricesWeightsKind
  79765. * - VertexBuffer.MatricesWeightsExtraKind
  79766. * @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
  79767. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79768. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79769. */
  79770. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79771. /**
  79772. * Returns the mesh VertexBuffer object from the requested `kind`
  79773. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79774. * - VertexBuffer.PositionKind
  79775. * - VertexBuffer.UVKind
  79776. * - VertexBuffer.UV2Kind
  79777. * - VertexBuffer.UV3Kind
  79778. * - VertexBuffer.UV4Kind
  79779. * - VertexBuffer.UV5Kind
  79780. * - VertexBuffer.UV6Kind
  79781. * - VertexBuffer.ColorKind
  79782. * - VertexBuffer.MatricesIndicesKind
  79783. * - VertexBuffer.MatricesIndicesExtraKind
  79784. * - VertexBuffer.MatricesWeightsKind
  79785. * - VertexBuffer.MatricesWeightsExtraKind
  79786. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79787. */
  79788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79789. /**
  79790. * Tests if a specific vertex buffer is associated with this mesh
  79791. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79792. * - VertexBuffer.PositionKind
  79793. * - VertexBuffer.UVKind
  79794. * - VertexBuffer.UV2Kind
  79795. * - VertexBuffer.UV3Kind
  79796. * - VertexBuffer.UV4Kind
  79797. * - VertexBuffer.UV5Kind
  79798. * - VertexBuffer.UV6Kind
  79799. * - VertexBuffer.ColorKind
  79800. * - VertexBuffer.MatricesIndicesKind
  79801. * - VertexBuffer.MatricesIndicesExtraKind
  79802. * - VertexBuffer.MatricesWeightsKind
  79803. * - VertexBuffer.MatricesWeightsExtraKind
  79804. * @returns a boolean
  79805. */
  79806. isVerticesDataPresent(kind: string): boolean;
  79807. /**
  79808. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79809. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79810. * - VertexBuffer.PositionKind
  79811. * - VertexBuffer.UVKind
  79812. * - VertexBuffer.UV2Kind
  79813. * - VertexBuffer.UV3Kind
  79814. * - VertexBuffer.UV4Kind
  79815. * - VertexBuffer.UV5Kind
  79816. * - VertexBuffer.UV6Kind
  79817. * - VertexBuffer.ColorKind
  79818. * - VertexBuffer.MatricesIndicesKind
  79819. * - VertexBuffer.MatricesIndicesExtraKind
  79820. * - VertexBuffer.MatricesWeightsKind
  79821. * - VertexBuffer.MatricesWeightsExtraKind
  79822. * @returns a boolean
  79823. */
  79824. isVertexBufferUpdatable(kind: string): boolean;
  79825. /**
  79826. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79827. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79828. * - VertexBuffer.PositionKind
  79829. * - VertexBuffer.UVKind
  79830. * - VertexBuffer.UV2Kind
  79831. * - VertexBuffer.UV3Kind
  79832. * - VertexBuffer.UV4Kind
  79833. * - VertexBuffer.UV5Kind
  79834. * - VertexBuffer.UV6Kind
  79835. * - VertexBuffer.ColorKind
  79836. * - VertexBuffer.MatricesIndicesKind
  79837. * - VertexBuffer.MatricesIndicesExtraKind
  79838. * - VertexBuffer.MatricesWeightsKind
  79839. * - VertexBuffer.MatricesWeightsExtraKind
  79840. * @returns an array of strings
  79841. */
  79842. getVerticesDataKinds(): string[];
  79843. /**
  79844. * Returns a positive integer : the total number of indices in this mesh geometry.
  79845. * @returns the numner of indices or zero if the mesh has no geometry.
  79846. */
  79847. getTotalIndices(): number;
  79848. /**
  79849. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79850. * @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.
  79851. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79852. * @returns the indices array or an empty array if the mesh has no geometry
  79853. */
  79854. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79855. readonly isBlocked: boolean;
  79856. /**
  79857. * Determine if the current mesh is ready to be rendered
  79858. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79859. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79860. * @returns true if all associated assets are ready (material, textures, shaders)
  79861. */
  79862. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79863. /**
  79864. * 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.
  79865. */
  79866. readonly areNormalsFrozen: boolean;
  79867. /**
  79868. * 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.
  79869. * @returns the current mesh
  79870. */
  79871. freezeNormals(): Mesh;
  79872. /**
  79873. * 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
  79874. * @returns the current mesh
  79875. */
  79876. unfreezeNormals(): Mesh;
  79877. /**
  79878. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79879. */
  79880. overridenInstanceCount: number;
  79881. /** @hidden */
  79882. _preActivate(): Mesh;
  79883. /** @hidden */
  79884. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79885. /** @hidden */
  79886. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79887. /**
  79888. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79889. * This means the mesh underlying bounding box and sphere are recomputed.
  79890. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79891. * @returns the current mesh
  79892. */
  79893. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79894. /** @hidden */
  79895. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79896. /**
  79897. * This function will subdivide the mesh into multiple submeshes
  79898. * @param count defines the expected number of submeshes
  79899. */
  79900. subdivide(count: number): void;
  79901. /**
  79902. * Copy a FloatArray into a specific associated vertex buffer
  79903. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79904. * - VertexBuffer.PositionKind
  79905. * - VertexBuffer.UVKind
  79906. * - VertexBuffer.UV2Kind
  79907. * - VertexBuffer.UV3Kind
  79908. * - VertexBuffer.UV4Kind
  79909. * - VertexBuffer.UV5Kind
  79910. * - VertexBuffer.UV6Kind
  79911. * - VertexBuffer.ColorKind
  79912. * - VertexBuffer.MatricesIndicesKind
  79913. * - VertexBuffer.MatricesIndicesExtraKind
  79914. * - VertexBuffer.MatricesWeightsKind
  79915. * - VertexBuffer.MatricesWeightsExtraKind
  79916. * @param data defines the data source
  79917. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79918. * @param stride defines the data stride size (can be null)
  79919. * @returns the current mesh
  79920. */
  79921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79922. /**
  79923. * Flags an associated vertex buffer as updatable
  79924. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79925. * - VertexBuffer.PositionKind
  79926. * - VertexBuffer.UVKind
  79927. * - VertexBuffer.UV2Kind
  79928. * - VertexBuffer.UV3Kind
  79929. * - VertexBuffer.UV4Kind
  79930. * - VertexBuffer.UV5Kind
  79931. * - VertexBuffer.UV6Kind
  79932. * - VertexBuffer.ColorKind
  79933. * - VertexBuffer.MatricesIndicesKind
  79934. * - VertexBuffer.MatricesIndicesExtraKind
  79935. * - VertexBuffer.MatricesWeightsKind
  79936. * - VertexBuffer.MatricesWeightsExtraKind
  79937. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79938. */
  79939. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79940. /**
  79941. * Sets the mesh global Vertex Buffer
  79942. * @param buffer defines the buffer to use
  79943. * @returns the current mesh
  79944. */
  79945. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79946. /**
  79947. * Update a specific associated vertex buffer
  79948. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79949. * - VertexBuffer.PositionKind
  79950. * - VertexBuffer.UVKind
  79951. * - VertexBuffer.UV2Kind
  79952. * - VertexBuffer.UV3Kind
  79953. * - VertexBuffer.UV4Kind
  79954. * - VertexBuffer.UV5Kind
  79955. * - VertexBuffer.UV6Kind
  79956. * - VertexBuffer.ColorKind
  79957. * - VertexBuffer.MatricesIndicesKind
  79958. * - VertexBuffer.MatricesIndicesExtraKind
  79959. * - VertexBuffer.MatricesWeightsKind
  79960. * - VertexBuffer.MatricesWeightsExtraKind
  79961. * @param data defines the data source
  79962. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79963. * @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)
  79964. * @returns the current mesh
  79965. */
  79966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79967. /**
  79968. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79969. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79970. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79971. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79972. * @returns the current mesh
  79973. */
  79974. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79975. /**
  79976. * Creates a un-shared specific occurence of the geometry for the mesh.
  79977. * @returns the current mesh
  79978. */
  79979. makeGeometryUnique(): Mesh;
  79980. /**
  79981. * Set the index buffer of this mesh
  79982. * @param indices defines the source data
  79983. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79984. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79985. * @returns the current mesh
  79986. */
  79987. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79988. /**
  79989. * Update the current index buffer
  79990. * @param indices defines the source data
  79991. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79992. * @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)
  79993. * @returns the current mesh
  79994. */
  79995. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79996. /**
  79997. * Invert the geometry to move from a right handed system to a left handed one.
  79998. * @returns the current mesh
  79999. */
  80000. toLeftHanded(): Mesh;
  80001. /** @hidden */
  80002. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80003. /** @hidden */
  80004. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80005. /**
  80006. * Registers for this mesh a javascript function called just before the rendering process
  80007. * @param func defines the function to call before rendering this mesh
  80008. * @returns the current mesh
  80009. */
  80010. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80011. /**
  80012. * Disposes a previously registered javascript function called before the rendering
  80013. * @param func defines the function to remove
  80014. * @returns the current mesh
  80015. */
  80016. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80017. /**
  80018. * Registers for this mesh a javascript function called just after the rendering is complete
  80019. * @param func defines the function to call after rendering this mesh
  80020. * @returns the current mesh
  80021. */
  80022. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80023. /**
  80024. * Disposes a previously registered javascript function called after the rendering.
  80025. * @param func defines the function to remove
  80026. * @returns the current mesh
  80027. */
  80028. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80029. /** @hidden */
  80030. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80031. /** @hidden */
  80032. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80033. /** @hidden */
  80034. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80035. /**
  80036. * 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
  80037. * @param subMesh defines the subMesh to render
  80038. * @param enableAlphaMode defines if alpha mode can be changed
  80039. * @returns the current mesh
  80040. */
  80041. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80042. private _onBeforeDraw;
  80043. /**
  80044. * Renormalize the mesh and patch it up if there are no weights
  80045. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80046. * However in the case of zero weights then we set just a single influence to 1.
  80047. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80048. */
  80049. cleanMatrixWeights(): void;
  80050. private normalizeSkinFourWeights;
  80051. private normalizeSkinWeightsAndExtra;
  80052. /**
  80053. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80054. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80055. * the user know there was an issue with importing the mesh
  80056. * @returns a validation object with skinned, valid and report string
  80057. */
  80058. validateSkinning(): {
  80059. skinned: boolean;
  80060. valid: boolean;
  80061. report: string;
  80062. };
  80063. /** @hidden */
  80064. _checkDelayState(): Mesh;
  80065. private _queueLoad;
  80066. /**
  80067. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80068. * A mesh is in the frustum if its bounding box intersects the frustum
  80069. * @param frustumPlanes defines the frustum to test
  80070. * @returns true if the mesh is in the frustum planes
  80071. */
  80072. isInFrustum(frustumPlanes: Plane[]): boolean;
  80073. /**
  80074. * Sets the mesh material by the material or multiMaterial `id` property
  80075. * @param id is a string identifying the material or the multiMaterial
  80076. * @returns the current mesh
  80077. */
  80078. setMaterialByID(id: string): Mesh;
  80079. /**
  80080. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80081. * @returns an array of IAnimatable
  80082. */
  80083. getAnimatables(): IAnimatable[];
  80084. /**
  80085. * Modifies the mesh geometry according to the passed transformation matrix.
  80086. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80087. * The mesh normals are modified using the same transformation.
  80088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80089. * @param transform defines the transform matrix to use
  80090. * @see http://doc.babylonjs.com/resources/baking_transformations
  80091. * @returns the current mesh
  80092. */
  80093. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80094. /**
  80095. * Modifies the mesh geometry according to its own current World Matrix.
  80096. * The mesh World Matrix is then reset.
  80097. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80098. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80099. * @see http://doc.babylonjs.com/resources/baking_transformations
  80100. * @returns the current mesh
  80101. */
  80102. bakeCurrentTransformIntoVertices(): Mesh;
  80103. /** @hidden */
  80104. readonly _positions: Nullable<Vector3[]>;
  80105. /** @hidden */
  80106. _resetPointsArrayCache(): Mesh;
  80107. /** @hidden */
  80108. _generatePointsArray(): boolean;
  80109. /**
  80110. * Returns a new Mesh object generated from the current mesh properties.
  80111. * This method must not get confused with createInstance()
  80112. * @param name is a string, the name given to the new mesh
  80113. * @param newParent can be any Node object (default `null`)
  80114. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80115. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80116. * @returns a new mesh
  80117. */
  80118. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80119. /**
  80120. * Releases resources associated with this mesh.
  80121. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80122. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80123. */
  80124. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80125. /**
  80126. * Modifies the mesh geometry according to a displacement map.
  80127. * 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.
  80128. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80129. * @param url is a string, the URL from the image file is to be downloaded.
  80130. * @param minHeight is the lower limit of the displacement.
  80131. * @param maxHeight is the upper limit of the displacement.
  80132. * @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.
  80133. * @param uvOffset is an optional vector2 used to offset UV.
  80134. * @param uvScale is an optional vector2 used to scale UV.
  80135. * @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.
  80136. * @returns the Mesh.
  80137. */
  80138. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80139. /**
  80140. * Modifies the mesh geometry according to a displacementMap buffer.
  80141. * 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.
  80142. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80143. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80144. * @param heightMapWidth is the width of the buffer image.
  80145. * @param heightMapHeight is the height of the buffer image.
  80146. * @param minHeight is the lower limit of the displacement.
  80147. * @param maxHeight is the upper limit of the displacement.
  80148. * @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.
  80149. * @param uvOffset is an optional vector2 used to offset UV.
  80150. * @param uvScale is an optional vector2 used to scale UV.
  80151. * @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.
  80152. * @returns the Mesh.
  80153. */
  80154. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80155. /**
  80156. * Modify the mesh to get a flat shading rendering.
  80157. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80158. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80159. * @returns current mesh
  80160. */
  80161. convertToFlatShadedMesh(): Mesh;
  80162. /**
  80163. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80164. * In other words, more vertices, no more indices and a single bigger VBO.
  80165. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80166. * @returns current mesh
  80167. */
  80168. convertToUnIndexedMesh(): Mesh;
  80169. /**
  80170. * Inverses facet orientations.
  80171. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80172. * @param flipNormals will also inverts the normals
  80173. * @returns current mesh
  80174. */
  80175. flipFaces(flipNormals?: boolean): Mesh;
  80176. /**
  80177. * Increase the number of facets and hence vertices in a mesh
  80178. * Vertex normals are interpolated from existing vertex normals
  80179. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80180. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80181. */
  80182. increaseVertices(numberPerEdge: number): void;
  80183. /**
  80184. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80185. * This will undo any application of covertToFlatShadedMesh
  80186. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80187. */
  80188. forceSharedVertices(): void;
  80189. /** @hidden */
  80190. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80191. /** @hidden */
  80192. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80193. /**
  80194. * Creates a new InstancedMesh object from the mesh model.
  80195. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80196. * @param name defines the name of the new instance
  80197. * @returns a new InstancedMesh
  80198. */
  80199. createInstance(name: string): InstancedMesh;
  80200. /**
  80201. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80202. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80203. * @returns the current mesh
  80204. */
  80205. synchronizeInstances(): Mesh;
  80206. /**
  80207. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80208. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80209. * This should be used together with the simplification to avoid disappearing triangles.
  80210. * @param successCallback an optional success callback to be called after the optimization finished.
  80211. * @returns the current mesh
  80212. */
  80213. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80214. /**
  80215. * Serialize current mesh
  80216. * @param serializationObject defines the object which will receive the serialization data
  80217. */
  80218. serialize(serializationObject: any): void;
  80219. /** @hidden */
  80220. _syncGeometryWithMorphTargetManager(): void;
  80221. /** @hidden */
  80222. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80223. /**
  80224. * Returns a new Mesh object parsed from the source provided.
  80225. * @param parsedMesh is the source
  80226. * @param scene defines the hosting scene
  80227. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80228. * @returns a new Mesh
  80229. */
  80230. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80231. /**
  80232. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80233. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80234. * @param name defines the name of the mesh to create
  80235. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80236. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80237. * @param closePath creates a seam between the first and the last points of each path of the path array
  80238. * @param offset is taken in account only if the `pathArray` is containing a single path
  80239. * @param scene defines the hosting scene
  80240. * @param updatable defines if the mesh must be flagged as updatable
  80241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80242. * @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)
  80243. * @returns a new Mesh
  80244. */
  80245. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80246. /**
  80247. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80248. * @param name defines the name of the mesh to create
  80249. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80250. * @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
  80251. * @param scene defines the hosting scene
  80252. * @param updatable defines if the mesh must be flagged as updatable
  80253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80254. * @returns a new Mesh
  80255. */
  80256. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80257. /**
  80258. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80259. * @param name defines the name of the mesh to create
  80260. * @param size sets the size (float) of each box side (default 1)
  80261. * @param scene defines the hosting scene
  80262. * @param updatable defines if the mesh must be flagged as updatable
  80263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80264. * @returns a new Mesh
  80265. */
  80266. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80267. /**
  80268. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80269. * @param name defines the name of the mesh to create
  80270. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80271. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80272. * @param scene defines the hosting scene
  80273. * @param updatable defines if the mesh must be flagged as updatable
  80274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80275. * @returns a new Mesh
  80276. */
  80277. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80278. /**
  80279. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80280. * @param name defines the name of the mesh to create
  80281. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80282. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80283. * @param scene defines the hosting scene
  80284. * @returns a new Mesh
  80285. */
  80286. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80287. /**
  80288. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80289. * @param name defines the name of the mesh to create
  80290. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80291. * @param diameterTop set the top cap diameter (floats, default 1)
  80292. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80293. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80294. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80295. * @param scene defines the hosting scene
  80296. * @param updatable defines if the mesh must be flagged as updatable
  80297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80298. * @returns a new Mesh
  80299. */
  80300. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80301. /**
  80302. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80303. * @param name defines the name of the mesh to create
  80304. * @param diameter sets the diameter size (float) of the torus (default 1)
  80305. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80306. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80307. * @param scene defines the hosting scene
  80308. * @param updatable defines if the mesh must be flagged as updatable
  80309. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80310. * @returns a new Mesh
  80311. */
  80312. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80313. /**
  80314. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80315. * @param name defines the name of the mesh to create
  80316. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80317. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80318. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80319. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80320. * @param p the number of windings on X axis (positive integers, default 2)
  80321. * @param q the number of windings on Y axis (positive integers, default 3)
  80322. * @param scene defines the hosting scene
  80323. * @param updatable defines if the mesh must be flagged as updatable
  80324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80325. * @returns a new Mesh
  80326. */
  80327. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80328. /**
  80329. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80330. * @param name defines the name of the mesh to create
  80331. * @param points is an array successive Vector3
  80332. * @param scene defines the hosting scene
  80333. * @param updatable defines if the mesh must be flagged as updatable
  80334. * @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).
  80335. * @returns a new Mesh
  80336. */
  80337. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80338. /**
  80339. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80340. * @param name defines the name of the mesh to create
  80341. * @param points is an array successive Vector3
  80342. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80343. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80344. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80345. * @param scene defines the hosting scene
  80346. * @param updatable defines if the mesh must be flagged as updatable
  80347. * @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)
  80348. * @returns a new Mesh
  80349. */
  80350. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80351. /**
  80352. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80353. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80354. * 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.
  80355. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80356. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80357. * Remember you can only change the shape positions, not their number when updating a polygon.
  80358. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80359. * @param name defines the name of the mesh to create
  80360. * @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
  80361. * @param scene defines the hosting scene
  80362. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80363. * @param updatable defines if the mesh must be flagged as updatable
  80364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80365. * @param earcutInjection can be used to inject your own earcut reference
  80366. * @returns a new Mesh
  80367. */
  80368. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80369. /**
  80370. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80372. * @param name defines the name of the mesh to create
  80373. * @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
  80374. * @param depth defines the height of extrusion
  80375. * @param scene defines the hosting scene
  80376. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80377. * @param updatable defines if the mesh must be flagged as updatable
  80378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80379. * @param earcutInjection can be used to inject your own earcut reference
  80380. * @returns a new Mesh
  80381. */
  80382. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80383. /**
  80384. * Creates an extruded shape mesh.
  80385. * 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
  80386. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80387. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80388. * @param name defines the name of the mesh to create
  80389. * @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
  80390. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80391. * @param scale is the value to scale the shape
  80392. * @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
  80393. * @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
  80394. * @param scene defines the hosting scene
  80395. * @param updatable defines if the mesh must be flagged as updatable
  80396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80397. * @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)
  80398. * @returns a new Mesh
  80399. */
  80400. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80401. /**
  80402. * Creates an custom extruded shape mesh.
  80403. * The custom extrusion is a parametric shape.
  80404. * It has no predefined shape. Its final shape will depend on the input parameters.
  80405. * Please consider using the same method from the MeshBuilder class instead
  80406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80407. * @param name defines the name of the mesh to create
  80408. * @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
  80409. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80410. * @param scaleFunction is a custom Javascript function called on each path point
  80411. * @param rotationFunction is a custom Javascript function called on each path point
  80412. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80413. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80414. * @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
  80415. * @param scene defines the hosting scene
  80416. * @param updatable defines if the mesh must be flagged as updatable
  80417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80418. * @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)
  80419. * @returns a new Mesh
  80420. */
  80421. 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;
  80422. /**
  80423. * Creates lathe mesh.
  80424. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80425. * Please consider using the same method from the MeshBuilder class instead
  80426. * @param name defines the name of the mesh to create
  80427. * @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
  80428. * @param radius is the radius value of the lathe
  80429. * @param tessellation is the side number of the lathe.
  80430. * @param scene defines the hosting scene
  80431. * @param updatable defines if the mesh must be flagged as updatable
  80432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80433. * @returns a new Mesh
  80434. */
  80435. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80436. /**
  80437. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80438. * @param name defines the name of the mesh to create
  80439. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80440. * @param scene defines the hosting scene
  80441. * @param updatable defines if the mesh must be flagged as updatable
  80442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80443. * @returns a new Mesh
  80444. */
  80445. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80446. /**
  80447. * Creates a ground mesh.
  80448. * Please consider using the same method from the MeshBuilder class instead
  80449. * @param name defines the name of the mesh to create
  80450. * @param width set the width of the ground
  80451. * @param height set the height of the ground
  80452. * @param subdivisions sets the number of subdivisions per side
  80453. * @param scene defines the hosting scene
  80454. * @param updatable defines if the mesh must be flagged as updatable
  80455. * @returns a new Mesh
  80456. */
  80457. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80458. /**
  80459. * Creates a tiled ground mesh.
  80460. * Please consider using the same method from the MeshBuilder class instead
  80461. * @param name defines the name of the mesh to create
  80462. * @param xmin set the ground minimum X coordinate
  80463. * @param zmin set the ground minimum Y coordinate
  80464. * @param xmax set the ground maximum X coordinate
  80465. * @param zmax set the ground maximum Z coordinate
  80466. * @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
  80467. * @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
  80468. * @param scene defines the hosting scene
  80469. * @param updatable defines if the mesh must be flagged as updatable
  80470. * @returns a new Mesh
  80471. */
  80472. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80473. w: number;
  80474. h: number;
  80475. }, precision: {
  80476. w: number;
  80477. h: number;
  80478. }, scene: Scene, updatable?: boolean): Mesh;
  80479. /**
  80480. * Creates a ground mesh from a height map.
  80481. * Please consider using the same method from the MeshBuilder class instead
  80482. * @see http://doc.babylonjs.com/babylon101/height_map
  80483. * @param name defines the name of the mesh to create
  80484. * @param url sets the URL of the height map image resource
  80485. * @param width set the ground width size
  80486. * @param height set the ground height size
  80487. * @param subdivisions sets the number of subdivision per side
  80488. * @param minHeight is the minimum altitude on the ground
  80489. * @param maxHeight is the maximum altitude on the ground
  80490. * @param scene defines the hosting scene
  80491. * @param updatable defines if the mesh must be flagged as updatable
  80492. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80493. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80494. * @returns a new Mesh
  80495. */
  80496. 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;
  80497. /**
  80498. * Creates a tube mesh.
  80499. * The tube is a parametric shape.
  80500. * It has no predefined shape. Its final shape will depend on the input parameters.
  80501. * Please consider using the same method from the MeshBuilder class instead
  80502. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80503. * @param name defines the name of the mesh to create
  80504. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80505. * @param radius sets the tube radius size
  80506. * @param tessellation is the number of sides on the tubular surface
  80507. * @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
  80508. * @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
  80509. * @param scene defines the hosting scene
  80510. * @param updatable defines if the mesh must be flagged as updatable
  80511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80512. * @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)
  80513. * @returns a new Mesh
  80514. */
  80515. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80516. (i: number, distance: number): number;
  80517. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80518. /**
  80519. * Creates a polyhedron mesh.
  80520. * Please consider using the same method from the MeshBuilder class instead.
  80521. * * 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
  80522. * * The parameter `size` (positive float, default 1) sets the polygon size
  80523. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80524. * * 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`
  80525. * * 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
  80526. * * 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)`)
  80527. * * 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
  80528. * * 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
  80529. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80530. * * If you create a double-sided mesh, you can choose what parts of 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
  80531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80532. * @param name defines the name of the mesh to create
  80533. * @param options defines the options used to create the mesh
  80534. * @param scene defines the hosting scene
  80535. * @returns a new Mesh
  80536. */
  80537. static CreatePolyhedron(name: string, options: {
  80538. type?: number;
  80539. size?: number;
  80540. sizeX?: number;
  80541. sizeY?: number;
  80542. sizeZ?: number;
  80543. custom?: any;
  80544. faceUV?: Vector4[];
  80545. faceColors?: Color4[];
  80546. updatable?: boolean;
  80547. sideOrientation?: number;
  80548. }, scene: Scene): Mesh;
  80549. /**
  80550. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80551. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80552. * * 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`)
  80553. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80554. * * 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
  80555. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80556. * * If you create a double-sided mesh, you can choose what parts of 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
  80557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80558. * @param name defines the name of the mesh
  80559. * @param options defines the options used to create the mesh
  80560. * @param scene defines the hosting scene
  80561. * @returns a new Mesh
  80562. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80563. */
  80564. static CreateIcoSphere(name: string, options: {
  80565. radius?: number;
  80566. flat?: boolean;
  80567. subdivisions?: number;
  80568. sideOrientation?: number;
  80569. updatable?: boolean;
  80570. }, scene: Scene): Mesh;
  80571. /**
  80572. * Creates a decal mesh.
  80573. * Please consider using the same method from the MeshBuilder class instead.
  80574. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80575. * @param name defines the name of the mesh
  80576. * @param sourceMesh defines the mesh receiving the decal
  80577. * @param position sets the position of the decal in world coordinates
  80578. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80579. * @param size sets the decal scaling
  80580. * @param angle sets the angle to rotate the decal
  80581. * @returns a new Mesh
  80582. */
  80583. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80584. /**
  80585. * Prepare internal position array for software CPU skinning
  80586. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80587. */
  80588. setPositionsForCPUSkinning(): Float32Array;
  80589. /**
  80590. * Prepare internal normal array for software CPU skinning
  80591. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80592. */
  80593. setNormalsForCPUSkinning(): Float32Array;
  80594. /**
  80595. * Updates the vertex buffer by applying transformation from the bones
  80596. * @param skeleton defines the skeleton to apply to current mesh
  80597. * @returns the current mesh
  80598. */
  80599. applySkeleton(skeleton: Skeleton): Mesh;
  80600. /**
  80601. * 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
  80602. * @param meshes defines the list of meshes to scan
  80603. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80604. */
  80605. static MinMax(meshes: AbstractMesh[]): {
  80606. min: Vector3;
  80607. max: Vector3;
  80608. };
  80609. /**
  80610. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80611. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80612. * @returns a vector3
  80613. */
  80614. static Center(meshesOrMinMaxVector: {
  80615. min: Vector3;
  80616. max: Vector3;
  80617. } | AbstractMesh[]): Vector3;
  80618. /**
  80619. * Merge the array of meshes into a single mesh for performance reasons.
  80620. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80621. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80622. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80623. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80624. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80625. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80626. * @returns a new mesh
  80627. */
  80628. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80629. /** @hidden */
  80630. addInstance(instance: InstancedMesh): void;
  80631. /** @hidden */
  80632. removeInstance(instance: InstancedMesh): void;
  80633. }
  80634. }
  80635. declare module BABYLON {
  80636. /**
  80637. * Base class for the main features of a material in Babylon.js
  80638. */
  80639. export class Material implements IAnimatable {
  80640. /**
  80641. * Returns the triangle fill mode
  80642. */
  80643. static readonly TriangleFillMode: number;
  80644. /**
  80645. * Returns the wireframe mode
  80646. */
  80647. static readonly WireFrameFillMode: number;
  80648. /**
  80649. * Returns the point fill mode
  80650. */
  80651. static readonly PointFillMode: number;
  80652. /**
  80653. * Returns the point list draw mode
  80654. */
  80655. static readonly PointListDrawMode: number;
  80656. /**
  80657. * Returns the line list draw mode
  80658. */
  80659. static readonly LineListDrawMode: number;
  80660. /**
  80661. * Returns the line loop draw mode
  80662. */
  80663. static readonly LineLoopDrawMode: number;
  80664. /**
  80665. * Returns the line strip draw mode
  80666. */
  80667. static readonly LineStripDrawMode: number;
  80668. /**
  80669. * Returns the triangle strip draw mode
  80670. */
  80671. static readonly TriangleStripDrawMode: number;
  80672. /**
  80673. * Returns the triangle fan draw mode
  80674. */
  80675. static readonly TriangleFanDrawMode: number;
  80676. /**
  80677. * Stores the clock-wise side orientation
  80678. */
  80679. static readonly ClockWiseSideOrientation: number;
  80680. /**
  80681. * Stores the counter clock-wise side orientation
  80682. */
  80683. static readonly CounterClockWiseSideOrientation: number;
  80684. /**
  80685. * The dirty texture flag value
  80686. */
  80687. static readonly TextureDirtyFlag: number;
  80688. /**
  80689. * The dirty light flag value
  80690. */
  80691. static readonly LightDirtyFlag: number;
  80692. /**
  80693. * The dirty fresnel flag value
  80694. */
  80695. static readonly FresnelDirtyFlag: number;
  80696. /**
  80697. * The dirty attribute flag value
  80698. */
  80699. static readonly AttributesDirtyFlag: number;
  80700. /**
  80701. * The dirty misc flag value
  80702. */
  80703. static readonly MiscDirtyFlag: number;
  80704. /**
  80705. * The all dirty flag value
  80706. */
  80707. static readonly AllDirtyFlag: number;
  80708. /**
  80709. * The ID of the material
  80710. */
  80711. id: string;
  80712. /**
  80713. * Gets or sets the unique id of the material
  80714. */
  80715. uniqueId: number;
  80716. /**
  80717. * The name of the material
  80718. */
  80719. name: string;
  80720. /**
  80721. * Gets or sets user defined metadata
  80722. */
  80723. metadata: any;
  80724. /**
  80725. * For internal use only. Please do not use.
  80726. */
  80727. reservedDataStore: any;
  80728. /**
  80729. * Specifies if the ready state should be checked on each call
  80730. */
  80731. checkReadyOnEveryCall: boolean;
  80732. /**
  80733. * Specifies if the ready state should be checked once
  80734. */
  80735. checkReadyOnlyOnce: boolean;
  80736. /**
  80737. * The state of the material
  80738. */
  80739. state: string;
  80740. /**
  80741. * The alpha value of the material
  80742. */
  80743. protected _alpha: number;
  80744. /**
  80745. * List of inspectable custom properties (used by the Inspector)
  80746. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80747. */
  80748. inspectableCustomProperties: IInspectable[];
  80749. /**
  80750. * Sets the alpha value of the material
  80751. */
  80752. /**
  80753. * Gets the alpha value of the material
  80754. */
  80755. alpha: number;
  80756. /**
  80757. * Specifies if back face culling is enabled
  80758. */
  80759. protected _backFaceCulling: boolean;
  80760. /**
  80761. * Sets the back-face culling state
  80762. */
  80763. /**
  80764. * Gets the back-face culling state
  80765. */
  80766. backFaceCulling: boolean;
  80767. /**
  80768. * Stores the value for side orientation
  80769. */
  80770. sideOrientation: number;
  80771. /**
  80772. * Callback triggered when the material is compiled
  80773. */
  80774. onCompiled: (effect: Effect) => void;
  80775. /**
  80776. * Callback triggered when an error occurs
  80777. */
  80778. onError: (effect: Effect, errors: string) => void;
  80779. /**
  80780. * Callback triggered to get the render target textures
  80781. */
  80782. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80783. /**
  80784. * Gets a boolean indicating that current material needs to register RTT
  80785. */
  80786. readonly hasRenderTargetTextures: boolean;
  80787. /**
  80788. * Specifies if the material should be serialized
  80789. */
  80790. doNotSerialize: boolean;
  80791. /**
  80792. * @hidden
  80793. */
  80794. _storeEffectOnSubMeshes: boolean;
  80795. /**
  80796. * Stores the animations for the material
  80797. */
  80798. animations: Array<Animation>;
  80799. /**
  80800. * An event triggered when the material is disposed
  80801. */
  80802. onDisposeObservable: Observable<Material>;
  80803. /**
  80804. * An observer which watches for dispose events
  80805. */
  80806. private _onDisposeObserver;
  80807. private _onUnBindObservable;
  80808. /**
  80809. * Called during a dispose event
  80810. */
  80811. onDispose: () => void;
  80812. private _onBindObservable;
  80813. /**
  80814. * An event triggered when the material is bound
  80815. */
  80816. readonly onBindObservable: Observable<AbstractMesh>;
  80817. /**
  80818. * An observer which watches for bind events
  80819. */
  80820. private _onBindObserver;
  80821. /**
  80822. * Called during a bind event
  80823. */
  80824. onBind: (Mesh: AbstractMesh) => void;
  80825. /**
  80826. * An event triggered when the material is unbound
  80827. */
  80828. readonly onUnBindObservable: Observable<Material>;
  80829. /**
  80830. * Stores the value of the alpha mode
  80831. */
  80832. private _alphaMode;
  80833. /**
  80834. * Sets the value of the alpha mode.
  80835. *
  80836. * | Value | Type | Description |
  80837. * | --- | --- | --- |
  80838. * | 0 | ALPHA_DISABLE | |
  80839. * | 1 | ALPHA_ADD | |
  80840. * | 2 | ALPHA_COMBINE | |
  80841. * | 3 | ALPHA_SUBTRACT | |
  80842. * | 4 | ALPHA_MULTIPLY | |
  80843. * | 5 | ALPHA_MAXIMIZED | |
  80844. * | 6 | ALPHA_ONEONE | |
  80845. * | 7 | ALPHA_PREMULTIPLIED | |
  80846. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80847. * | 9 | ALPHA_INTERPOLATE | |
  80848. * | 10 | ALPHA_SCREENMODE | |
  80849. *
  80850. */
  80851. /**
  80852. * Gets the value of the alpha mode
  80853. */
  80854. alphaMode: number;
  80855. /**
  80856. * Stores the state of the need depth pre-pass value
  80857. */
  80858. private _needDepthPrePass;
  80859. /**
  80860. * Sets the need depth pre-pass value
  80861. */
  80862. /**
  80863. * Gets the depth pre-pass value
  80864. */
  80865. needDepthPrePass: boolean;
  80866. /**
  80867. * Specifies if depth writing should be disabled
  80868. */
  80869. disableDepthWrite: boolean;
  80870. /**
  80871. * Specifies if depth writing should be forced
  80872. */
  80873. forceDepthWrite: boolean;
  80874. /**
  80875. * Specifies if there should be a separate pass for culling
  80876. */
  80877. separateCullingPass: boolean;
  80878. /**
  80879. * Stores the state specifing if fog should be enabled
  80880. */
  80881. private _fogEnabled;
  80882. /**
  80883. * Sets the state for enabling fog
  80884. */
  80885. /**
  80886. * Gets the value of the fog enabled state
  80887. */
  80888. fogEnabled: boolean;
  80889. /**
  80890. * Stores the size of points
  80891. */
  80892. pointSize: number;
  80893. /**
  80894. * Stores the z offset value
  80895. */
  80896. zOffset: number;
  80897. /**
  80898. * Gets a value specifying if wireframe mode is enabled
  80899. */
  80900. /**
  80901. * Sets the state of wireframe mode
  80902. */
  80903. wireframe: boolean;
  80904. /**
  80905. * Gets the value specifying if point clouds are enabled
  80906. */
  80907. /**
  80908. * Sets the state of point cloud mode
  80909. */
  80910. pointsCloud: boolean;
  80911. /**
  80912. * Gets the material fill mode
  80913. */
  80914. /**
  80915. * Sets the material fill mode
  80916. */
  80917. fillMode: number;
  80918. /**
  80919. * @hidden
  80920. * Stores the effects for the material
  80921. */
  80922. _effect: Nullable<Effect>;
  80923. /**
  80924. * @hidden
  80925. * Specifies if the material was previously ready
  80926. */
  80927. _wasPreviouslyReady: boolean;
  80928. /**
  80929. * Specifies if uniform buffers should be used
  80930. */
  80931. private _useUBO;
  80932. /**
  80933. * Stores a reference to the scene
  80934. */
  80935. private _scene;
  80936. /**
  80937. * Stores the fill mode state
  80938. */
  80939. private _fillMode;
  80940. /**
  80941. * Specifies if the depth write state should be cached
  80942. */
  80943. private _cachedDepthWriteState;
  80944. /**
  80945. * Stores the uniform buffer
  80946. */
  80947. protected _uniformBuffer: UniformBuffer;
  80948. /** @hidden */
  80949. _indexInSceneMaterialArray: number;
  80950. /** @hidden */
  80951. meshMap: Nullable<{
  80952. [id: string]: AbstractMesh | undefined;
  80953. }>;
  80954. /**
  80955. * Creates a material instance
  80956. * @param name defines the name of the material
  80957. * @param scene defines the scene to reference
  80958. * @param doNotAdd specifies if the material should be added to the scene
  80959. */
  80960. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80961. /**
  80962. * Returns a string representation of the current material
  80963. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80964. * @returns a string with material information
  80965. */
  80966. toString(fullDetails?: boolean): string;
  80967. /**
  80968. * Gets the class name of the material
  80969. * @returns a string with the class name of the material
  80970. */
  80971. getClassName(): string;
  80972. /**
  80973. * Specifies if updates for the material been locked
  80974. */
  80975. readonly isFrozen: boolean;
  80976. /**
  80977. * Locks updates for the material
  80978. */
  80979. freeze(): void;
  80980. /**
  80981. * Unlocks updates for the material
  80982. */
  80983. unfreeze(): void;
  80984. /**
  80985. * Specifies if the material is ready to be used
  80986. * @param mesh defines the mesh to check
  80987. * @param useInstances specifies if instances should be used
  80988. * @returns a boolean indicating if the material is ready to be used
  80989. */
  80990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80991. /**
  80992. * Specifies that the submesh is ready to be used
  80993. * @param mesh defines the mesh to check
  80994. * @param subMesh defines which submesh to check
  80995. * @param useInstances specifies that instances should be used
  80996. * @returns a boolean indicating that the submesh is ready or not
  80997. */
  80998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80999. /**
  81000. * Returns the material effect
  81001. * @returns the effect associated with the material
  81002. */
  81003. getEffect(): Nullable<Effect>;
  81004. /**
  81005. * Returns the current scene
  81006. * @returns a Scene
  81007. */
  81008. getScene(): Scene;
  81009. /**
  81010. * Specifies if the material will require alpha blending
  81011. * @returns a boolean specifying if alpha blending is needed
  81012. */
  81013. needAlphaBlending(): boolean;
  81014. /**
  81015. * Specifies if the mesh will require alpha blending
  81016. * @param mesh defines the mesh to check
  81017. * @returns a boolean specifying if alpha blending is needed for the mesh
  81018. */
  81019. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81020. /**
  81021. * Specifies if this material should be rendered in alpha test mode
  81022. * @returns a boolean specifying if an alpha test is needed.
  81023. */
  81024. needAlphaTesting(): boolean;
  81025. /**
  81026. * Gets the texture used for the alpha test
  81027. * @returns the texture to use for alpha testing
  81028. */
  81029. getAlphaTestTexture(): Nullable<BaseTexture>;
  81030. /**
  81031. * Marks the material to indicate that it needs to be re-calculated
  81032. */
  81033. markDirty(): void;
  81034. /** @hidden */
  81035. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81036. /**
  81037. * Binds the material to the mesh
  81038. * @param world defines the world transformation matrix
  81039. * @param mesh defines the mesh to bind the material to
  81040. */
  81041. bind(world: Matrix, mesh?: Mesh): void;
  81042. /**
  81043. * Binds the submesh to the material
  81044. * @param world defines the world transformation matrix
  81045. * @param mesh defines the mesh containing the submesh
  81046. * @param subMesh defines the submesh to bind the material to
  81047. */
  81048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81049. /**
  81050. * Binds the world matrix to the material
  81051. * @param world defines the world transformation matrix
  81052. */
  81053. bindOnlyWorldMatrix(world: Matrix): void;
  81054. /**
  81055. * Binds the scene's uniform buffer to the effect.
  81056. * @param effect defines the effect to bind to the scene uniform buffer
  81057. * @param sceneUbo defines the uniform buffer storing scene data
  81058. */
  81059. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81060. /**
  81061. * Binds the view matrix to the effect
  81062. * @param effect defines the effect to bind the view matrix to
  81063. */
  81064. bindView(effect: Effect): void;
  81065. /**
  81066. * Binds the view projection matrix to the effect
  81067. * @param effect defines the effect to bind the view projection matrix to
  81068. */
  81069. bindViewProjection(effect: Effect): void;
  81070. /**
  81071. * Specifies if material alpha testing should be turned on for the mesh
  81072. * @param mesh defines the mesh to check
  81073. */
  81074. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81075. /**
  81076. * Processes to execute after binding the material to a mesh
  81077. * @param mesh defines the rendered mesh
  81078. */
  81079. protected _afterBind(mesh?: Mesh): void;
  81080. /**
  81081. * Unbinds the material from the mesh
  81082. */
  81083. unbind(): void;
  81084. /**
  81085. * Gets the active textures from the material
  81086. * @returns an array of textures
  81087. */
  81088. getActiveTextures(): BaseTexture[];
  81089. /**
  81090. * Specifies if the material uses a texture
  81091. * @param texture defines the texture to check against the material
  81092. * @returns a boolean specifying if the material uses the texture
  81093. */
  81094. hasTexture(texture: BaseTexture): boolean;
  81095. /**
  81096. * Makes a duplicate of the material, and gives it a new name
  81097. * @param name defines the new name for the duplicated material
  81098. * @returns the cloned material
  81099. */
  81100. clone(name: string): Nullable<Material>;
  81101. /**
  81102. * Gets the meshes bound to the material
  81103. * @returns an array of meshes bound to the material
  81104. */
  81105. getBindedMeshes(): AbstractMesh[];
  81106. /**
  81107. * Force shader compilation
  81108. * @param mesh defines the mesh associated with this material
  81109. * @param onCompiled defines a function to execute once the material is compiled
  81110. * @param options defines the options to configure the compilation
  81111. */
  81112. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81113. clipPlane: boolean;
  81114. }>): void;
  81115. /**
  81116. * Force shader compilation
  81117. * @param mesh defines the mesh that will use this material
  81118. * @param options defines additional options for compiling the shaders
  81119. * @returns a promise that resolves when the compilation completes
  81120. */
  81121. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81122. clipPlane: boolean;
  81123. }>): Promise<void>;
  81124. private static readonly _ImageProcessingDirtyCallBack;
  81125. private static readonly _TextureDirtyCallBack;
  81126. private static readonly _FresnelDirtyCallBack;
  81127. private static readonly _MiscDirtyCallBack;
  81128. private static readonly _LightsDirtyCallBack;
  81129. private static readonly _AttributeDirtyCallBack;
  81130. private static _FresnelAndMiscDirtyCallBack;
  81131. private static _TextureAndMiscDirtyCallBack;
  81132. private static readonly _DirtyCallbackArray;
  81133. private static readonly _RunDirtyCallBacks;
  81134. /**
  81135. * Marks a define in the material to indicate that it needs to be re-computed
  81136. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81137. */
  81138. markAsDirty(flag: number): void;
  81139. /**
  81140. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81141. * @param func defines a function which checks material defines against the submeshes
  81142. */
  81143. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81144. /**
  81145. * Indicates that image processing needs to be re-calculated for all submeshes
  81146. */
  81147. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81148. /**
  81149. * Indicates that textures need to be re-calculated for all submeshes
  81150. */
  81151. protected _markAllSubMeshesAsTexturesDirty(): void;
  81152. /**
  81153. * Indicates that fresnel needs to be re-calculated for all submeshes
  81154. */
  81155. protected _markAllSubMeshesAsFresnelDirty(): void;
  81156. /**
  81157. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81158. */
  81159. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81160. /**
  81161. * Indicates that lights need to be re-calculated for all submeshes
  81162. */
  81163. protected _markAllSubMeshesAsLightsDirty(): void;
  81164. /**
  81165. * Indicates that attributes need to be re-calculated for all submeshes
  81166. */
  81167. protected _markAllSubMeshesAsAttributesDirty(): void;
  81168. /**
  81169. * Indicates that misc needs to be re-calculated for all submeshes
  81170. */
  81171. protected _markAllSubMeshesAsMiscDirty(): void;
  81172. /**
  81173. * Indicates that textures and misc need to be re-calculated for all submeshes
  81174. */
  81175. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81176. /**
  81177. * Disposes the material
  81178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81180. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81181. */
  81182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81183. /** @hidden */
  81184. private releaseVertexArrayObject;
  81185. /**
  81186. * Serializes this material
  81187. * @returns the serialized material object
  81188. */
  81189. serialize(): any;
  81190. /**
  81191. * Creates a material from parsed material data
  81192. * @param parsedMaterial defines parsed material data
  81193. * @param scene defines the hosting scene
  81194. * @param rootUrl defines the root URL to use to load textures
  81195. * @returns a new material
  81196. */
  81197. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  81198. }
  81199. }
  81200. declare module BABYLON {
  81201. /**
  81202. * Base class for submeshes
  81203. */
  81204. export class BaseSubMesh {
  81205. /** @hidden */
  81206. _materialDefines: Nullable<MaterialDefines>;
  81207. /** @hidden */
  81208. _materialEffect: Nullable<Effect>;
  81209. /**
  81210. * Gets associated effect
  81211. */
  81212. readonly effect: Nullable<Effect>;
  81213. /**
  81214. * Sets associated effect (effect used to render this submesh)
  81215. * @param effect defines the effect to associate with
  81216. * @param defines defines the set of defines used to compile this effect
  81217. */
  81218. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81219. }
  81220. /**
  81221. * Defines a subdivision inside a mesh
  81222. */
  81223. export class SubMesh extends BaseSubMesh implements ICullable {
  81224. /** the material index to use */
  81225. materialIndex: number;
  81226. /** vertex index start */
  81227. verticesStart: number;
  81228. /** vertices count */
  81229. verticesCount: number;
  81230. /** index start */
  81231. indexStart: number;
  81232. /** indices count */
  81233. indexCount: number;
  81234. /** @hidden */
  81235. _linesIndexCount: number;
  81236. private _mesh;
  81237. private _renderingMesh;
  81238. private _boundingInfo;
  81239. private _linesIndexBuffer;
  81240. /** @hidden */
  81241. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81242. /** @hidden */
  81243. _trianglePlanes: Plane[];
  81244. /** @hidden */
  81245. _lastColliderTransformMatrix: Matrix;
  81246. /** @hidden */
  81247. _renderId: number;
  81248. /** @hidden */
  81249. _alphaIndex: number;
  81250. /** @hidden */
  81251. _distanceToCamera: number;
  81252. /** @hidden */
  81253. _id: number;
  81254. private _currentMaterial;
  81255. /**
  81256. * Add a new submesh to a mesh
  81257. * @param materialIndex defines the material index to use
  81258. * @param verticesStart defines vertex index start
  81259. * @param verticesCount defines vertices count
  81260. * @param indexStart defines index start
  81261. * @param indexCount defines indices count
  81262. * @param mesh defines the parent mesh
  81263. * @param renderingMesh defines an optional rendering mesh
  81264. * @param createBoundingBox defines if bounding box should be created for this submesh
  81265. * @returns the new submesh
  81266. */
  81267. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81268. /**
  81269. * Creates a new submesh
  81270. * @param materialIndex defines the material index to use
  81271. * @param verticesStart defines vertex index start
  81272. * @param verticesCount defines vertices count
  81273. * @param indexStart defines index start
  81274. * @param indexCount defines indices count
  81275. * @param mesh defines the parent mesh
  81276. * @param renderingMesh defines an optional rendering mesh
  81277. * @param createBoundingBox defines if bounding box should be created for this submesh
  81278. */
  81279. constructor(
  81280. /** the material index to use */
  81281. materialIndex: number,
  81282. /** vertex index start */
  81283. verticesStart: number,
  81284. /** vertices count */
  81285. verticesCount: number,
  81286. /** index start */
  81287. indexStart: number,
  81288. /** indices count */
  81289. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81290. /**
  81291. * Returns true if this submesh covers the entire parent mesh
  81292. * @ignorenaming
  81293. */
  81294. readonly IsGlobal: boolean;
  81295. /**
  81296. * Returns the submesh BoudingInfo object
  81297. * @returns current bounding info (or mesh's one if the submesh is global)
  81298. */
  81299. getBoundingInfo(): BoundingInfo;
  81300. /**
  81301. * Sets the submesh BoundingInfo
  81302. * @param boundingInfo defines the new bounding info to use
  81303. * @returns the SubMesh
  81304. */
  81305. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81306. /**
  81307. * Returns the mesh of the current submesh
  81308. * @return the parent mesh
  81309. */
  81310. getMesh(): AbstractMesh;
  81311. /**
  81312. * Returns the rendering mesh of the submesh
  81313. * @returns the rendering mesh (could be different from parent mesh)
  81314. */
  81315. getRenderingMesh(): Mesh;
  81316. /**
  81317. * Returns the submesh material
  81318. * @returns null or the current material
  81319. */
  81320. getMaterial(): Nullable<Material>;
  81321. /**
  81322. * Sets a new updated BoundingInfo object to the submesh
  81323. * @returns the SubMesh
  81324. */
  81325. refreshBoundingInfo(): SubMesh;
  81326. /** @hidden */
  81327. _checkCollision(collider: Collider): boolean;
  81328. /**
  81329. * Updates the submesh BoundingInfo
  81330. * @param world defines the world matrix to use to update the bounding info
  81331. * @returns the submesh
  81332. */
  81333. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81334. /**
  81335. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81336. * @param frustumPlanes defines the frustum planes
  81337. * @returns true if the submesh is intersecting with the frustum
  81338. */
  81339. isInFrustum(frustumPlanes: Plane[]): boolean;
  81340. /**
  81341. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81342. * @param frustumPlanes defines the frustum planes
  81343. * @returns true if the submesh is inside the frustum
  81344. */
  81345. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81346. /**
  81347. * Renders the submesh
  81348. * @param enableAlphaMode defines if alpha needs to be used
  81349. * @returns the submesh
  81350. */
  81351. render(enableAlphaMode: boolean): SubMesh;
  81352. /**
  81353. * @hidden
  81354. */
  81355. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81356. /**
  81357. * Checks if the submesh intersects with a ray
  81358. * @param ray defines the ray to test
  81359. * @returns true is the passed ray intersects the submesh bounding box
  81360. */
  81361. canIntersects(ray: Ray): boolean;
  81362. /**
  81363. * Intersects current submesh with a ray
  81364. * @param ray defines the ray to test
  81365. * @param positions defines mesh's positions array
  81366. * @param indices defines mesh's indices array
  81367. * @param fastCheck defines if only bounding info should be used
  81368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81369. * @returns intersection info or null if no intersection
  81370. */
  81371. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81372. /** @hidden */
  81373. private _intersectLines;
  81374. /** @hidden */
  81375. private _intersectTriangles;
  81376. /** @hidden */
  81377. _rebuild(): void;
  81378. /**
  81379. * Creates a new submesh from the passed mesh
  81380. * @param newMesh defines the new hosting mesh
  81381. * @param newRenderingMesh defines an optional rendering mesh
  81382. * @returns the new submesh
  81383. */
  81384. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81385. /**
  81386. * Release associated resources
  81387. */
  81388. dispose(): void;
  81389. /**
  81390. * Gets the class name
  81391. * @returns the string "SubMesh".
  81392. */
  81393. getClassName(): string;
  81394. /**
  81395. * Creates a new submesh from indices data
  81396. * @param materialIndex the index of the main mesh material
  81397. * @param startIndex the index where to start the copy in the mesh indices array
  81398. * @param indexCount the number of indices to copy then from the startIndex
  81399. * @param mesh the main mesh to create the submesh from
  81400. * @param renderingMesh the optional rendering mesh
  81401. * @returns a new submesh
  81402. */
  81403. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81404. }
  81405. }
  81406. declare module BABYLON {
  81407. /**
  81408. * Class used to store geometry data (vertex buffers + index buffer)
  81409. */
  81410. export class Geometry implements IGetSetVerticesData {
  81411. /**
  81412. * Gets or sets the ID of the geometry
  81413. */
  81414. id: string;
  81415. /**
  81416. * Gets or sets the unique ID of the geometry
  81417. */
  81418. uniqueId: number;
  81419. /**
  81420. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81421. */
  81422. delayLoadState: number;
  81423. /**
  81424. * Gets the file containing the data to load when running in delay load state
  81425. */
  81426. delayLoadingFile: Nullable<string>;
  81427. /**
  81428. * Callback called when the geometry is updated
  81429. */
  81430. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81431. private _scene;
  81432. private _engine;
  81433. private _meshes;
  81434. private _totalVertices;
  81435. /** @hidden */
  81436. _indices: IndicesArray;
  81437. /** @hidden */
  81438. _vertexBuffers: {
  81439. [key: string]: VertexBuffer;
  81440. };
  81441. private _isDisposed;
  81442. private _extend;
  81443. private _boundingBias;
  81444. /** @hidden */
  81445. _delayInfo: Array<string>;
  81446. private _indexBuffer;
  81447. private _indexBufferIsUpdatable;
  81448. /** @hidden */
  81449. _boundingInfo: Nullable<BoundingInfo>;
  81450. /** @hidden */
  81451. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81452. /** @hidden */
  81453. _softwareSkinningFrameId: number;
  81454. private _vertexArrayObjects;
  81455. private _updatable;
  81456. /** @hidden */
  81457. _positions: Nullable<Vector3[]>;
  81458. /**
  81459. * 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
  81460. */
  81461. /**
  81462. * 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
  81463. */
  81464. boundingBias: Vector2;
  81465. /**
  81466. * Static function used to attach a new empty geometry to a mesh
  81467. * @param mesh defines the mesh to attach the geometry to
  81468. * @returns the new Geometry
  81469. */
  81470. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81471. /**
  81472. * Creates a new geometry
  81473. * @param id defines the unique ID
  81474. * @param scene defines the hosting scene
  81475. * @param vertexData defines the VertexData used to get geometry data
  81476. * @param updatable defines if geometry must be updatable (false by default)
  81477. * @param mesh defines the mesh that will be associated with the geometry
  81478. */
  81479. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81480. /**
  81481. * Gets the current extend of the geometry
  81482. */
  81483. readonly extend: {
  81484. minimum: Vector3;
  81485. maximum: Vector3;
  81486. };
  81487. /**
  81488. * Gets the hosting scene
  81489. * @returns the hosting Scene
  81490. */
  81491. getScene(): Scene;
  81492. /**
  81493. * Gets the hosting engine
  81494. * @returns the hosting Engine
  81495. */
  81496. getEngine(): Engine;
  81497. /**
  81498. * Defines if the geometry is ready to use
  81499. * @returns true if the geometry is ready to be used
  81500. */
  81501. isReady(): boolean;
  81502. /**
  81503. * Gets a value indicating that the geometry should not be serialized
  81504. */
  81505. readonly doNotSerialize: boolean;
  81506. /** @hidden */
  81507. _rebuild(): void;
  81508. /**
  81509. * Affects all geometry data in one call
  81510. * @param vertexData defines the geometry data
  81511. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81512. */
  81513. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81514. /**
  81515. * Set specific vertex data
  81516. * @param kind defines the data kind (Position, normal, etc...)
  81517. * @param data defines the vertex data to use
  81518. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81519. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81520. */
  81521. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81522. /**
  81523. * Removes a specific vertex data
  81524. * @param kind defines the data kind (Position, normal, etc...)
  81525. */
  81526. removeVerticesData(kind: string): void;
  81527. /**
  81528. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81529. * @param buffer defines the vertex buffer to use
  81530. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81531. */
  81532. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81533. /**
  81534. * Update a specific vertex buffer
  81535. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81536. * It will do nothing if the buffer is not updatable
  81537. * @param kind defines the data kind (Position, normal, etc...)
  81538. * @param data defines the data to use
  81539. * @param offset defines the offset in the target buffer where to store the data
  81540. * @param useBytes set to true if the offset is in bytes
  81541. */
  81542. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81543. /**
  81544. * Update a specific vertex buffer
  81545. * This function will create a new buffer if the current one is not updatable
  81546. * @param kind defines the data kind (Position, normal, etc...)
  81547. * @param data defines the data to use
  81548. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81549. */
  81550. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81551. private _updateBoundingInfo;
  81552. /** @hidden */
  81553. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81554. /**
  81555. * Gets total number of vertices
  81556. * @returns the total number of vertices
  81557. */
  81558. getTotalVertices(): number;
  81559. /**
  81560. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81561. * @param kind defines the data kind (Position, normal, etc...)
  81562. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81563. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81564. * @returns a float array containing vertex data
  81565. */
  81566. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81567. /**
  81568. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81569. * @param kind defines the data kind (Position, normal, etc...)
  81570. * @returns true if the vertex buffer with the specified kind is updatable
  81571. */
  81572. isVertexBufferUpdatable(kind: string): boolean;
  81573. /**
  81574. * Gets a specific vertex buffer
  81575. * @param kind defines the data kind (Position, normal, etc...)
  81576. * @returns a VertexBuffer
  81577. */
  81578. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81579. /**
  81580. * Returns all vertex buffers
  81581. * @return an object holding all vertex buffers indexed by kind
  81582. */
  81583. getVertexBuffers(): Nullable<{
  81584. [key: string]: VertexBuffer;
  81585. }>;
  81586. /**
  81587. * Gets a boolean indicating if specific vertex buffer is present
  81588. * @param kind defines the data kind (Position, normal, etc...)
  81589. * @returns true if data is present
  81590. */
  81591. isVerticesDataPresent(kind: string): boolean;
  81592. /**
  81593. * Gets a list of all attached data kinds (Position, normal, etc...)
  81594. * @returns a list of string containing all kinds
  81595. */
  81596. getVerticesDataKinds(): string[];
  81597. /**
  81598. * Update index buffer
  81599. * @param indices defines the indices to store in the index buffer
  81600. * @param offset defines the offset in the target buffer where to store the data
  81601. * @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)
  81602. */
  81603. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81604. /**
  81605. * Creates a new index buffer
  81606. * @param indices defines the indices to store in the index buffer
  81607. * @param totalVertices defines the total number of vertices (could be null)
  81608. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81609. */
  81610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81611. /**
  81612. * Return the total number of indices
  81613. * @returns the total number of indices
  81614. */
  81615. getTotalIndices(): number;
  81616. /**
  81617. * Gets the index buffer array
  81618. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81619. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81620. * @returns the index buffer array
  81621. */
  81622. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81623. /**
  81624. * Gets the index buffer
  81625. * @return the index buffer
  81626. */
  81627. getIndexBuffer(): Nullable<WebGLBuffer>;
  81628. /** @hidden */
  81629. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81630. /**
  81631. * Release the associated resources for a specific mesh
  81632. * @param mesh defines the source mesh
  81633. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81634. */
  81635. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81636. /**
  81637. * Apply current geometry to a given mesh
  81638. * @param mesh defines the mesh to apply geometry to
  81639. */
  81640. applyToMesh(mesh: Mesh): void;
  81641. private _updateExtend;
  81642. private _applyToMesh;
  81643. private notifyUpdate;
  81644. /**
  81645. * Load the geometry if it was flagged as delay loaded
  81646. * @param scene defines the hosting scene
  81647. * @param onLoaded defines a callback called when the geometry is loaded
  81648. */
  81649. load(scene: Scene, onLoaded?: () => void): void;
  81650. private _queueLoad;
  81651. /**
  81652. * Invert the geometry to move from a right handed system to a left handed one.
  81653. */
  81654. toLeftHanded(): void;
  81655. /** @hidden */
  81656. _resetPointsArrayCache(): void;
  81657. /** @hidden */
  81658. _generatePointsArray(): boolean;
  81659. /**
  81660. * Gets a value indicating if the geometry is disposed
  81661. * @returns true if the geometry was disposed
  81662. */
  81663. isDisposed(): boolean;
  81664. private _disposeVertexArrayObjects;
  81665. /**
  81666. * Free all associated resources
  81667. */
  81668. dispose(): void;
  81669. /**
  81670. * Clone the current geometry into a new geometry
  81671. * @param id defines the unique ID of the new geometry
  81672. * @returns a new geometry object
  81673. */
  81674. copy(id: string): Geometry;
  81675. /**
  81676. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81677. * @return a JSON representation of the current geometry data (without the vertices data)
  81678. */
  81679. serialize(): any;
  81680. private toNumberArray;
  81681. /**
  81682. * Serialize all vertices data into a JSON oject
  81683. * @returns a JSON representation of the current geometry data
  81684. */
  81685. serializeVerticeData(): any;
  81686. /**
  81687. * Extracts a clone of a mesh geometry
  81688. * @param mesh defines the source mesh
  81689. * @param id defines the unique ID of the new geometry object
  81690. * @returns the new geometry object
  81691. */
  81692. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81693. /**
  81694. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81695. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81696. * Be aware Math.random() could cause collisions, but:
  81697. * "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"
  81698. * @returns a string containing a new GUID
  81699. */
  81700. static RandomId(): string;
  81701. /** @hidden */
  81702. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81703. private static _CleanMatricesWeights;
  81704. /**
  81705. * Create a new geometry from persisted data (Using .babylon file format)
  81706. * @param parsedVertexData defines the persisted data
  81707. * @param scene defines the hosting scene
  81708. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81709. * @returns the new geometry object
  81710. */
  81711. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81712. }
  81713. }
  81714. declare module BABYLON {
  81715. /**
  81716. * Define an interface for all classes that will get and set the data on vertices
  81717. */
  81718. export interface IGetSetVerticesData {
  81719. /**
  81720. * Gets a boolean indicating if specific vertex data is present
  81721. * @param kind defines the vertex data kind to use
  81722. * @returns true is data kind is present
  81723. */
  81724. isVerticesDataPresent(kind: string): boolean;
  81725. /**
  81726. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81727. * @param kind defines the data kind (Position, normal, etc...)
  81728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81730. * @returns a float array containing vertex data
  81731. */
  81732. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81733. /**
  81734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81735. * @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.
  81736. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81737. * @returns the indices array or an empty array if the mesh has no geometry
  81738. */
  81739. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81740. /**
  81741. * Set specific vertex data
  81742. * @param kind defines the data kind (Position, normal, etc...)
  81743. * @param data defines the vertex data to use
  81744. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81745. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81746. */
  81747. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81748. /**
  81749. * Update a specific associated vertex buffer
  81750. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81751. * - VertexBuffer.PositionKind
  81752. * - VertexBuffer.UVKind
  81753. * - VertexBuffer.UV2Kind
  81754. * - VertexBuffer.UV3Kind
  81755. * - VertexBuffer.UV4Kind
  81756. * - VertexBuffer.UV5Kind
  81757. * - VertexBuffer.UV6Kind
  81758. * - VertexBuffer.ColorKind
  81759. * - VertexBuffer.MatricesIndicesKind
  81760. * - VertexBuffer.MatricesIndicesExtraKind
  81761. * - VertexBuffer.MatricesWeightsKind
  81762. * - VertexBuffer.MatricesWeightsExtraKind
  81763. * @param data defines the data source
  81764. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81765. * @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)
  81766. */
  81767. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81768. /**
  81769. * Creates a new index buffer
  81770. * @param indices defines the indices to store in the index buffer
  81771. * @param totalVertices defines the total number of vertices (could be null)
  81772. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81773. */
  81774. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81775. }
  81776. /**
  81777. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81778. */
  81779. export class VertexData {
  81780. /**
  81781. * Mesh side orientation : usually the external or front surface
  81782. */
  81783. static readonly FRONTSIDE: number;
  81784. /**
  81785. * Mesh side orientation : usually the internal or back surface
  81786. */
  81787. static readonly BACKSIDE: number;
  81788. /**
  81789. * Mesh side orientation : both internal and external or front and back surfaces
  81790. */
  81791. static readonly DOUBLESIDE: number;
  81792. /**
  81793. * Mesh side orientation : by default, `FRONTSIDE`
  81794. */
  81795. static readonly DEFAULTSIDE: number;
  81796. /**
  81797. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81798. */
  81799. positions: Nullable<FloatArray>;
  81800. /**
  81801. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81802. */
  81803. normals: Nullable<FloatArray>;
  81804. /**
  81805. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81806. */
  81807. tangents: Nullable<FloatArray>;
  81808. /**
  81809. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81810. */
  81811. uvs: Nullable<FloatArray>;
  81812. /**
  81813. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81814. */
  81815. uvs2: Nullable<FloatArray>;
  81816. /**
  81817. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81818. */
  81819. uvs3: Nullable<FloatArray>;
  81820. /**
  81821. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81822. */
  81823. uvs4: Nullable<FloatArray>;
  81824. /**
  81825. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81826. */
  81827. uvs5: Nullable<FloatArray>;
  81828. /**
  81829. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81830. */
  81831. uvs6: Nullable<FloatArray>;
  81832. /**
  81833. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81834. */
  81835. colors: Nullable<FloatArray>;
  81836. /**
  81837. * 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).
  81838. */
  81839. matricesIndices: Nullable<FloatArray>;
  81840. /**
  81841. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81842. */
  81843. matricesWeights: Nullable<FloatArray>;
  81844. /**
  81845. * An array extending the number of possible indices
  81846. */
  81847. matricesIndicesExtra: Nullable<FloatArray>;
  81848. /**
  81849. * An array extending the number of possible weights when the number of indices is extended
  81850. */
  81851. matricesWeightsExtra: Nullable<FloatArray>;
  81852. /**
  81853. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81854. */
  81855. indices: Nullable<IndicesArray>;
  81856. /**
  81857. * Uses the passed data array to set the set the values for the specified kind of data
  81858. * @param data a linear array of floating numbers
  81859. * @param kind the type of data that is being set, eg positions, colors etc
  81860. */
  81861. set(data: FloatArray, kind: string): void;
  81862. /**
  81863. * Associates the vertexData to the passed Mesh.
  81864. * Sets it as updatable or not (default `false`)
  81865. * @param mesh the mesh the vertexData is applied to
  81866. * @param updatable when used and having the value true allows new data to update the vertexData
  81867. * @returns the VertexData
  81868. */
  81869. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81870. /**
  81871. * Associates the vertexData to the passed Geometry.
  81872. * Sets it as updatable or not (default `false`)
  81873. * @param geometry the geometry the vertexData is applied to
  81874. * @param updatable when used and having the value true allows new data to update the vertexData
  81875. * @returns VertexData
  81876. */
  81877. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81878. /**
  81879. * Updates the associated mesh
  81880. * @param mesh the mesh to be updated
  81881. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81882. * @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
  81883. * @returns VertexData
  81884. */
  81885. updateMesh(mesh: Mesh): VertexData;
  81886. /**
  81887. * Updates the associated geometry
  81888. * @param geometry the geometry to be updated
  81889. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81890. * @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
  81891. * @returns VertexData.
  81892. */
  81893. updateGeometry(geometry: Geometry): VertexData;
  81894. private _applyTo;
  81895. private _update;
  81896. /**
  81897. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81898. * @param matrix the transforming matrix
  81899. * @returns the VertexData
  81900. */
  81901. transform(matrix: Matrix): VertexData;
  81902. /**
  81903. * Merges the passed VertexData into the current one
  81904. * @param other the VertexData to be merged into the current one
  81905. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81906. * @returns the modified VertexData
  81907. */
  81908. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81909. private _mergeElement;
  81910. private _validate;
  81911. /**
  81912. * Serializes the VertexData
  81913. * @returns a serialized object
  81914. */
  81915. serialize(): any;
  81916. /**
  81917. * Extracts the vertexData from a mesh
  81918. * @param mesh the mesh from which to extract the VertexData
  81919. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81920. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81921. * @returns the object VertexData associated to the passed mesh
  81922. */
  81923. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81924. /**
  81925. * Extracts the vertexData from the geometry
  81926. * @param geometry the geometry from which to extract the VertexData
  81927. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81928. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81929. * @returns the object VertexData associated to the passed mesh
  81930. */
  81931. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81932. private static _ExtractFrom;
  81933. /**
  81934. * Creates the VertexData for a Ribbon
  81935. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81936. * * pathArray array of paths, each of which an array of successive Vector3
  81937. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81938. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81939. * * 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
  81940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81941. * * 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)
  81942. * * 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)
  81943. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81944. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81945. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81946. * @returns the VertexData of the ribbon
  81947. */
  81948. static CreateRibbon(options: {
  81949. pathArray: Vector3[][];
  81950. closeArray?: boolean;
  81951. closePath?: boolean;
  81952. offset?: number;
  81953. sideOrientation?: number;
  81954. frontUVs?: Vector4;
  81955. backUVs?: Vector4;
  81956. invertUV?: boolean;
  81957. uvs?: Vector2[];
  81958. colors?: Color4[];
  81959. }): VertexData;
  81960. /**
  81961. * Creates the VertexData for a box
  81962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81963. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81964. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81965. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81966. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81967. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81968. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81970. * * 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)
  81971. * * 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)
  81972. * @returns the VertexData of the box
  81973. */
  81974. static CreateBox(options: {
  81975. size?: number;
  81976. width?: number;
  81977. height?: number;
  81978. depth?: number;
  81979. faceUV?: Vector4[];
  81980. faceColors?: Color4[];
  81981. sideOrientation?: number;
  81982. frontUVs?: Vector4;
  81983. backUVs?: Vector4;
  81984. }): VertexData;
  81985. /**
  81986. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81987. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81988. * * segments sets the number of horizontal strips optional, default 32
  81989. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81990. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81991. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81992. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81993. * * 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
  81994. * * 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
  81995. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81996. * * 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)
  81997. * * 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)
  81998. * @returns the VertexData of the ellipsoid
  81999. */
  82000. static CreateSphere(options: {
  82001. segments?: number;
  82002. diameter?: number;
  82003. diameterX?: number;
  82004. diameterY?: number;
  82005. diameterZ?: number;
  82006. arc?: number;
  82007. slice?: number;
  82008. sideOrientation?: number;
  82009. frontUVs?: Vector4;
  82010. backUVs?: Vector4;
  82011. }): VertexData;
  82012. /**
  82013. * Creates the VertexData for a cylinder, cone or prism
  82014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82015. * * height sets the height (y direction) of the cylinder, optional, default 2
  82016. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82017. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82018. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82019. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82020. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82021. * * 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
  82022. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82023. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82024. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82025. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82027. * * 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)
  82028. * * 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)
  82029. * @returns the VertexData of the cylinder, cone or prism
  82030. */
  82031. static CreateCylinder(options: {
  82032. height?: number;
  82033. diameterTop?: number;
  82034. diameterBottom?: number;
  82035. diameter?: number;
  82036. tessellation?: number;
  82037. subdivisions?: number;
  82038. arc?: number;
  82039. faceColors?: Color4[];
  82040. faceUV?: Vector4[];
  82041. hasRings?: boolean;
  82042. enclose?: boolean;
  82043. sideOrientation?: number;
  82044. frontUVs?: Vector4;
  82045. backUVs?: Vector4;
  82046. }): VertexData;
  82047. /**
  82048. * Creates the VertexData for a torus
  82049. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82050. * * diameter the diameter of the torus, optional default 1
  82051. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82052. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82054. * * 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)
  82055. * * 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)
  82056. * @returns the VertexData of the torus
  82057. */
  82058. static CreateTorus(options: {
  82059. diameter?: number;
  82060. thickness?: number;
  82061. tessellation?: number;
  82062. sideOrientation?: number;
  82063. frontUVs?: Vector4;
  82064. backUVs?: Vector4;
  82065. }): VertexData;
  82066. /**
  82067. * Creates the VertexData of the LineSystem
  82068. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82069. * - lines an array of lines, each line being an array of successive Vector3
  82070. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82071. * @returns the VertexData of the LineSystem
  82072. */
  82073. static CreateLineSystem(options: {
  82074. lines: Vector3[][];
  82075. colors?: Nullable<Color4[][]>;
  82076. }): VertexData;
  82077. /**
  82078. * Create the VertexData for a DashedLines
  82079. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82080. * - points an array successive Vector3
  82081. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82082. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82083. * - dashNb the intended total number of dashes, optional, default 200
  82084. * @returns the VertexData for the DashedLines
  82085. */
  82086. static CreateDashedLines(options: {
  82087. points: Vector3[];
  82088. dashSize?: number;
  82089. gapSize?: number;
  82090. dashNb?: number;
  82091. }): VertexData;
  82092. /**
  82093. * Creates the VertexData for a Ground
  82094. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82095. * - width the width (x direction) of the ground, optional, default 1
  82096. * - height the height (z direction) of the ground, optional, default 1
  82097. * - subdivisions the number of subdivisions per side, optional, default 1
  82098. * @returns the VertexData of the Ground
  82099. */
  82100. static CreateGround(options: {
  82101. width?: number;
  82102. height?: number;
  82103. subdivisions?: number;
  82104. subdivisionsX?: number;
  82105. subdivisionsY?: number;
  82106. }): VertexData;
  82107. /**
  82108. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82109. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82110. * * xmin the ground minimum X coordinate, optional, default -1
  82111. * * zmin the ground minimum Z coordinate, optional, default -1
  82112. * * xmax the ground maximum X coordinate, optional, default 1
  82113. * * zmax the ground maximum Z coordinate, optional, default 1
  82114. * * 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}
  82115. * * 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}
  82116. * @returns the VertexData of the TiledGround
  82117. */
  82118. static CreateTiledGround(options: {
  82119. xmin: number;
  82120. zmin: number;
  82121. xmax: number;
  82122. zmax: number;
  82123. subdivisions?: {
  82124. w: number;
  82125. h: number;
  82126. };
  82127. precision?: {
  82128. w: number;
  82129. h: number;
  82130. };
  82131. }): VertexData;
  82132. /**
  82133. * Creates the VertexData of the Ground designed from a heightmap
  82134. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82135. * * width the width (x direction) of the ground
  82136. * * height the height (z direction) of the ground
  82137. * * subdivisions the number of subdivisions per side
  82138. * * minHeight the minimum altitude on the ground, optional, default 0
  82139. * * maxHeight the maximum altitude on the ground, optional default 1
  82140. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82141. * * buffer the array holding the image color data
  82142. * * bufferWidth the width of image
  82143. * * bufferHeight the height of image
  82144. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82145. * @returns the VertexData of the Ground designed from a heightmap
  82146. */
  82147. static CreateGroundFromHeightMap(options: {
  82148. width: number;
  82149. height: number;
  82150. subdivisions: number;
  82151. minHeight: number;
  82152. maxHeight: number;
  82153. colorFilter: Color3;
  82154. buffer: Uint8Array;
  82155. bufferWidth: number;
  82156. bufferHeight: number;
  82157. alphaFilter: number;
  82158. }): VertexData;
  82159. /**
  82160. * Creates the VertexData for a Plane
  82161. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82162. * * size sets the width and height of the plane to the value of size, optional default 1
  82163. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82164. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82166. * * 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)
  82167. * * 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)
  82168. * @returns the VertexData of the box
  82169. */
  82170. static CreatePlane(options: {
  82171. size?: number;
  82172. width?: number;
  82173. height?: number;
  82174. sideOrientation?: number;
  82175. frontUVs?: Vector4;
  82176. backUVs?: Vector4;
  82177. }): VertexData;
  82178. /**
  82179. * Creates the VertexData of the Disc or regular Polygon
  82180. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82181. * * radius the radius of the disc, optional default 0.5
  82182. * * tessellation the number of polygon sides, optional, default 64
  82183. * * 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
  82184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82185. * * 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)
  82186. * * 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)
  82187. * @returns the VertexData of the box
  82188. */
  82189. static CreateDisc(options: {
  82190. radius?: number;
  82191. tessellation?: number;
  82192. arc?: number;
  82193. sideOrientation?: number;
  82194. frontUVs?: Vector4;
  82195. backUVs?: Vector4;
  82196. }): VertexData;
  82197. /**
  82198. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82199. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82200. * @param polygon a mesh built from polygonTriangulation.build()
  82201. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82202. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82203. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82204. * @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)
  82205. * @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)
  82206. * @returns the VertexData of the Polygon
  82207. */
  82208. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82209. /**
  82210. * Creates the VertexData of the IcoSphere
  82211. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82212. * * radius the radius of the IcoSphere, optional default 1
  82213. * * radiusX allows stretching in the x direction, optional, default radius
  82214. * * radiusY allows stretching in the y direction, optional, default radius
  82215. * * radiusZ allows stretching in the z direction, optional, default radius
  82216. * * flat when true creates a flat shaded mesh, optional, default true
  82217. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  82222. */
  82223. static CreateIcoSphere(options: {
  82224. radius?: number;
  82225. radiusX?: number;
  82226. radiusY?: number;
  82227. radiusZ?: number;
  82228. flat?: boolean;
  82229. subdivisions?: number;
  82230. sideOrientation?: number;
  82231. frontUVs?: Vector4;
  82232. backUVs?: Vector4;
  82233. }): VertexData;
  82234. /**
  82235. * Creates the VertexData for a Polyhedron
  82236. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82237. * * type provided types are:
  82238. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82239. * * 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)
  82240. * * size the size of the IcoSphere, optional default 1
  82241. * * sizeX allows stretching in the x direction, optional, default size
  82242. * * sizeY allows stretching in the y direction, optional, default size
  82243. * * sizeZ allows stretching in the z direction, optional, default size
  82244. * * 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
  82245. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82246. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82247. * * flat when true creates a flat shaded mesh, optional, default true
  82248. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 Polyhedron
  82253. */
  82254. static CreatePolyhedron(options: {
  82255. type?: number;
  82256. size?: number;
  82257. sizeX?: number;
  82258. sizeY?: number;
  82259. sizeZ?: number;
  82260. custom?: any;
  82261. faceUV?: Vector4[];
  82262. faceColors?: Color4[];
  82263. flat?: boolean;
  82264. sideOrientation?: number;
  82265. frontUVs?: Vector4;
  82266. backUVs?: Vector4;
  82267. }): VertexData;
  82268. /**
  82269. * Creates the VertexData for a TorusKnot
  82270. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82271. * * radius the radius of the torus knot, optional, default 2
  82272. * * tube the thickness of the tube, optional, default 0.5
  82273. * * radialSegments the number of sides on each tube segments, optional, default 32
  82274. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82275. * * p the number of windings around the z axis, optional, default 2
  82276. * * q the number of windings around the x axis, optional, default 3
  82277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82278. * * 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)
  82279. * * 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)
  82280. * @returns the VertexData of the Torus Knot
  82281. */
  82282. static CreateTorusKnot(options: {
  82283. radius?: number;
  82284. tube?: number;
  82285. radialSegments?: number;
  82286. tubularSegments?: number;
  82287. p?: number;
  82288. q?: number;
  82289. sideOrientation?: number;
  82290. frontUVs?: Vector4;
  82291. backUVs?: Vector4;
  82292. }): VertexData;
  82293. /**
  82294. * Compute normals for given positions and indices
  82295. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82296. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82297. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82298. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82299. * * facetNormals : optional array of facet normals (vector3)
  82300. * * facetPositions : optional array of facet positions (vector3)
  82301. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82302. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82303. * * bInfo : optional bounding info, required for facetPartitioning computation
  82304. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82305. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82306. * * useRightHandedSystem: optional boolean to for right handed system computation
  82307. * * depthSort : optional boolean to enable the facet depth sort computation
  82308. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82309. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82310. */
  82311. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82312. facetNormals?: any;
  82313. facetPositions?: any;
  82314. facetPartitioning?: any;
  82315. ratio?: number;
  82316. bInfo?: any;
  82317. bbSize?: Vector3;
  82318. subDiv?: any;
  82319. useRightHandedSystem?: boolean;
  82320. depthSort?: boolean;
  82321. distanceTo?: Vector3;
  82322. depthSortedFacets?: any;
  82323. }): void;
  82324. /** @hidden */
  82325. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82326. /**
  82327. * Applies VertexData created from the imported parameters to the geometry
  82328. * @param parsedVertexData the parsed data from an imported file
  82329. * @param geometry the geometry to apply the VertexData to
  82330. */
  82331. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82332. }
  82333. }
  82334. declare module BABYLON {
  82335. /**
  82336. * Class containing static functions to help procedurally build meshes
  82337. */
  82338. export class DiscBuilder {
  82339. /**
  82340. * Creates a plane polygonal mesh. By default, this is a disc
  82341. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82342. * * 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
  82343. * * 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
  82344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82347. * @param name defines the name of the mesh
  82348. * @param options defines the options used to create the mesh
  82349. * @param scene defines the hosting scene
  82350. * @returns the plane polygonal mesh
  82351. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82352. */
  82353. static CreateDisc(name: string, options: {
  82354. radius?: number;
  82355. tessellation?: number;
  82356. arc?: number;
  82357. updatable?: boolean;
  82358. sideOrientation?: number;
  82359. frontUVs?: Vector4;
  82360. backUVs?: Vector4;
  82361. }, scene?: Nullable<Scene>): Mesh;
  82362. }
  82363. }
  82364. declare module BABYLON {
  82365. /**
  82366. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82367. *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.
  82368. * The SPS is also a particle system. It provides some methods to manage the particles.
  82369. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82370. *
  82371. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82372. */
  82373. export class SolidParticleSystem implements IDisposable {
  82374. /**
  82375. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82376. * Example : var p = SPS.particles[i];
  82377. */
  82378. particles: SolidParticle[];
  82379. /**
  82380. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82381. */
  82382. nbParticles: number;
  82383. /**
  82384. * If the particles must ever face the camera (default false). Useful for planar particles.
  82385. */
  82386. billboard: boolean;
  82387. /**
  82388. * Recompute normals when adding a shape
  82389. */
  82390. recomputeNormals: boolean;
  82391. /**
  82392. * This a counter ofr your own usage. It's not set by any SPS functions.
  82393. */
  82394. counter: number;
  82395. /**
  82396. * The SPS name. This name is also given to the underlying mesh.
  82397. */
  82398. name: string;
  82399. /**
  82400. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82401. */
  82402. mesh: Mesh;
  82403. /**
  82404. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82405. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82406. */
  82407. vars: any;
  82408. /**
  82409. * This array is populated when the SPS is set as 'pickable'.
  82410. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82411. * Each element of this array is an object `{idx: int, faceId: int}`.
  82412. * `idx` is the picked particle index in the `SPS.particles` array
  82413. * `faceId` is the picked face index counted within this particle.
  82414. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82415. */
  82416. pickedParticles: {
  82417. idx: number;
  82418. faceId: number;
  82419. }[];
  82420. /**
  82421. * This array is populated when `enableDepthSort` is set to true.
  82422. * Each element of this array is an instance of the class DepthSortedParticle.
  82423. */
  82424. depthSortedParticles: DepthSortedParticle[];
  82425. /**
  82426. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82427. * @hidden
  82428. */
  82429. _bSphereOnly: boolean;
  82430. /**
  82431. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82432. * @hidden
  82433. */
  82434. _bSphereRadiusFactor: number;
  82435. private _scene;
  82436. private _positions;
  82437. private _indices;
  82438. private _normals;
  82439. private _colors;
  82440. private _uvs;
  82441. private _indices32;
  82442. private _positions32;
  82443. private _normals32;
  82444. private _fixedNormal32;
  82445. private _colors32;
  82446. private _uvs32;
  82447. private _index;
  82448. private _updatable;
  82449. private _pickable;
  82450. private _isVisibilityBoxLocked;
  82451. private _alwaysVisible;
  82452. private _depthSort;
  82453. private _shapeCounter;
  82454. private _copy;
  82455. private _color;
  82456. private _computeParticleColor;
  82457. private _computeParticleTexture;
  82458. private _computeParticleRotation;
  82459. private _computeParticleVertex;
  82460. private _computeBoundingBox;
  82461. private _depthSortParticles;
  82462. private _camera;
  82463. private _mustUnrotateFixedNormals;
  82464. private _particlesIntersect;
  82465. private _needs32Bits;
  82466. /**
  82467. * Creates a SPS (Solid Particle System) object.
  82468. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82469. * @param scene (Scene) is the scene in which the SPS is added.
  82470. * @param options defines the options of the sps e.g.
  82471. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82472. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82473. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82474. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82475. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82476. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82477. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82478. */
  82479. constructor(name: string, scene: Scene, options?: {
  82480. updatable?: boolean;
  82481. isPickable?: boolean;
  82482. enableDepthSort?: boolean;
  82483. particleIntersection?: boolean;
  82484. boundingSphereOnly?: boolean;
  82485. bSphereRadiusFactor?: number;
  82486. });
  82487. /**
  82488. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82489. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82490. * @returns the created mesh
  82491. */
  82492. buildMesh(): Mesh;
  82493. /**
  82494. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82495. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82496. * Thus the particles generated from `digest()` have their property `position` set yet.
  82497. * @param mesh ( Mesh ) is the mesh to be digested
  82498. * @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
  82499. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82500. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82501. * @returns the current SPS
  82502. */
  82503. digest(mesh: Mesh, options?: {
  82504. facetNb?: number;
  82505. number?: number;
  82506. delta?: number;
  82507. }): SolidParticleSystem;
  82508. private _unrotateFixedNormals;
  82509. private _resetCopy;
  82510. private _meshBuilder;
  82511. private _posToShape;
  82512. private _uvsToShapeUV;
  82513. private _addParticle;
  82514. /**
  82515. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82516. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82517. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82518. * @param nb (positive integer) the number of particles to be created from this model
  82519. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82520. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82521. * @returns the number of shapes in the system
  82522. */
  82523. addShape(mesh: Mesh, nb: number, options?: {
  82524. positionFunction?: any;
  82525. vertexFunction?: any;
  82526. }): number;
  82527. private _rebuildParticle;
  82528. /**
  82529. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82530. * @returns the SPS.
  82531. */
  82532. rebuildMesh(): SolidParticleSystem;
  82533. /**
  82534. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82535. * This method calls `updateParticle()` for each particle of the SPS.
  82536. * For an animated SPS, it is usually called within the render loop.
  82537. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82538. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82539. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82540. * @returns the SPS.
  82541. */
  82542. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82543. /**
  82544. * Disposes the SPS.
  82545. */
  82546. dispose(): void;
  82547. /**
  82548. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82550. * @returns the SPS.
  82551. */
  82552. refreshVisibleSize(): SolidParticleSystem;
  82553. /**
  82554. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82555. * @param size the size (float) of the visibility box
  82556. * note : this doesn't lock the SPS mesh bounding box.
  82557. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82558. */
  82559. setVisibilityBox(size: number): void;
  82560. /**
  82561. * Gets whether the SPS as always visible or not
  82562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82563. */
  82564. /**
  82565. * Sets the SPS as always visible or not
  82566. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82567. */
  82568. isAlwaysVisible: boolean;
  82569. /**
  82570. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82571. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82572. */
  82573. /**
  82574. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82576. */
  82577. isVisibilityBoxLocked: boolean;
  82578. /**
  82579. * Tells to `setParticles()` to compute the particle rotations or not.
  82580. * Default value : true. The SPS is faster when it's set to false.
  82581. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82582. */
  82583. /**
  82584. * Gets if `setParticles()` computes the particle rotations or not.
  82585. * Default value : true. The SPS is faster when it's set to false.
  82586. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82587. */
  82588. computeParticleRotation: boolean;
  82589. /**
  82590. * Tells to `setParticles()` to compute the particle colors or not.
  82591. * Default value : true. The SPS is faster when it's set to false.
  82592. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82593. */
  82594. /**
  82595. * Gets if `setParticles()` computes the particle colors or not.
  82596. * Default value : true. The SPS is faster when it's set to false.
  82597. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82598. */
  82599. computeParticleColor: boolean;
  82600. /**
  82601. * Gets if `setParticles()` computes the particle textures or not.
  82602. * Default value : true. The SPS is faster when it's set to false.
  82603. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82604. */
  82605. computeParticleTexture: boolean;
  82606. /**
  82607. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82608. * Default value : false. The SPS is faster when it's set to false.
  82609. * Note : the particle custom vertex positions aren't stored values.
  82610. */
  82611. /**
  82612. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82613. * Default value : false. The SPS is faster when it's set to false.
  82614. * Note : the particle custom vertex positions aren't stored values.
  82615. */
  82616. computeParticleVertex: boolean;
  82617. /**
  82618. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82619. */
  82620. /**
  82621. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82622. */
  82623. computeBoundingBox: boolean;
  82624. /**
  82625. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82626. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82627. * Default : `true`
  82628. */
  82629. /**
  82630. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82631. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82632. * Default : `true`
  82633. */
  82634. depthSortParticles: boolean;
  82635. /**
  82636. * This function does nothing. It may be overwritten to set all the particle first values.
  82637. * The SPS doesn't call this function, you may have to call it by your own.
  82638. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82639. */
  82640. initParticles(): void;
  82641. /**
  82642. * This function does nothing. It may be overwritten to recycle a particle.
  82643. * The SPS doesn't call this function, you may have to call it by your own.
  82644. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82645. * @param particle The particle to recycle
  82646. * @returns the recycled particle
  82647. */
  82648. recycleParticle(particle: SolidParticle): SolidParticle;
  82649. /**
  82650. * Updates a particle : this function should be overwritten by the user.
  82651. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82652. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82653. * @example : just set a particle position or velocity and recycle conditions
  82654. * @param particle The particle to update
  82655. * @returns the updated particle
  82656. */
  82657. updateParticle(particle: SolidParticle): SolidParticle;
  82658. /**
  82659. * Updates a vertex of a particle : it can be overwritten by the user.
  82660. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82661. * @param particle the current particle
  82662. * @param vertex the current index of the current particle
  82663. * @param pt the index of the current vertex in the particle shape
  82664. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82665. * @example : just set a vertex particle position
  82666. * @returns the updated vertex
  82667. */
  82668. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82669. /**
  82670. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82671. * This does nothing and may be overwritten by the user.
  82672. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82674. * @param update the boolean update value actually passed to setParticles()
  82675. */
  82676. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82677. /**
  82678. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82679. * This will be passed three parameters.
  82680. * This does nothing and may be overwritten by the user.
  82681. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82682. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82683. * @param update the boolean update value actually passed to setParticles()
  82684. */
  82685. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82686. }
  82687. }
  82688. declare module BABYLON {
  82689. /**
  82690. * Represents one particle of a solid particle system.
  82691. */
  82692. export class SolidParticle {
  82693. /**
  82694. * particle global index
  82695. */
  82696. idx: number;
  82697. /**
  82698. * The color of the particle
  82699. */
  82700. color: Nullable<Color4>;
  82701. /**
  82702. * The world space position of the particle.
  82703. */
  82704. position: Vector3;
  82705. /**
  82706. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82707. */
  82708. rotation: Vector3;
  82709. /**
  82710. * The world space rotation quaternion of the particle.
  82711. */
  82712. rotationQuaternion: Nullable<Quaternion>;
  82713. /**
  82714. * The scaling of the particle.
  82715. */
  82716. scaling: Vector3;
  82717. /**
  82718. * The uvs of the particle.
  82719. */
  82720. uvs: Vector4;
  82721. /**
  82722. * The current speed of the particle.
  82723. */
  82724. velocity: Vector3;
  82725. /**
  82726. * The pivot point in the particle local space.
  82727. */
  82728. pivot: Vector3;
  82729. /**
  82730. * Must the particle be translated from its pivot point in its local space ?
  82731. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82732. * Default : false
  82733. */
  82734. translateFromPivot: boolean;
  82735. /**
  82736. * Is the particle active or not ?
  82737. */
  82738. alive: boolean;
  82739. /**
  82740. * Is the particle visible or not ?
  82741. */
  82742. isVisible: boolean;
  82743. /**
  82744. * Index of this particle in the global "positions" array (Internal use)
  82745. * @hidden
  82746. */
  82747. _pos: number;
  82748. /**
  82749. * @hidden Index of this particle in the global "indices" array (Internal use)
  82750. */
  82751. _ind: number;
  82752. /**
  82753. * @hidden ModelShape of this particle (Internal use)
  82754. */
  82755. _model: ModelShape;
  82756. /**
  82757. * ModelShape id of this particle
  82758. */
  82759. shapeId: number;
  82760. /**
  82761. * Index of the particle in its shape id (Internal use)
  82762. */
  82763. idxInShape: number;
  82764. /**
  82765. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82766. */
  82767. _modelBoundingInfo: BoundingInfo;
  82768. /**
  82769. * @hidden Particle BoundingInfo object (Internal use)
  82770. */
  82771. _boundingInfo: BoundingInfo;
  82772. /**
  82773. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82774. */
  82775. _sps: SolidParticleSystem;
  82776. /**
  82777. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82778. */
  82779. _stillInvisible: boolean;
  82780. /**
  82781. * @hidden Last computed particle rotation matrix
  82782. */
  82783. _rotationMatrix: number[];
  82784. /**
  82785. * Parent particle Id, if any.
  82786. * Default null.
  82787. */
  82788. parentId: Nullable<number>;
  82789. /**
  82790. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82791. * The possible values are :
  82792. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82793. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82794. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82795. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82796. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82797. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82798. * */
  82799. cullingStrategy: number;
  82800. /**
  82801. * @hidden Internal global position in the SPS.
  82802. */
  82803. _globalPosition: Vector3;
  82804. /**
  82805. * Creates a Solid Particle object.
  82806. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82807. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82808. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82809. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82810. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82811. * @param shapeId (integer) is the model shape identifier in the SPS.
  82812. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82813. * @param sps defines the sps it is associated to
  82814. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82815. */
  82816. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82817. /**
  82818. * Legacy support, changed scale to scaling
  82819. */
  82820. /**
  82821. * Legacy support, changed scale to scaling
  82822. */
  82823. scale: Vector3;
  82824. /**
  82825. * Legacy support, changed quaternion to rotationQuaternion
  82826. */
  82827. /**
  82828. * Legacy support, changed quaternion to rotationQuaternion
  82829. */
  82830. quaternion: Nullable<Quaternion>;
  82831. /**
  82832. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82833. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82834. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82835. * @returns true if it intersects
  82836. */
  82837. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82838. /**
  82839. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82840. * A particle is in the frustum if its bounding box intersects the frustum
  82841. * @param frustumPlanes defines the frustum to test
  82842. * @returns true if the particle is in the frustum planes
  82843. */
  82844. isInFrustum(frustumPlanes: Plane[]): boolean;
  82845. /**
  82846. * get the rotation matrix of the particle
  82847. * @hidden
  82848. */
  82849. getRotationMatrix(m: Matrix): void;
  82850. }
  82851. /**
  82852. * Represents the shape of the model used by one particle of a solid particle system.
  82853. * SPS internal tool, don't use it manually.
  82854. */
  82855. export class ModelShape {
  82856. /**
  82857. * The shape id
  82858. * @hidden
  82859. */
  82860. shapeID: number;
  82861. /**
  82862. * flat array of model positions (internal use)
  82863. * @hidden
  82864. */
  82865. _shape: Vector3[];
  82866. /**
  82867. * flat array of model UVs (internal use)
  82868. * @hidden
  82869. */
  82870. _shapeUV: number[];
  82871. /**
  82872. * length of the shape in the model indices array (internal use)
  82873. * @hidden
  82874. */
  82875. _indicesLength: number;
  82876. /**
  82877. * Custom position function (internal use)
  82878. * @hidden
  82879. */
  82880. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82881. /**
  82882. * Custom vertex function (internal use)
  82883. * @hidden
  82884. */
  82885. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82886. /**
  82887. * 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.
  82888. * SPS internal tool, don't use it manually.
  82889. * @hidden
  82890. */
  82891. 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>);
  82892. }
  82893. /**
  82894. * Represents a Depth Sorted Particle in the solid particle system.
  82895. */
  82896. export class DepthSortedParticle {
  82897. /**
  82898. * Index of the particle in the "indices" array
  82899. */
  82900. ind: number;
  82901. /**
  82902. * Length of the particle shape in the "indices" array
  82903. */
  82904. indicesLength: number;
  82905. /**
  82906. * Squared distance from the particle to the camera
  82907. */
  82908. sqDistance: number;
  82909. }
  82910. }
  82911. declare module BABYLON {
  82912. /**
  82913. * Class used to store all common mesh properties
  82914. */
  82915. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82916. /** No occlusion */
  82917. static OCCLUSION_TYPE_NONE: number;
  82918. /** Occlusion set to optimisitic */
  82919. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82920. /** Occlusion set to strict */
  82921. static OCCLUSION_TYPE_STRICT: number;
  82922. /** Use an accurante occlusion algorithm */
  82923. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82924. /** Use a conservative occlusion algorithm */
  82925. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82926. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82927. * Test order :
  82928. * Is the bounding sphere outside the frustum ?
  82929. * If not, are the bounding box vertices outside the frustum ?
  82930. * It not, then the cullable object is in the frustum.
  82931. */
  82932. static readonly CULLINGSTRATEGY_STANDARD: number;
  82933. /** Culling strategy : Bounding Sphere Only.
  82934. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82935. * It's also less accurate than the standard because some not visible objects can still be selected.
  82936. * Test : is the bounding sphere outside the frustum ?
  82937. * If not, then the cullable object is in the frustum.
  82938. */
  82939. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82940. /** Culling strategy : Optimistic Inclusion.
  82941. * This in an inclusion test first, then the standard exclusion test.
  82942. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82943. * 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.
  82944. * Anyway, it's as accurate as the standard strategy.
  82945. * Test :
  82946. * Is the cullable object bounding sphere center in the frustum ?
  82947. * If not, apply the default culling strategy.
  82948. */
  82949. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82950. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82951. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82952. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82953. * 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.
  82954. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82955. * Test :
  82956. * Is the cullable object bounding sphere center in the frustum ?
  82957. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82958. */
  82959. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82960. /**
  82961. * No billboard
  82962. */
  82963. static readonly BILLBOARDMODE_NONE: number;
  82964. /** Billboard on X axis */
  82965. static readonly BILLBOARDMODE_X: number;
  82966. /** Billboard on Y axis */
  82967. static readonly BILLBOARDMODE_Y: number;
  82968. /** Billboard on Z axis */
  82969. static readonly BILLBOARDMODE_Z: number;
  82970. /** Billboard on all axes */
  82971. static readonly BILLBOARDMODE_ALL: number;
  82972. private _facetData;
  82973. /**
  82974. * The culling strategy to use to check whether the mesh must be rendered or not.
  82975. * This value can be changed at any time and will be used on the next render mesh selection.
  82976. * The possible values are :
  82977. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82978. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82979. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82980. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82981. * Please read each static variable documentation to get details about the culling process.
  82982. * */
  82983. cullingStrategy: number;
  82984. /**
  82985. * Gets the number of facets in the mesh
  82986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82987. */
  82988. readonly facetNb: number;
  82989. /**
  82990. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82992. */
  82993. partitioningSubdivisions: number;
  82994. /**
  82995. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82996. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82998. */
  82999. partitioningBBoxRatio: number;
  83000. /**
  83001. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83002. * Works only for updatable meshes.
  83003. * Doesn't work with multi-materials
  83004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83005. */
  83006. mustDepthSortFacets: boolean;
  83007. /**
  83008. * The location (Vector3) where the facet depth sort must be computed from.
  83009. * By default, the active camera position.
  83010. * Used only when facet depth sort is enabled
  83011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83012. */
  83013. facetDepthSortFrom: Vector3;
  83014. /**
  83015. * gets a boolean indicating if facetData is enabled
  83016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83017. */
  83018. readonly isFacetDataEnabled: boolean;
  83019. /** @hidden */
  83020. _updateNonUniformScalingState(value: boolean): boolean;
  83021. /**
  83022. * An event triggered when this mesh collides with another one
  83023. */
  83024. onCollideObservable: Observable<AbstractMesh>;
  83025. private _onCollideObserver;
  83026. /** Set a function to call when this mesh collides with another one */
  83027. onCollide: () => void;
  83028. /**
  83029. * An event triggered when the collision's position changes
  83030. */
  83031. onCollisionPositionChangeObservable: Observable<Vector3>;
  83032. private _onCollisionPositionChangeObserver;
  83033. /** Set a function to call when the collision's position changes */
  83034. onCollisionPositionChange: () => void;
  83035. /**
  83036. * An event triggered when material is changed
  83037. */
  83038. onMaterialChangedObservable: Observable<AbstractMesh>;
  83039. /**
  83040. * Gets or sets the orientation for POV movement & rotation
  83041. */
  83042. definedFacingForward: boolean;
  83043. /** @hidden */
  83044. _occlusionQuery: Nullable<WebGLQuery>;
  83045. private _visibility;
  83046. /**
  83047. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83048. */
  83049. /**
  83050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83051. */
  83052. visibility: number;
  83053. /** Gets or sets the alpha index used to sort transparent meshes
  83054. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83055. */
  83056. alphaIndex: number;
  83057. /**
  83058. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83059. */
  83060. isVisible: boolean;
  83061. /**
  83062. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83063. */
  83064. isPickable: boolean;
  83065. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83066. showSubMeshesBoundingBox: boolean;
  83067. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83068. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83069. */
  83070. isBlocker: boolean;
  83071. /**
  83072. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83073. */
  83074. enablePointerMoveEvents: boolean;
  83075. /**
  83076. * Specifies the rendering group id for this mesh (0 by default)
  83077. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83078. */
  83079. renderingGroupId: number;
  83080. private _material;
  83081. /** Gets or sets current material */
  83082. material: Nullable<Material>;
  83083. private _receiveShadows;
  83084. /**
  83085. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83086. * @see http://doc.babylonjs.com/babylon101/shadows
  83087. */
  83088. receiveShadows: boolean;
  83089. /** Defines color to use when rendering outline */
  83090. outlineColor: Color3;
  83091. /** Define width to use when rendering outline */
  83092. outlineWidth: number;
  83093. /** Defines color to use when rendering overlay */
  83094. overlayColor: Color3;
  83095. /** Defines alpha to use when rendering overlay */
  83096. overlayAlpha: number;
  83097. private _hasVertexAlpha;
  83098. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83099. hasVertexAlpha: boolean;
  83100. private _useVertexColors;
  83101. /** 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) */
  83102. useVertexColors: boolean;
  83103. private _computeBonesUsingShaders;
  83104. /**
  83105. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83106. */
  83107. computeBonesUsingShaders: boolean;
  83108. private _numBoneInfluencers;
  83109. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83110. numBoneInfluencers: number;
  83111. private _applyFog;
  83112. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83113. applyFog: boolean;
  83114. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83115. useOctreeForRenderingSelection: boolean;
  83116. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83117. useOctreeForPicking: boolean;
  83118. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83119. useOctreeForCollisions: boolean;
  83120. private _layerMask;
  83121. /**
  83122. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83123. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83124. */
  83125. layerMask: number;
  83126. /**
  83127. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83128. */
  83129. alwaysSelectAsActiveMesh: boolean;
  83130. /**
  83131. * Gets or sets the current action manager
  83132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83133. */
  83134. actionManager: Nullable<AbstractActionManager>;
  83135. private _checkCollisions;
  83136. private _collisionMask;
  83137. private _collisionGroup;
  83138. /**
  83139. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83141. */
  83142. ellipsoid: Vector3;
  83143. /**
  83144. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83146. */
  83147. ellipsoidOffset: Vector3;
  83148. private _collider;
  83149. private _oldPositionForCollisions;
  83150. private _diffPositionForCollisions;
  83151. /**
  83152. * Gets or sets a collision mask used to mask collisions (default is -1).
  83153. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83154. */
  83155. collisionMask: number;
  83156. /**
  83157. * Gets or sets the current collision group mask (-1 by default).
  83158. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83159. */
  83160. collisionGroup: number;
  83161. /**
  83162. * Defines edge width used when edgesRenderer is enabled
  83163. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83164. */
  83165. edgesWidth: number;
  83166. /**
  83167. * Defines edge color used when edgesRenderer is enabled
  83168. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83169. */
  83170. edgesColor: Color4;
  83171. /** @hidden */
  83172. _edgesRenderer: Nullable<IEdgesRenderer>;
  83173. /** @hidden */
  83174. _masterMesh: Nullable<AbstractMesh>;
  83175. /** @hidden */
  83176. _boundingInfo: Nullable<BoundingInfo>;
  83177. /** @hidden */
  83178. _renderId: number;
  83179. /**
  83180. * Gets or sets the list of subMeshes
  83181. * @see http://doc.babylonjs.com/how_to/multi_materials
  83182. */
  83183. subMeshes: SubMesh[];
  83184. /** @hidden */
  83185. _intersectionsInProgress: AbstractMesh[];
  83186. /** @hidden */
  83187. _unIndexed: boolean;
  83188. /** @hidden */
  83189. _lightSources: Light[];
  83190. /** @hidden */
  83191. readonly _positions: Nullable<Vector3[]>;
  83192. /** @hidden */
  83193. _waitingActions: any;
  83194. /** @hidden */
  83195. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83196. private _skeleton;
  83197. /** @hidden */
  83198. _bonesTransformMatrices: Nullable<Float32Array>;
  83199. /**
  83200. * Gets or sets a skeleton to apply skining transformations
  83201. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83202. */
  83203. skeleton: Nullable<Skeleton>;
  83204. /**
  83205. * An event triggered when the mesh is rebuilt.
  83206. */
  83207. onRebuildObservable: Observable<AbstractMesh>;
  83208. /**
  83209. * Creates a new AbstractMesh
  83210. * @param name defines the name of the mesh
  83211. * @param scene defines the hosting scene
  83212. */
  83213. constructor(name: string, scene?: Nullable<Scene>);
  83214. /**
  83215. * Returns the string "AbstractMesh"
  83216. * @returns "AbstractMesh"
  83217. */
  83218. getClassName(): string;
  83219. /**
  83220. * Gets a string representation of the current mesh
  83221. * @param fullDetails defines a boolean indicating if full details must be included
  83222. * @returns a string representation of the current mesh
  83223. */
  83224. toString(fullDetails?: boolean): string;
  83225. /** @hidden */
  83226. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83227. /** @hidden */
  83228. _rebuild(): void;
  83229. /** @hidden */
  83230. _resyncLightSources(): void;
  83231. /** @hidden */
  83232. _resyncLighSource(light: Light): void;
  83233. /** @hidden */
  83234. _unBindEffect(): void;
  83235. /** @hidden */
  83236. _removeLightSource(light: Light): void;
  83237. private _markSubMeshesAsDirty;
  83238. /** @hidden */
  83239. _markSubMeshesAsLightDirty(): void;
  83240. /** @hidden */
  83241. _markSubMeshesAsAttributesDirty(): void;
  83242. /** @hidden */
  83243. _markSubMeshesAsMiscDirty(): void;
  83244. /**
  83245. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83246. */
  83247. scaling: Vector3;
  83248. /**
  83249. * Returns true if the mesh is blocked. Implemented by child classes
  83250. */
  83251. readonly isBlocked: boolean;
  83252. /**
  83253. * Returns the mesh itself by default. Implemented by child classes
  83254. * @param camera defines the camera to use to pick the right LOD level
  83255. * @returns the currentAbstractMesh
  83256. */
  83257. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83258. /**
  83259. * Returns 0 by default. Implemented by child classes
  83260. * @returns an integer
  83261. */
  83262. getTotalVertices(): number;
  83263. /**
  83264. * Returns a positive integer : the total number of indices in this mesh geometry.
  83265. * @returns the numner of indices or zero if the mesh has no geometry.
  83266. */
  83267. getTotalIndices(): number;
  83268. /**
  83269. * Returns null by default. Implemented by child classes
  83270. * @returns null
  83271. */
  83272. getIndices(): Nullable<IndicesArray>;
  83273. /**
  83274. * Returns the array of the requested vertex data kind. Implemented by child classes
  83275. * @param kind defines the vertex data kind to use
  83276. * @returns null
  83277. */
  83278. getVerticesData(kind: string): Nullable<FloatArray>;
  83279. /**
  83280. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83281. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83282. * Note that a new underlying VertexBuffer object is created each call.
  83283. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83284. * @param kind defines vertex data kind:
  83285. * * VertexBuffer.PositionKind
  83286. * * VertexBuffer.UVKind
  83287. * * VertexBuffer.UV2Kind
  83288. * * VertexBuffer.UV3Kind
  83289. * * VertexBuffer.UV4Kind
  83290. * * VertexBuffer.UV5Kind
  83291. * * VertexBuffer.UV6Kind
  83292. * * VertexBuffer.ColorKind
  83293. * * VertexBuffer.MatricesIndicesKind
  83294. * * VertexBuffer.MatricesIndicesExtraKind
  83295. * * VertexBuffer.MatricesWeightsKind
  83296. * * VertexBuffer.MatricesWeightsExtraKind
  83297. * @param data defines the data source
  83298. * @param updatable defines if the data must be flagged as updatable (or static)
  83299. * @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
  83300. * @returns the current mesh
  83301. */
  83302. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83303. /**
  83304. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83305. * If the mesh has no geometry, it is simply returned as it is.
  83306. * @param kind defines vertex data kind:
  83307. * * VertexBuffer.PositionKind
  83308. * * VertexBuffer.UVKind
  83309. * * VertexBuffer.UV2Kind
  83310. * * VertexBuffer.UV3Kind
  83311. * * VertexBuffer.UV4Kind
  83312. * * VertexBuffer.UV5Kind
  83313. * * VertexBuffer.UV6Kind
  83314. * * VertexBuffer.ColorKind
  83315. * * VertexBuffer.MatricesIndicesKind
  83316. * * VertexBuffer.MatricesIndicesExtraKind
  83317. * * VertexBuffer.MatricesWeightsKind
  83318. * * VertexBuffer.MatricesWeightsExtraKind
  83319. * @param data defines the data source
  83320. * @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
  83321. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83322. * @returns the current mesh
  83323. */
  83324. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83325. /**
  83326. * Sets the mesh indices,
  83327. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83328. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83329. * @param totalVertices Defines the total number of vertices
  83330. * @returns the current mesh
  83331. */
  83332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83333. /**
  83334. * Gets a boolean indicating if specific vertex data is present
  83335. * @param kind defines the vertex data kind to use
  83336. * @returns true is data kind is present
  83337. */
  83338. isVerticesDataPresent(kind: string): boolean;
  83339. /**
  83340. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83341. * @returns a BoundingInfo
  83342. */
  83343. getBoundingInfo(): BoundingInfo;
  83344. /**
  83345. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83346. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83347. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83348. * @returns the current mesh
  83349. */
  83350. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83351. /**
  83352. * Overwrite the current bounding info
  83353. * @param boundingInfo defines the new bounding info
  83354. * @returns the current mesh
  83355. */
  83356. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83357. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83358. readonly useBones: boolean;
  83359. /** @hidden */
  83360. _preActivate(): void;
  83361. /** @hidden */
  83362. _preActivateForIntermediateRendering(renderId: number): void;
  83363. /** @hidden */
  83364. _activate(renderId: number): void;
  83365. /**
  83366. * Gets the current world matrix
  83367. * @returns a Matrix
  83368. */
  83369. getWorldMatrix(): Matrix;
  83370. /** @hidden */
  83371. _getWorldMatrixDeterminant(): number;
  83372. /**
  83373. * Perform relative position change from the point of view of behind the front of the mesh.
  83374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83375. * Supports definition of mesh facing forward or backward
  83376. * @param amountRight defines the distance on the right axis
  83377. * @param amountUp defines the distance on the up axis
  83378. * @param amountForward defines the distance on the forward axis
  83379. * @returns the current mesh
  83380. */
  83381. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83382. /**
  83383. * Calculate relative position change from the point of view of behind the front of the mesh.
  83384. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83385. * Supports definition of mesh facing forward or backward
  83386. * @param amountRight defines the distance on the right axis
  83387. * @param amountUp defines the distance on the up axis
  83388. * @param amountForward defines the distance on the forward axis
  83389. * @returns the new displacement vector
  83390. */
  83391. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83392. /**
  83393. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83394. * Supports definition of mesh facing forward or backward
  83395. * @param flipBack defines the flip
  83396. * @param twirlClockwise defines the twirl
  83397. * @param tiltRight defines the tilt
  83398. * @returns the current mesh
  83399. */
  83400. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83401. /**
  83402. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83403. * Supports definition of mesh facing forward or backward.
  83404. * @param flipBack defines the flip
  83405. * @param twirlClockwise defines the twirl
  83406. * @param tiltRight defines the tilt
  83407. * @returns the new rotation vector
  83408. */
  83409. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83410. /**
  83411. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83412. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83413. * @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
  83414. * @returns the new bounding vectors
  83415. */
  83416. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83417. min: Vector3;
  83418. max: Vector3;
  83419. };
  83420. /**
  83421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83422. * This means the mesh underlying bounding box and sphere are recomputed.
  83423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83424. * @returns the current mesh
  83425. */
  83426. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83427. /** @hidden */
  83428. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83429. /** @hidden */
  83430. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83431. /** @hidden */
  83432. _updateBoundingInfo(): AbstractMesh;
  83433. /** @hidden */
  83434. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83435. /** @hidden */
  83436. protected _afterComputeWorldMatrix(): void;
  83437. /** @hidden */
  83438. readonly _effectiveMesh: AbstractMesh;
  83439. /**
  83440. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83441. * A mesh is in the frustum if its bounding box intersects the frustum
  83442. * @param frustumPlanes defines the frustum to test
  83443. * @returns true if the mesh is in the frustum planes
  83444. */
  83445. isInFrustum(frustumPlanes: Plane[]): boolean;
  83446. /**
  83447. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83448. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83449. * @param frustumPlanes defines the frustum to test
  83450. * @returns true if the mesh is completely in the frustum planes
  83451. */
  83452. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83453. /**
  83454. * True if the mesh intersects another mesh or a SolidParticle object
  83455. * @param mesh defines a target mesh or SolidParticle to test
  83456. * @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)
  83457. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83458. * @returns true if there is an intersection
  83459. */
  83460. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83461. /**
  83462. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83463. * @param point defines the point to test
  83464. * @returns true if there is an intersection
  83465. */
  83466. intersectsPoint(point: Vector3): boolean;
  83467. /**
  83468. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83470. */
  83471. checkCollisions: boolean;
  83472. /**
  83473. * Gets Collider object used to compute collisions (not physics)
  83474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83475. */
  83476. readonly collider: Collider;
  83477. /**
  83478. * Move the mesh using collision engine
  83479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83480. * @param displacement defines the requested displacement vector
  83481. * @returns the current mesh
  83482. */
  83483. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83484. private _onCollisionPositionChange;
  83485. /** @hidden */
  83486. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83487. /** @hidden */
  83488. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83489. /** @hidden */
  83490. _checkCollision(collider: Collider): AbstractMesh;
  83491. /** @hidden */
  83492. _generatePointsArray(): boolean;
  83493. /**
  83494. * Checks if the passed Ray intersects with the mesh
  83495. * @param ray defines the ray to use
  83496. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83497. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83498. * @returns the picking info
  83499. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83500. */
  83501. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83502. /**
  83503. * Clones the current mesh
  83504. * @param name defines the mesh name
  83505. * @param newParent defines the new mesh parent
  83506. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83507. * @returns the new mesh
  83508. */
  83509. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83510. /**
  83511. * Disposes all the submeshes of the current meshnp
  83512. * @returns the current mesh
  83513. */
  83514. releaseSubMeshes(): AbstractMesh;
  83515. /**
  83516. * Releases resources associated with this abstract mesh.
  83517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83519. */
  83520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83521. /**
  83522. * Adds the passed mesh as a child to the current mesh
  83523. * @param mesh defines the child mesh
  83524. * @returns the current mesh
  83525. */
  83526. addChild(mesh: AbstractMesh): AbstractMesh;
  83527. /**
  83528. * Removes the passed mesh from the current mesh children list
  83529. * @param mesh defines the child mesh
  83530. * @returns the current mesh
  83531. */
  83532. removeChild(mesh: AbstractMesh): AbstractMesh;
  83533. /** @hidden */
  83534. private _initFacetData;
  83535. /**
  83536. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83537. * This method can be called within the render loop.
  83538. * 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
  83539. * @returns the current mesh
  83540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83541. */
  83542. updateFacetData(): AbstractMesh;
  83543. /**
  83544. * Returns the facetLocalNormals array.
  83545. * The normals are expressed in the mesh local spac
  83546. * @returns an array of Vector3
  83547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83548. */
  83549. getFacetLocalNormals(): Vector3[];
  83550. /**
  83551. * Returns the facetLocalPositions array.
  83552. * The facet positions are expressed in the mesh local space
  83553. * @returns an array of Vector3
  83554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83555. */
  83556. getFacetLocalPositions(): Vector3[];
  83557. /**
  83558. * Returns the facetLocalPartioning array
  83559. * @returns an array of array of numbers
  83560. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83561. */
  83562. getFacetLocalPartitioning(): number[][];
  83563. /**
  83564. * Returns the i-th facet position in the world system.
  83565. * This method allocates a new Vector3 per call
  83566. * @param i defines the facet index
  83567. * @returns a new Vector3
  83568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83569. */
  83570. getFacetPosition(i: number): Vector3;
  83571. /**
  83572. * Sets the reference Vector3 with the i-th facet position in the world system
  83573. * @param i defines the facet index
  83574. * @param ref defines the target vector
  83575. * @returns the current mesh
  83576. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83577. */
  83578. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83579. /**
  83580. * Returns the i-th facet normal in the world system.
  83581. * This method allocates a new Vector3 per call
  83582. * @param i defines the facet index
  83583. * @returns a new Vector3
  83584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83585. */
  83586. getFacetNormal(i: number): Vector3;
  83587. /**
  83588. * Sets the reference Vector3 with the i-th facet normal in the world system
  83589. * @param i defines the facet index
  83590. * @param ref defines the target vector
  83591. * @returns the current mesh
  83592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83593. */
  83594. getFacetNormalToRef(i: number, ref: Vector3): this;
  83595. /**
  83596. * 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)
  83597. * @param x defines x coordinate
  83598. * @param y defines y coordinate
  83599. * @param z defines z coordinate
  83600. * @returns the array of facet indexes
  83601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83602. */
  83603. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83604. /**
  83605. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83606. * @param projected sets as the (x,y,z) world projection on the facet
  83607. * @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
  83608. * @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
  83609. * @param x defines x coordinate
  83610. * @param y defines y coordinate
  83611. * @param z defines z coordinate
  83612. * @returns the face index if found (or null instead)
  83613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83614. */
  83615. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83616. /**
  83617. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83618. * @param projected sets as the (x,y,z) local projection on the facet
  83619. * @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
  83620. * @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
  83621. * @param x defines x coordinate
  83622. * @param y defines y coordinate
  83623. * @param z defines z coordinate
  83624. * @returns the face index if found (or null instead)
  83625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83626. */
  83627. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83628. /**
  83629. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83630. * @returns the parameters
  83631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83632. */
  83633. getFacetDataParameters(): any;
  83634. /**
  83635. * Disables the feature FacetData and frees the related memory
  83636. * @returns the current mesh
  83637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83638. */
  83639. disableFacetData(): AbstractMesh;
  83640. /**
  83641. * Updates the AbstractMesh indices array
  83642. * @param indices defines the data source
  83643. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83644. * @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)
  83645. * @returns the current mesh
  83646. */
  83647. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83648. /**
  83649. * Creates new normals data for the mesh
  83650. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83651. * @returns the current mesh
  83652. */
  83653. createNormals(updatable: boolean): AbstractMesh;
  83654. /**
  83655. * Align the mesh with a normal
  83656. * @param normal defines the normal to use
  83657. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83658. * @returns the current mesh
  83659. */
  83660. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83661. /** @hidden */
  83662. _checkOcclusionQuery(): boolean;
  83663. }
  83664. }
  83665. declare module BABYLON {
  83666. /**
  83667. * Interface used to define ActionEvent
  83668. */
  83669. export interface IActionEvent {
  83670. /** The mesh or sprite that triggered the action */
  83671. source: any;
  83672. /** The X mouse cursor position at the time of the event */
  83673. pointerX: number;
  83674. /** The Y mouse cursor position at the time of the event */
  83675. pointerY: number;
  83676. /** The mesh that is currently pointed at (can be null) */
  83677. meshUnderPointer: Nullable<AbstractMesh>;
  83678. /** the original (browser) event that triggered the ActionEvent */
  83679. sourceEvent?: any;
  83680. /** additional data for the event */
  83681. additionalData?: any;
  83682. }
  83683. /**
  83684. * ActionEvent is the event being sent when an action is triggered.
  83685. */
  83686. export class ActionEvent implements IActionEvent {
  83687. /** The mesh or sprite that triggered the action */
  83688. source: any;
  83689. /** The X mouse cursor position at the time of the event */
  83690. pointerX: number;
  83691. /** The Y mouse cursor position at the time of the event */
  83692. pointerY: number;
  83693. /** The mesh that is currently pointed at (can be null) */
  83694. meshUnderPointer: Nullable<AbstractMesh>;
  83695. /** the original (browser) event that triggered the ActionEvent */
  83696. sourceEvent?: any;
  83697. /** additional data for the event */
  83698. additionalData?: any;
  83699. /**
  83700. * Creates a new ActionEvent
  83701. * @param source The mesh or sprite that triggered the action
  83702. * @param pointerX The X mouse cursor position at the time of the event
  83703. * @param pointerY The Y mouse cursor position at the time of the event
  83704. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83705. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83706. * @param additionalData additional data for the event
  83707. */
  83708. constructor(
  83709. /** The mesh or sprite that triggered the action */
  83710. source: any,
  83711. /** The X mouse cursor position at the time of the event */
  83712. pointerX: number,
  83713. /** The Y mouse cursor position at the time of the event */
  83714. pointerY: number,
  83715. /** The mesh that is currently pointed at (can be null) */
  83716. meshUnderPointer: Nullable<AbstractMesh>,
  83717. /** the original (browser) event that triggered the ActionEvent */
  83718. sourceEvent?: any,
  83719. /** additional data for the event */
  83720. additionalData?: any);
  83721. /**
  83722. * Helper function to auto-create an ActionEvent from a source mesh.
  83723. * @param source The source mesh that triggered the event
  83724. * @param evt The original (browser) event
  83725. * @param additionalData additional data for the event
  83726. * @returns the new ActionEvent
  83727. */
  83728. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83729. /**
  83730. * Helper function to auto-create an ActionEvent from a source sprite
  83731. * @param source The source sprite that triggered the event
  83732. * @param scene Scene associated with the sprite
  83733. * @param evt The original (browser) event
  83734. * @param additionalData additional data for the event
  83735. * @returns the new ActionEvent
  83736. */
  83737. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83738. /**
  83739. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83740. * @param scene the scene where the event occurred
  83741. * @param evt The original (browser) event
  83742. * @returns the new ActionEvent
  83743. */
  83744. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83745. /**
  83746. * Helper function to auto-create an ActionEvent from a primitive
  83747. * @param prim defines the target primitive
  83748. * @param pointerPos defines the pointer position
  83749. * @param evt The original (browser) event
  83750. * @param additionalData additional data for the event
  83751. * @returns the new ActionEvent
  83752. */
  83753. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83754. }
  83755. }
  83756. declare module BABYLON {
  83757. /**
  83758. * Abstract class used to decouple action Manager from scene and meshes.
  83759. * Do not instantiate.
  83760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83761. */
  83762. export abstract class AbstractActionManager implements IDisposable {
  83763. /** Gets the list of active triggers */
  83764. static Triggers: {
  83765. [key: string]: number;
  83766. };
  83767. /** Gets the cursor to use when hovering items */
  83768. hoverCursor: string;
  83769. /** Gets the list of actions */
  83770. actions: IAction[];
  83771. /**
  83772. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  83773. */
  83774. isRecursive: boolean;
  83775. /**
  83776. * Releases all associated resources
  83777. */
  83778. abstract dispose(): void;
  83779. /**
  83780. * Does this action manager has pointer triggers
  83781. */
  83782. abstract readonly hasPointerTriggers: boolean;
  83783. /**
  83784. * Does this action manager has pick triggers
  83785. */
  83786. abstract readonly hasPickTriggers: boolean;
  83787. /**
  83788. * Process a specific trigger
  83789. * @param trigger defines the trigger to process
  83790. * @param evt defines the event details to be processed
  83791. */
  83792. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83793. /**
  83794. * Does this action manager handles actions of any of the given triggers
  83795. * @param triggers defines the triggers to be tested
  83796. * @return a boolean indicating whether one (or more) of the triggers is handled
  83797. */
  83798. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83799. /**
  83800. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83801. * speed.
  83802. * @param triggerA defines the trigger to be tested
  83803. * @param triggerB defines the trigger to be tested
  83804. * @return a boolean indicating whether one (or more) of the triggers is handled
  83805. */
  83806. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83807. /**
  83808. * Does this action manager handles actions of a given trigger
  83809. * @param trigger defines the trigger to be tested
  83810. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83811. * @return whether the trigger is handled
  83812. */
  83813. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83814. /**
  83815. * Serialize this manager to a JSON object
  83816. * @param name defines the property name to store this manager
  83817. * @returns a JSON representation of this manager
  83818. */
  83819. abstract serialize(name: string): any;
  83820. /**
  83821. * Registers an action to this action manager
  83822. * @param action defines the action to be registered
  83823. * @return the action amended (prepared) after registration
  83824. */
  83825. abstract registerAction(action: IAction): Nullable<IAction>;
  83826. /**
  83827. * Unregisters an action to this action manager
  83828. * @param action defines the action to be unregistered
  83829. * @return a boolean indicating whether the action has been unregistered
  83830. */
  83831. abstract unregisterAction(action: IAction): Boolean;
  83832. /**
  83833. * Does exist one action manager with at least one trigger
  83834. **/
  83835. static readonly HasTriggers: boolean;
  83836. /**
  83837. * Does exist one action manager with at least one pick trigger
  83838. **/
  83839. static readonly HasPickTriggers: boolean;
  83840. /**
  83841. * Does exist one action manager that handles actions of a given trigger
  83842. * @param trigger defines the trigger to be tested
  83843. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83844. **/
  83845. static HasSpecificTrigger(trigger: number): boolean;
  83846. }
  83847. }
  83848. declare module BABYLON {
  83849. /**
  83850. * Defines how a node can be built from a string name.
  83851. */
  83852. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83853. /**
  83854. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83855. */
  83856. export class Node implements IBehaviorAware<Node> {
  83857. /** @hidden */
  83858. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83859. private static _NodeConstructors;
  83860. /**
  83861. * Add a new node constructor
  83862. * @param type defines the type name of the node to construct
  83863. * @param constructorFunc defines the constructor function
  83864. */
  83865. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83866. /**
  83867. * Returns a node constructor based on type name
  83868. * @param type defines the type name
  83869. * @param name defines the new node name
  83870. * @param scene defines the hosting scene
  83871. * @param options defines optional options to transmit to constructors
  83872. * @returns the new constructor or null
  83873. */
  83874. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83875. /**
  83876. * Gets or sets the name of the node
  83877. */
  83878. name: string;
  83879. /**
  83880. * Gets or sets the id of the node
  83881. */
  83882. id: string;
  83883. /**
  83884. * Gets or sets the unique id of the node
  83885. */
  83886. uniqueId: number;
  83887. /**
  83888. * Gets or sets a string used to store user defined state for the node
  83889. */
  83890. state: string;
  83891. /**
  83892. * Gets or sets an object used to store user defined information for the node
  83893. */
  83894. metadata: any;
  83895. /**
  83896. * For internal use only. Please do not use.
  83897. */
  83898. reservedDataStore: any;
  83899. /**
  83900. * List of inspectable custom properties (used by the Inspector)
  83901. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83902. */
  83903. inspectableCustomProperties: IInspectable[];
  83904. /**
  83905. * Gets or sets a boolean used to define if the node must be serialized
  83906. */
  83907. doNotSerialize: boolean;
  83908. /** @hidden */
  83909. _isDisposed: boolean;
  83910. /**
  83911. * Gets a list of Animations associated with the node
  83912. */
  83913. animations: Animation[];
  83914. protected _ranges: {
  83915. [name: string]: Nullable<AnimationRange>;
  83916. };
  83917. /**
  83918. * Callback raised when the node is ready to be used
  83919. */
  83920. onReady: (node: Node) => void;
  83921. private _isEnabled;
  83922. private _isParentEnabled;
  83923. private _isReady;
  83924. /** @hidden */
  83925. _currentRenderId: number;
  83926. private _parentUpdateId;
  83927. protected _childUpdateId: number;
  83928. /** @hidden */
  83929. _waitingParentId: Nullable<string>;
  83930. /** @hidden */
  83931. _scene: Scene;
  83932. /** @hidden */
  83933. _cache: any;
  83934. private _parentNode;
  83935. private _children;
  83936. /** @hidden */
  83937. _worldMatrix: Matrix;
  83938. /** @hidden */
  83939. _worldMatrixDeterminant: number;
  83940. /** @hidden */
  83941. private _sceneRootNodesIndex;
  83942. /**
  83943. * Gets a boolean indicating if the node has been disposed
  83944. * @returns true if the node was disposed
  83945. */
  83946. isDisposed(): boolean;
  83947. /**
  83948. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83949. * @see https://doc.babylonjs.com/how_to/parenting
  83950. */
  83951. parent: Nullable<Node>;
  83952. private addToSceneRootNodes;
  83953. private removeFromSceneRootNodes;
  83954. private _animationPropertiesOverride;
  83955. /**
  83956. * Gets or sets the animation properties override
  83957. */
  83958. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83959. /**
  83960. * Gets a string idenfifying the name of the class
  83961. * @returns "Node" string
  83962. */
  83963. getClassName(): string;
  83964. /** @hidden */
  83965. readonly _isNode: boolean;
  83966. /**
  83967. * An event triggered when the mesh is disposed
  83968. */
  83969. onDisposeObservable: Observable<Node>;
  83970. private _onDisposeObserver;
  83971. /**
  83972. * Sets a callback that will be raised when the node will be disposed
  83973. */
  83974. onDispose: () => void;
  83975. /**
  83976. * Creates a new Node
  83977. * @param name the name and id to be given to this node
  83978. * @param scene the scene this node will be added to
  83979. * @param addToRootNodes the node will be added to scene.rootNodes
  83980. */
  83981. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83982. /**
  83983. * Gets the scene of the node
  83984. * @returns a scene
  83985. */
  83986. getScene(): Scene;
  83987. /**
  83988. * Gets the engine of the node
  83989. * @returns a Engine
  83990. */
  83991. getEngine(): Engine;
  83992. private _behaviors;
  83993. /**
  83994. * Attach a behavior to the node
  83995. * @see http://doc.babylonjs.com/features/behaviour
  83996. * @param behavior defines the behavior to attach
  83997. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83998. * @returns the current Node
  83999. */
  84000. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84001. /**
  84002. * Remove an attached behavior
  84003. * @see http://doc.babylonjs.com/features/behaviour
  84004. * @param behavior defines the behavior to attach
  84005. * @returns the current Node
  84006. */
  84007. removeBehavior(behavior: Behavior<Node>): Node;
  84008. /**
  84009. * Gets the list of attached behaviors
  84010. * @see http://doc.babylonjs.com/features/behaviour
  84011. */
  84012. readonly behaviors: Behavior<Node>[];
  84013. /**
  84014. * Gets an attached behavior by name
  84015. * @param name defines the name of the behavior to look for
  84016. * @see http://doc.babylonjs.com/features/behaviour
  84017. * @returns null if behavior was not found else the requested behavior
  84018. */
  84019. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84020. /**
  84021. * Returns the latest update of the World matrix
  84022. * @returns a Matrix
  84023. */
  84024. getWorldMatrix(): Matrix;
  84025. /** @hidden */
  84026. _getWorldMatrixDeterminant(): number;
  84027. /**
  84028. * Returns directly the latest state of the mesh World matrix.
  84029. * A Matrix is returned.
  84030. */
  84031. readonly worldMatrixFromCache: Matrix;
  84032. /** @hidden */
  84033. _initCache(): void;
  84034. /** @hidden */
  84035. updateCache(force?: boolean): void;
  84036. /** @hidden */
  84037. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84038. /** @hidden */
  84039. _updateCache(ignoreParentClass?: boolean): void;
  84040. /** @hidden */
  84041. _isSynchronized(): boolean;
  84042. /** @hidden */
  84043. _markSyncedWithParent(): void;
  84044. /** @hidden */
  84045. isSynchronizedWithParent(): boolean;
  84046. /** @hidden */
  84047. isSynchronized(): boolean;
  84048. /**
  84049. * Is this node ready to be used/rendered
  84050. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84051. * @return true if the node is ready
  84052. */
  84053. isReady(completeCheck?: boolean): boolean;
  84054. /**
  84055. * Is this node enabled?
  84056. * 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
  84057. * @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
  84058. * @return whether this node (and its parent) is enabled
  84059. */
  84060. isEnabled(checkAncestors?: boolean): boolean;
  84061. /** @hidden */
  84062. protected _syncParentEnabledState(): void;
  84063. /**
  84064. * Set the enabled state of this node
  84065. * @param value defines the new enabled state
  84066. */
  84067. setEnabled(value: boolean): void;
  84068. /**
  84069. * Is this node a descendant of the given node?
  84070. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84071. * @param ancestor defines the parent node to inspect
  84072. * @returns a boolean indicating if this node is a descendant of the given node
  84073. */
  84074. isDescendantOf(ancestor: Node): boolean;
  84075. /** @hidden */
  84076. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84077. /**
  84078. * Will return all nodes that have this node as ascendant
  84079. * @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
  84080. * @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
  84081. * @return all children nodes of all types
  84082. */
  84083. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84084. /**
  84085. * Get all child-meshes of this node
  84086. * @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)
  84087. * @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
  84088. * @returns an array of AbstractMesh
  84089. */
  84090. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84091. /**
  84092. * Get all direct children of this node
  84093. * @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
  84094. * @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)
  84095. * @returns an array of Node
  84096. */
  84097. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84098. /** @hidden */
  84099. _setReady(state: boolean): void;
  84100. /**
  84101. * Get an animation by name
  84102. * @param name defines the name of the animation to look for
  84103. * @returns null if not found else the requested animation
  84104. */
  84105. getAnimationByName(name: string): Nullable<Animation>;
  84106. /**
  84107. * Creates an animation range for this node
  84108. * @param name defines the name of the range
  84109. * @param from defines the starting key
  84110. * @param to defines the end key
  84111. */
  84112. createAnimationRange(name: string, from: number, to: number): void;
  84113. /**
  84114. * Delete a specific animation range
  84115. * @param name defines the name of the range to delete
  84116. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84117. */
  84118. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84119. /**
  84120. * Get an animation range by name
  84121. * @param name defines the name of the animation range to look for
  84122. * @returns null if not found else the requested animation range
  84123. */
  84124. getAnimationRange(name: string): Nullable<AnimationRange>;
  84125. /**
  84126. * Gets the list of all animation ranges defined on this node
  84127. * @returns an array
  84128. */
  84129. getAnimationRanges(): Nullable<AnimationRange>[];
  84130. /**
  84131. * Will start the animation sequence
  84132. * @param name defines the range frames for animation sequence
  84133. * @param loop defines if the animation should loop (false by default)
  84134. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84135. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84136. * @returns the object created for this animation. If range does not exist, it will return null
  84137. */
  84138. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84139. /**
  84140. * Serialize animation ranges into a JSON compatible object
  84141. * @returns serialization object
  84142. */
  84143. serializeAnimationRanges(): any;
  84144. /**
  84145. * Computes the world matrix of the node
  84146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84147. * @returns the world matrix
  84148. */
  84149. computeWorldMatrix(force?: boolean): Matrix;
  84150. /**
  84151. * Releases resources associated with this node.
  84152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84154. */
  84155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84156. /**
  84157. * Parse animation range data from a serialization object and store them into a given node
  84158. * @param node defines where to store the animation ranges
  84159. * @param parsedNode defines the serialization object to read data from
  84160. * @param scene defines the hosting scene
  84161. */
  84162. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84163. }
  84164. }
  84165. declare module BABYLON {
  84166. /**
  84167. * Class used to store any kind of animation
  84168. */
  84169. export class Animation {
  84170. /**Name of the animation */
  84171. name: string;
  84172. /**Property to animate */
  84173. targetProperty: string;
  84174. /**The frames per second of the animation */
  84175. framePerSecond: number;
  84176. /**The data type of the animation */
  84177. dataType: number;
  84178. /**The loop mode of the animation */
  84179. loopMode?: number | undefined;
  84180. /**Specifies if blending should be enabled */
  84181. enableBlending?: boolean | undefined;
  84182. /**
  84183. * Use matrix interpolation instead of using direct key value when animating matrices
  84184. */
  84185. static AllowMatricesInterpolation: boolean;
  84186. /**
  84187. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84188. */
  84189. static AllowMatrixDecomposeForInterpolation: boolean;
  84190. /**
  84191. * Stores the key frames of the animation
  84192. */
  84193. private _keys;
  84194. /**
  84195. * Stores the easing function of the animation
  84196. */
  84197. private _easingFunction;
  84198. /**
  84199. * @hidden Internal use only
  84200. */
  84201. _runtimeAnimations: RuntimeAnimation[];
  84202. /**
  84203. * The set of event that will be linked to this animation
  84204. */
  84205. private _events;
  84206. /**
  84207. * Stores an array of target property paths
  84208. */
  84209. targetPropertyPath: string[];
  84210. /**
  84211. * Stores the blending speed of the animation
  84212. */
  84213. blendingSpeed: number;
  84214. /**
  84215. * Stores the animation ranges for the animation
  84216. */
  84217. private _ranges;
  84218. /**
  84219. * @hidden Internal use
  84220. */
  84221. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84222. /**
  84223. * Sets up an animation
  84224. * @param property The property to animate
  84225. * @param animationType The animation type to apply
  84226. * @param framePerSecond The frames per second of the animation
  84227. * @param easingFunction The easing function used in the animation
  84228. * @returns The created animation
  84229. */
  84230. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84231. /**
  84232. * Create and start an animation on a node
  84233. * @param name defines the name of the global animation that will be run on all nodes
  84234. * @param node defines the root node where the animation will take place
  84235. * @param targetProperty defines property to animate
  84236. * @param framePerSecond defines the number of frame per second yo use
  84237. * @param totalFrame defines the number of frames in total
  84238. * @param from defines the initial value
  84239. * @param to defines the final value
  84240. * @param loopMode defines which loop mode you want to use (off by default)
  84241. * @param easingFunction defines the easing function to use (linear by default)
  84242. * @param onAnimationEnd defines the callback to call when animation end
  84243. * @returns the animatable created for this animation
  84244. */
  84245. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84246. /**
  84247. * Create and start an animation on a node and its descendants
  84248. * @param name defines the name of the global animation that will be run on all nodes
  84249. * @param node defines the root node where the animation will take place
  84250. * @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
  84251. * @param targetProperty defines property to animate
  84252. * @param framePerSecond defines the number of frame per second to use
  84253. * @param totalFrame defines the number of frames in total
  84254. * @param from defines the initial value
  84255. * @param to defines the final value
  84256. * @param loopMode defines which loop mode you want to use (off by default)
  84257. * @param easingFunction defines the easing function to use (linear by default)
  84258. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84259. * @returns the list of animatables created for all nodes
  84260. * @example https://www.babylonjs-playground.com/#MH0VLI
  84261. */
  84262. 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[]>;
  84263. /**
  84264. * Creates a new animation, merges it with the existing animations and starts it
  84265. * @param name Name of the animation
  84266. * @param node Node which contains the scene that begins the animations
  84267. * @param targetProperty Specifies which property to animate
  84268. * @param framePerSecond The frames per second of the animation
  84269. * @param totalFrame The total number of frames
  84270. * @param from The frame at the beginning of the animation
  84271. * @param to The frame at the end of the animation
  84272. * @param loopMode Specifies the loop mode of the animation
  84273. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84274. * @param onAnimationEnd Callback to run once the animation is complete
  84275. * @returns Nullable animation
  84276. */
  84277. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84278. /**
  84279. * Transition property of an host to the target Value
  84280. * @param property The property to transition
  84281. * @param targetValue The target Value of the property
  84282. * @param host The object where the property to animate belongs
  84283. * @param scene Scene used to run the animation
  84284. * @param frameRate Framerate (in frame/s) to use
  84285. * @param transition The transition type we want to use
  84286. * @param duration The duration of the animation, in milliseconds
  84287. * @param onAnimationEnd Callback trigger at the end of the animation
  84288. * @returns Nullable animation
  84289. */
  84290. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84291. /**
  84292. * Return the array of runtime animations currently using this animation
  84293. */
  84294. readonly runtimeAnimations: RuntimeAnimation[];
  84295. /**
  84296. * Specifies if any of the runtime animations are currently running
  84297. */
  84298. readonly hasRunningRuntimeAnimations: boolean;
  84299. /**
  84300. * Initializes the animation
  84301. * @param name Name of the animation
  84302. * @param targetProperty Property to animate
  84303. * @param framePerSecond The frames per second of the animation
  84304. * @param dataType The data type of the animation
  84305. * @param loopMode The loop mode of the animation
  84306. * @param enableBlending Specifies if blending should be enabled
  84307. */
  84308. constructor(
  84309. /**Name of the animation */
  84310. name: string,
  84311. /**Property to animate */
  84312. targetProperty: string,
  84313. /**The frames per second of the animation */
  84314. framePerSecond: number,
  84315. /**The data type of the animation */
  84316. dataType: number,
  84317. /**The loop mode of the animation */
  84318. loopMode?: number | undefined,
  84319. /**Specifies if blending should be enabled */
  84320. enableBlending?: boolean | undefined);
  84321. /**
  84322. * Converts the animation to a string
  84323. * @param fullDetails support for multiple levels of logging within scene loading
  84324. * @returns String form of the animation
  84325. */
  84326. toString(fullDetails?: boolean): string;
  84327. /**
  84328. * Add an event to this animation
  84329. * @param event Event to add
  84330. */
  84331. addEvent(event: AnimationEvent): void;
  84332. /**
  84333. * Remove all events found at the given frame
  84334. * @param frame The frame to remove events from
  84335. */
  84336. removeEvents(frame: number): void;
  84337. /**
  84338. * Retrieves all the events from the animation
  84339. * @returns Events from the animation
  84340. */
  84341. getEvents(): AnimationEvent[];
  84342. /**
  84343. * Creates an animation range
  84344. * @param name Name of the animation range
  84345. * @param from Starting frame of the animation range
  84346. * @param to Ending frame of the animation
  84347. */
  84348. createRange(name: string, from: number, to: number): void;
  84349. /**
  84350. * Deletes an animation range by name
  84351. * @param name Name of the animation range to delete
  84352. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84353. */
  84354. deleteRange(name: string, deleteFrames?: boolean): void;
  84355. /**
  84356. * Gets the animation range by name, or null if not defined
  84357. * @param name Name of the animation range
  84358. * @returns Nullable animation range
  84359. */
  84360. getRange(name: string): Nullable<AnimationRange>;
  84361. /**
  84362. * Gets the key frames from the animation
  84363. * @returns The key frames of the animation
  84364. */
  84365. getKeys(): Array<IAnimationKey>;
  84366. /**
  84367. * Gets the highest frame rate of the animation
  84368. * @returns Highest frame rate of the animation
  84369. */
  84370. getHighestFrame(): number;
  84371. /**
  84372. * Gets the easing function of the animation
  84373. * @returns Easing function of the animation
  84374. */
  84375. getEasingFunction(): IEasingFunction;
  84376. /**
  84377. * Sets the easing function of the animation
  84378. * @param easingFunction A custom mathematical formula for animation
  84379. */
  84380. setEasingFunction(easingFunction: EasingFunction): void;
  84381. /**
  84382. * Interpolates a scalar linearly
  84383. * @param startValue Start value of the animation curve
  84384. * @param endValue End value of the animation curve
  84385. * @param gradient Scalar amount to interpolate
  84386. * @returns Interpolated scalar value
  84387. */
  84388. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84389. /**
  84390. * Interpolates a scalar cubically
  84391. * @param startValue Start value of the animation curve
  84392. * @param outTangent End tangent of the animation
  84393. * @param endValue End value of the animation curve
  84394. * @param inTangent Start tangent of the animation curve
  84395. * @param gradient Scalar amount to interpolate
  84396. * @returns Interpolated scalar value
  84397. */
  84398. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84399. /**
  84400. * Interpolates a quaternion using a spherical linear interpolation
  84401. * @param startValue Start value of the animation curve
  84402. * @param endValue End value of the animation curve
  84403. * @param gradient Scalar amount to interpolate
  84404. * @returns Interpolated quaternion value
  84405. */
  84406. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84407. /**
  84408. * Interpolates a quaternion cubically
  84409. * @param startValue Start value of the animation curve
  84410. * @param outTangent End tangent of the animation curve
  84411. * @param endValue End value of the animation curve
  84412. * @param inTangent Start tangent of the animation curve
  84413. * @param gradient Scalar amount to interpolate
  84414. * @returns Interpolated quaternion value
  84415. */
  84416. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84417. /**
  84418. * Interpolates a Vector3 linearl
  84419. * @param startValue Start value of the animation curve
  84420. * @param endValue End value of the animation curve
  84421. * @param gradient Scalar amount to interpolate
  84422. * @returns Interpolated scalar value
  84423. */
  84424. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84425. /**
  84426. * Interpolates a Vector3 cubically
  84427. * @param startValue Start value of the animation curve
  84428. * @param outTangent End tangent of the animation
  84429. * @param endValue End value of the animation curve
  84430. * @param inTangent Start tangent of the animation curve
  84431. * @param gradient Scalar amount to interpolate
  84432. * @returns InterpolatedVector3 value
  84433. */
  84434. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84435. /**
  84436. * Interpolates a Vector2 linearly
  84437. * @param startValue Start value of the animation curve
  84438. * @param endValue End value of the animation curve
  84439. * @param gradient Scalar amount to interpolate
  84440. * @returns Interpolated Vector2 value
  84441. */
  84442. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84443. /**
  84444. * Interpolates a Vector2 cubically
  84445. * @param startValue Start value of the animation curve
  84446. * @param outTangent End tangent of the animation
  84447. * @param endValue End value of the animation curve
  84448. * @param inTangent Start tangent of the animation curve
  84449. * @param gradient Scalar amount to interpolate
  84450. * @returns Interpolated Vector2 value
  84451. */
  84452. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84453. /**
  84454. * Interpolates a size linearly
  84455. * @param startValue Start value of the animation curve
  84456. * @param endValue End value of the animation curve
  84457. * @param gradient Scalar amount to interpolate
  84458. * @returns Interpolated Size value
  84459. */
  84460. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84461. /**
  84462. * Interpolates a Color3 linearly
  84463. * @param startValue Start value of the animation curve
  84464. * @param endValue End value of the animation curve
  84465. * @param gradient Scalar amount to interpolate
  84466. * @returns Interpolated Color3 value
  84467. */
  84468. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84469. /**
  84470. * @hidden Internal use only
  84471. */
  84472. _getKeyValue(value: any): any;
  84473. /**
  84474. * @hidden Internal use only
  84475. */
  84476. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84477. /**
  84478. * Defines the function to use to interpolate matrices
  84479. * @param startValue defines the start matrix
  84480. * @param endValue defines the end matrix
  84481. * @param gradient defines the gradient between both matrices
  84482. * @param result defines an optional target matrix where to store the interpolation
  84483. * @returns the interpolated matrix
  84484. */
  84485. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84486. /**
  84487. * Makes a copy of the animation
  84488. * @returns Cloned animation
  84489. */
  84490. clone(): Animation;
  84491. /**
  84492. * Sets the key frames of the animation
  84493. * @param values The animation key frames to set
  84494. */
  84495. setKeys(values: Array<IAnimationKey>): void;
  84496. /**
  84497. * Serializes the animation to an object
  84498. * @returns Serialized object
  84499. */
  84500. serialize(): any;
  84501. /**
  84502. * Float animation type
  84503. */
  84504. private static _ANIMATIONTYPE_FLOAT;
  84505. /**
  84506. * Vector3 animation type
  84507. */
  84508. private static _ANIMATIONTYPE_VECTOR3;
  84509. /**
  84510. * Quaternion animation type
  84511. */
  84512. private static _ANIMATIONTYPE_QUATERNION;
  84513. /**
  84514. * Matrix animation type
  84515. */
  84516. private static _ANIMATIONTYPE_MATRIX;
  84517. /**
  84518. * Color3 animation type
  84519. */
  84520. private static _ANIMATIONTYPE_COLOR3;
  84521. /**
  84522. * Vector2 animation type
  84523. */
  84524. private static _ANIMATIONTYPE_VECTOR2;
  84525. /**
  84526. * Size animation type
  84527. */
  84528. private static _ANIMATIONTYPE_SIZE;
  84529. /**
  84530. * Relative Loop Mode
  84531. */
  84532. private static _ANIMATIONLOOPMODE_RELATIVE;
  84533. /**
  84534. * Cycle Loop Mode
  84535. */
  84536. private static _ANIMATIONLOOPMODE_CYCLE;
  84537. /**
  84538. * Constant Loop Mode
  84539. */
  84540. private static _ANIMATIONLOOPMODE_CONSTANT;
  84541. /**
  84542. * Get the float animation type
  84543. */
  84544. static readonly ANIMATIONTYPE_FLOAT: number;
  84545. /**
  84546. * Get the Vector3 animation type
  84547. */
  84548. static readonly ANIMATIONTYPE_VECTOR3: number;
  84549. /**
  84550. * Get the Vector2 animation type
  84551. */
  84552. static readonly ANIMATIONTYPE_VECTOR2: number;
  84553. /**
  84554. * Get the Size animation type
  84555. */
  84556. static readonly ANIMATIONTYPE_SIZE: number;
  84557. /**
  84558. * Get the Quaternion animation type
  84559. */
  84560. static readonly ANIMATIONTYPE_QUATERNION: number;
  84561. /**
  84562. * Get the Matrix animation type
  84563. */
  84564. static readonly ANIMATIONTYPE_MATRIX: number;
  84565. /**
  84566. * Get the Color3 animation type
  84567. */
  84568. static readonly ANIMATIONTYPE_COLOR3: number;
  84569. /**
  84570. * Get the Relative Loop Mode
  84571. */
  84572. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84573. /**
  84574. * Get the Cycle Loop Mode
  84575. */
  84576. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84577. /**
  84578. * Get the Constant Loop Mode
  84579. */
  84580. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84581. /** @hidden */
  84582. static _UniversalLerp(left: any, right: any, amount: number): any;
  84583. /**
  84584. * Parses an animation object and creates an animation
  84585. * @param parsedAnimation Parsed animation object
  84586. * @returns Animation object
  84587. */
  84588. static Parse(parsedAnimation: any): Animation;
  84589. /**
  84590. * Appends the serialized animations from the source animations
  84591. * @param source Source containing the animations
  84592. * @param destination Target to store the animations
  84593. */
  84594. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84595. }
  84596. }
  84597. declare module BABYLON {
  84598. /**
  84599. * Base class of all the textures in babylon.
  84600. * It groups all the common properties the materials, post process, lights... might need
  84601. * in order to make a correct use of the texture.
  84602. */
  84603. export class BaseTexture implements IAnimatable {
  84604. /**
  84605. * Default anisotropic filtering level for the application.
  84606. * It is set to 4 as a good tradeoff between perf and quality.
  84607. */
  84608. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84609. /**
  84610. * Gets or sets the unique id of the texture
  84611. */
  84612. uniqueId: number;
  84613. /**
  84614. * Define the name of the texture.
  84615. */
  84616. name: string;
  84617. /**
  84618. * Gets or sets an object used to store user defined information.
  84619. */
  84620. metadata: any;
  84621. /**
  84622. * For internal use only. Please do not use.
  84623. */
  84624. reservedDataStore: any;
  84625. private _hasAlpha;
  84626. /**
  84627. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84628. */
  84629. hasAlpha: boolean;
  84630. /**
  84631. * Defines if the alpha value should be determined via the rgb values.
  84632. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84633. */
  84634. getAlphaFromRGB: boolean;
  84635. /**
  84636. * Intensity or strength of the texture.
  84637. * It is commonly used by materials to fine tune the intensity of the texture
  84638. */
  84639. level: number;
  84640. /**
  84641. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84642. * This is part of the texture as textures usually maps to one uv set.
  84643. */
  84644. coordinatesIndex: number;
  84645. private _coordinatesMode;
  84646. /**
  84647. * How a texture is mapped.
  84648. *
  84649. * | Value | Type | Description |
  84650. * | ----- | ----------------------------------- | ----------- |
  84651. * | 0 | EXPLICIT_MODE | |
  84652. * | 1 | SPHERICAL_MODE | |
  84653. * | 2 | PLANAR_MODE | |
  84654. * | 3 | CUBIC_MODE | |
  84655. * | 4 | PROJECTION_MODE | |
  84656. * | 5 | SKYBOX_MODE | |
  84657. * | 6 | INVCUBIC_MODE | |
  84658. * | 7 | EQUIRECTANGULAR_MODE | |
  84659. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84660. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84661. */
  84662. coordinatesMode: number;
  84663. /**
  84664. * | Value | Type | Description |
  84665. * | ----- | ------------------ | ----------- |
  84666. * | 0 | CLAMP_ADDRESSMODE | |
  84667. * | 1 | WRAP_ADDRESSMODE | |
  84668. * | 2 | MIRROR_ADDRESSMODE | |
  84669. */
  84670. wrapU: number;
  84671. /**
  84672. * | Value | Type | Description |
  84673. * | ----- | ------------------ | ----------- |
  84674. * | 0 | CLAMP_ADDRESSMODE | |
  84675. * | 1 | WRAP_ADDRESSMODE | |
  84676. * | 2 | MIRROR_ADDRESSMODE | |
  84677. */
  84678. wrapV: number;
  84679. /**
  84680. * | Value | Type | Description |
  84681. * | ----- | ------------------ | ----------- |
  84682. * | 0 | CLAMP_ADDRESSMODE | |
  84683. * | 1 | WRAP_ADDRESSMODE | |
  84684. * | 2 | MIRROR_ADDRESSMODE | |
  84685. */
  84686. wrapR: number;
  84687. /**
  84688. * With compliant hardware and browser (supporting anisotropic filtering)
  84689. * this defines the level of anisotropic filtering in the texture.
  84690. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84691. */
  84692. anisotropicFilteringLevel: number;
  84693. /**
  84694. * Define if the texture is a cube texture or if false a 2d texture.
  84695. */
  84696. isCube: boolean;
  84697. /**
  84698. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84699. */
  84700. is3D: boolean;
  84701. /**
  84702. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84703. * HDR texture are usually stored in linear space.
  84704. * This only impacts the PBR and Background materials
  84705. */
  84706. gammaSpace: boolean;
  84707. /**
  84708. * Gets whether or not the texture contains RGBD data.
  84709. */
  84710. readonly isRGBD: boolean;
  84711. /**
  84712. * Is Z inverted in the texture (useful in a cube texture).
  84713. */
  84714. invertZ: boolean;
  84715. /**
  84716. * Are mip maps generated for this texture or not.
  84717. */
  84718. readonly noMipmap: boolean;
  84719. /**
  84720. * @hidden
  84721. */
  84722. lodLevelInAlpha: boolean;
  84723. /**
  84724. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84725. */
  84726. lodGenerationOffset: number;
  84727. /**
  84728. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84729. */
  84730. lodGenerationScale: number;
  84731. /**
  84732. * Define if the texture is a render target.
  84733. */
  84734. isRenderTarget: boolean;
  84735. /**
  84736. * Define the unique id of the texture in the scene.
  84737. */
  84738. readonly uid: string;
  84739. /**
  84740. * Return a string representation of the texture.
  84741. * @returns the texture as a string
  84742. */
  84743. toString(): string;
  84744. /**
  84745. * Get the class name of the texture.
  84746. * @returns "BaseTexture"
  84747. */
  84748. getClassName(): string;
  84749. /**
  84750. * Define the list of animation attached to the texture.
  84751. */
  84752. animations: Animation[];
  84753. /**
  84754. * An event triggered when the texture is disposed.
  84755. */
  84756. onDisposeObservable: Observable<BaseTexture>;
  84757. private _onDisposeObserver;
  84758. /**
  84759. * Callback triggered when the texture has been disposed.
  84760. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84761. */
  84762. onDispose: () => void;
  84763. /**
  84764. * Define the current state of the loading sequence when in delayed load mode.
  84765. */
  84766. delayLoadState: number;
  84767. private _scene;
  84768. /** @hidden */
  84769. _texture: Nullable<InternalTexture>;
  84770. private _uid;
  84771. /**
  84772. * Define if the texture is preventinga material to render or not.
  84773. * If not and the texture is not ready, the engine will use a default black texture instead.
  84774. */
  84775. readonly isBlocking: boolean;
  84776. /**
  84777. * Instantiates a new BaseTexture.
  84778. * Base class of all the textures in babylon.
  84779. * It groups all the common properties the materials, post process, lights... might need
  84780. * in order to make a correct use of the texture.
  84781. * @param scene Define the scene the texture blongs to
  84782. */
  84783. constructor(scene: Nullable<Scene>);
  84784. /**
  84785. * Get the scene the texture belongs to.
  84786. * @returns the scene or null if undefined
  84787. */
  84788. getScene(): Nullable<Scene>;
  84789. /**
  84790. * Get the texture transform matrix used to offset tile the texture for istance.
  84791. * @returns the transformation matrix
  84792. */
  84793. getTextureMatrix(): Matrix;
  84794. /**
  84795. * Get the texture reflection matrix used to rotate/transform the reflection.
  84796. * @returns the reflection matrix
  84797. */
  84798. getReflectionTextureMatrix(): Matrix;
  84799. /**
  84800. * Get the underlying lower level texture from Babylon.
  84801. * @returns the insternal texture
  84802. */
  84803. getInternalTexture(): Nullable<InternalTexture>;
  84804. /**
  84805. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84806. * @returns true if ready or not blocking
  84807. */
  84808. isReadyOrNotBlocking(): boolean;
  84809. /**
  84810. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84811. * @returns true if fully ready
  84812. */
  84813. isReady(): boolean;
  84814. private _cachedSize;
  84815. /**
  84816. * Get the size of the texture.
  84817. * @returns the texture size.
  84818. */
  84819. getSize(): ISize;
  84820. /**
  84821. * Get the base size of the texture.
  84822. * It can be different from the size if the texture has been resized for POT for instance
  84823. * @returns the base size
  84824. */
  84825. getBaseSize(): ISize;
  84826. /**
  84827. * Update the sampling mode of the texture.
  84828. * Default is Trilinear mode.
  84829. *
  84830. * | Value | Type | Description |
  84831. * | ----- | ------------------ | ----------- |
  84832. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84833. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84834. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84835. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84836. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84837. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84838. * | 7 | NEAREST_LINEAR | |
  84839. * | 8 | NEAREST_NEAREST | |
  84840. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84841. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84842. * | 11 | LINEAR_LINEAR | |
  84843. * | 12 | LINEAR_NEAREST | |
  84844. *
  84845. * > _mag_: magnification filter (close to the viewer)
  84846. * > _min_: minification filter (far from the viewer)
  84847. * > _mip_: filter used between mip map levels
  84848. *@param samplingMode Define the new sampling mode of the texture
  84849. */
  84850. updateSamplingMode(samplingMode: number): void;
  84851. /**
  84852. * Scales the texture if is `canRescale()`
  84853. * @param ratio the resize factor we want to use to rescale
  84854. */
  84855. scale(ratio: number): void;
  84856. /**
  84857. * Get if the texture can rescale.
  84858. */
  84859. readonly canRescale: boolean;
  84860. /** @hidden */
  84861. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84862. /** @hidden */
  84863. _rebuild(): void;
  84864. /**
  84865. * Triggers the load sequence in delayed load mode.
  84866. */
  84867. delayLoad(): void;
  84868. /**
  84869. * Clones the texture.
  84870. * @returns the cloned texture
  84871. */
  84872. clone(): Nullable<BaseTexture>;
  84873. /**
  84874. * Get the texture underlying type (INT, FLOAT...)
  84875. */
  84876. readonly textureType: number;
  84877. /**
  84878. * Get the texture underlying format (RGB, RGBA...)
  84879. */
  84880. readonly textureFormat: number;
  84881. /**
  84882. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84883. * This will returns an RGBA array buffer containing either in values (0-255) or
  84884. * float values (0-1) depending of the underlying buffer type.
  84885. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84886. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84887. * @param buffer defines a user defined buffer to fill with data (can be null)
  84888. * @returns The Array buffer containing the pixels data.
  84889. */
  84890. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84891. /**
  84892. * Release and destroy the underlying lower level texture aka internalTexture.
  84893. */
  84894. releaseInternalTexture(): void;
  84895. /**
  84896. * Get the polynomial representation of the texture data.
  84897. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84898. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84899. */
  84900. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84901. /** @hidden */
  84902. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84903. /** @hidden */
  84904. readonly _lodTextureMid: Nullable<BaseTexture>;
  84905. /** @hidden */
  84906. readonly _lodTextureLow: Nullable<BaseTexture>;
  84907. /**
  84908. * Dispose the texture and release its associated resources.
  84909. */
  84910. dispose(): void;
  84911. /**
  84912. * Serialize the texture into a JSON representation that can be parsed later on.
  84913. * @returns the JSON representation of the texture
  84914. */
  84915. serialize(): any;
  84916. /**
  84917. * Helper function to be called back once a list of texture contains only ready textures.
  84918. * @param textures Define the list of textures to wait for
  84919. * @param callback Define the callback triggered once the entire list will be ready
  84920. */
  84921. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84922. }
  84923. }
  84924. declare module BABYLON {
  84925. /**
  84926. * Uniform buffer objects.
  84927. *
  84928. * Handles blocks of uniform on the GPU.
  84929. *
  84930. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84931. *
  84932. * For more information, please refer to :
  84933. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84934. */
  84935. export class UniformBuffer {
  84936. private _engine;
  84937. private _buffer;
  84938. private _data;
  84939. private _bufferData;
  84940. private _dynamic?;
  84941. private _uniformLocations;
  84942. private _uniformSizes;
  84943. private _uniformLocationPointer;
  84944. private _needSync;
  84945. private _noUBO;
  84946. private _currentEffect;
  84947. private static _MAX_UNIFORM_SIZE;
  84948. private static _tempBuffer;
  84949. /**
  84950. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84951. * This is dynamic to allow compat with webgl 1 and 2.
  84952. * You will need to pass the name of the uniform as well as the value.
  84953. */
  84954. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84955. /**
  84956. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84957. * This is dynamic to allow compat with webgl 1 and 2.
  84958. * You will need to pass the name of the uniform as well as the value.
  84959. */
  84960. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84961. /**
  84962. * Lambda to Update a single float in a uniform buffer.
  84963. * This is dynamic to allow compat with webgl 1 and 2.
  84964. * You will need to pass the name of the uniform as well as the value.
  84965. */
  84966. updateFloat: (name: string, x: number) => void;
  84967. /**
  84968. * Lambda to Update a vec2 of float in a uniform buffer.
  84969. * This is dynamic to allow compat with webgl 1 and 2.
  84970. * You will need to pass the name of the uniform as well as the value.
  84971. */
  84972. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84973. /**
  84974. * Lambda to Update a vec3 of float in a uniform buffer.
  84975. * This is dynamic to allow compat with webgl 1 and 2.
  84976. * You will need to pass the name of the uniform as well as the value.
  84977. */
  84978. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84979. /**
  84980. * Lambda to Update a vec4 of float in a uniform buffer.
  84981. * This is dynamic to allow compat with webgl 1 and 2.
  84982. * You will need to pass the name of the uniform as well as the value.
  84983. */
  84984. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84985. /**
  84986. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84987. * This is dynamic to allow compat with webgl 1 and 2.
  84988. * You will need to pass the name of the uniform as well as the value.
  84989. */
  84990. updateMatrix: (name: string, mat: Matrix) => void;
  84991. /**
  84992. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84993. * This is dynamic to allow compat with webgl 1 and 2.
  84994. * You will need to pass the name of the uniform as well as the value.
  84995. */
  84996. updateVector3: (name: string, vector: Vector3) => void;
  84997. /**
  84998. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84999. * This is dynamic to allow compat with webgl 1 and 2.
  85000. * You will need to pass the name of the uniform as well as the value.
  85001. */
  85002. updateVector4: (name: string, vector: Vector4) => void;
  85003. /**
  85004. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85005. * This is dynamic to allow compat with webgl 1 and 2.
  85006. * You will need to pass the name of the uniform as well as the value.
  85007. */
  85008. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85009. /**
  85010. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85011. * This is dynamic to allow compat with webgl 1 and 2.
  85012. * You will need to pass the name of the uniform as well as the value.
  85013. */
  85014. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85015. /**
  85016. * Instantiates a new Uniform buffer objects.
  85017. *
  85018. * Handles blocks of uniform on the GPU.
  85019. *
  85020. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85021. *
  85022. * For more information, please refer to :
  85023. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85024. * @param engine Define the engine the buffer is associated with
  85025. * @param data Define the data contained in the buffer
  85026. * @param dynamic Define if the buffer is updatable
  85027. */
  85028. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85029. /**
  85030. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85031. * or just falling back on setUniformXXX calls.
  85032. */
  85033. readonly useUbo: boolean;
  85034. /**
  85035. * Indicates if the WebGL underlying uniform buffer is in sync
  85036. * with the javascript cache data.
  85037. */
  85038. readonly isSync: boolean;
  85039. /**
  85040. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85041. * Also, a dynamic UniformBuffer will disable cache verification and always
  85042. * update the underlying WebGL uniform buffer to the GPU.
  85043. * @returns if Dynamic, otherwise false
  85044. */
  85045. isDynamic(): boolean;
  85046. /**
  85047. * The data cache on JS side.
  85048. * @returns the underlying data as a float array
  85049. */
  85050. getData(): Float32Array;
  85051. /**
  85052. * The underlying WebGL Uniform buffer.
  85053. * @returns the webgl buffer
  85054. */
  85055. getBuffer(): Nullable<WebGLBuffer>;
  85056. /**
  85057. * std140 layout specifies how to align data within an UBO structure.
  85058. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85059. * for specs.
  85060. */
  85061. private _fillAlignment;
  85062. /**
  85063. * Adds an uniform in the buffer.
  85064. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85065. * for the layout to be correct !
  85066. * @param name Name of the uniform, as used in the uniform block in the shader.
  85067. * @param size Data size, or data directly.
  85068. */
  85069. addUniform(name: string, size: number | number[]): void;
  85070. /**
  85071. * Adds a Matrix 4x4 to the uniform buffer.
  85072. * @param name Name of the uniform, as used in the uniform block in the shader.
  85073. * @param mat A 4x4 matrix.
  85074. */
  85075. addMatrix(name: string, mat: Matrix): void;
  85076. /**
  85077. * Adds a vec2 to the uniform buffer.
  85078. * @param name Name of the uniform, as used in the uniform block in the shader.
  85079. * @param x Define the x component value of the vec2
  85080. * @param y Define the y component value of the vec2
  85081. */
  85082. addFloat2(name: string, x: number, y: number): void;
  85083. /**
  85084. * Adds a vec3 to the uniform buffer.
  85085. * @param name Name of the uniform, as used in the uniform block in the shader.
  85086. * @param x Define the x component value of the vec3
  85087. * @param y Define the y component value of the vec3
  85088. * @param z Define the z component value of the vec3
  85089. */
  85090. addFloat3(name: string, x: number, y: number, z: number): void;
  85091. /**
  85092. * Adds a vec3 to the uniform buffer.
  85093. * @param name Name of the uniform, as used in the uniform block in the shader.
  85094. * @param color Define the vec3 from a Color
  85095. */
  85096. addColor3(name: string, color: Color3): void;
  85097. /**
  85098. * Adds a vec4 to the uniform buffer.
  85099. * @param name Name of the uniform, as used in the uniform block in the shader.
  85100. * @param color Define the rgb components from a Color
  85101. * @param alpha Define the a component of the vec4
  85102. */
  85103. addColor4(name: string, color: Color3, alpha: number): void;
  85104. /**
  85105. * Adds a vec3 to the uniform buffer.
  85106. * @param name Name of the uniform, as used in the uniform block in the shader.
  85107. * @param vector Define the vec3 components from a Vector
  85108. */
  85109. addVector3(name: string, vector: Vector3): void;
  85110. /**
  85111. * Adds a Matrix 3x3 to the uniform buffer.
  85112. * @param name Name of the uniform, as used in the uniform block in the shader.
  85113. */
  85114. addMatrix3x3(name: string): void;
  85115. /**
  85116. * Adds a Matrix 2x2 to the uniform buffer.
  85117. * @param name Name of the uniform, as used in the uniform block in the shader.
  85118. */
  85119. addMatrix2x2(name: string): void;
  85120. /**
  85121. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85122. */
  85123. create(): void;
  85124. /** @hidden */
  85125. _rebuild(): void;
  85126. /**
  85127. * Updates the WebGL Uniform Buffer on the GPU.
  85128. * If the `dynamic` flag is set to true, no cache comparison is done.
  85129. * Otherwise, the buffer will be updated only if the cache differs.
  85130. */
  85131. update(): void;
  85132. /**
  85133. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85134. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85135. * @param data Define the flattened data
  85136. * @param size Define the size of the data.
  85137. */
  85138. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85139. private _updateMatrix3x3ForUniform;
  85140. private _updateMatrix3x3ForEffect;
  85141. private _updateMatrix2x2ForEffect;
  85142. private _updateMatrix2x2ForUniform;
  85143. private _updateFloatForEffect;
  85144. private _updateFloatForUniform;
  85145. private _updateFloat2ForEffect;
  85146. private _updateFloat2ForUniform;
  85147. private _updateFloat3ForEffect;
  85148. private _updateFloat3ForUniform;
  85149. private _updateFloat4ForEffect;
  85150. private _updateFloat4ForUniform;
  85151. private _updateMatrixForEffect;
  85152. private _updateMatrixForUniform;
  85153. private _updateVector3ForEffect;
  85154. private _updateVector3ForUniform;
  85155. private _updateVector4ForEffect;
  85156. private _updateVector4ForUniform;
  85157. private _updateColor3ForEffect;
  85158. private _updateColor3ForUniform;
  85159. private _updateColor4ForEffect;
  85160. private _updateColor4ForUniform;
  85161. /**
  85162. * Sets a sampler uniform on the effect.
  85163. * @param name Define the name of the sampler.
  85164. * @param texture Define the texture to set in the sampler
  85165. */
  85166. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85167. /**
  85168. * Directly updates the value of the uniform in the cache AND on the GPU.
  85169. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85170. * @param data Define the flattened data
  85171. */
  85172. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85173. /**
  85174. * Binds this uniform buffer to an effect.
  85175. * @param effect Define the effect to bind the buffer to
  85176. * @param name Name of the uniform block in the shader.
  85177. */
  85178. bindToEffect(effect: Effect, name: string): void;
  85179. /**
  85180. * Disposes the uniform buffer.
  85181. */
  85182. dispose(): void;
  85183. }
  85184. }
  85185. declare module BABYLON {
  85186. /**
  85187. * This represents the required contract to create a new type of texture loader.
  85188. */
  85189. export interface IInternalTextureLoader {
  85190. /**
  85191. * Defines wether the loader supports cascade loading the different faces.
  85192. */
  85193. supportCascades: boolean;
  85194. /**
  85195. * This returns if the loader support the current file information.
  85196. * @param extension defines the file extension of the file being loaded
  85197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85198. * @param fallback defines the fallback internal texture if any
  85199. * @param isBase64 defines whether the texture is encoded as a base64
  85200. * @param isBuffer defines whether the texture data are stored as a buffer
  85201. * @returns true if the loader can load the specified file
  85202. */
  85203. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85204. /**
  85205. * Transform the url before loading if required.
  85206. * @param rootUrl the url of the texture
  85207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85208. * @returns the transformed texture
  85209. */
  85210. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85211. /**
  85212. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85213. * @param rootUrl the url of the texture
  85214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85215. * @returns the fallback texture
  85216. */
  85217. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85218. /**
  85219. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85220. * @param data contains the texture data
  85221. * @param texture defines the BabylonJS internal texture
  85222. * @param createPolynomials will be true if polynomials have been requested
  85223. * @param onLoad defines the callback to trigger once the texture is ready
  85224. * @param onError defines the callback to trigger in case of error
  85225. */
  85226. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85227. /**
  85228. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85229. * @param data contains the texture data
  85230. * @param texture defines the BabylonJS internal texture
  85231. * @param callback defines the method to call once ready to upload
  85232. */
  85233. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85234. }
  85235. }
  85236. declare module BABYLON {
  85237. /**
  85238. * Creation options of the multi render target texture.
  85239. */
  85240. export interface IMultiRenderTargetOptions {
  85241. /**
  85242. * Define if the texture needs to create mip maps after render.
  85243. */
  85244. generateMipMaps?: boolean;
  85245. /**
  85246. * Define the types of all the draw buffers we want to create
  85247. */
  85248. types?: number[];
  85249. /**
  85250. * Define the sampling modes of all the draw buffers we want to create
  85251. */
  85252. samplingModes?: number[];
  85253. /**
  85254. * Define if a depth buffer is required
  85255. */
  85256. generateDepthBuffer?: boolean;
  85257. /**
  85258. * Define if a stencil buffer is required
  85259. */
  85260. generateStencilBuffer?: boolean;
  85261. /**
  85262. * Define if a depth texture is required instead of a depth buffer
  85263. */
  85264. generateDepthTexture?: boolean;
  85265. /**
  85266. * Define the number of desired draw buffers
  85267. */
  85268. textureCount?: number;
  85269. /**
  85270. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85271. */
  85272. doNotChangeAspectRatio?: boolean;
  85273. /**
  85274. * Define the default type of the buffers we are creating
  85275. */
  85276. defaultType?: number;
  85277. }
  85278. /**
  85279. * A multi render target, like a render target provides the ability to render to a texture.
  85280. * Unlike the render target, it can render to several draw buffers in one draw.
  85281. * This is specially interesting in deferred rendering or for any effects requiring more than
  85282. * just one color from a single pass.
  85283. */
  85284. export class MultiRenderTarget extends RenderTargetTexture {
  85285. private _internalTextures;
  85286. private _textures;
  85287. private _multiRenderTargetOptions;
  85288. /**
  85289. * Get if draw buffers are currently supported by the used hardware and browser.
  85290. */
  85291. readonly isSupported: boolean;
  85292. /**
  85293. * Get the list of textures generated by the multi render target.
  85294. */
  85295. readonly textures: Texture[];
  85296. /**
  85297. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85298. */
  85299. readonly depthTexture: Texture;
  85300. /**
  85301. * Set the wrapping mode on U of all the textures we are rendering to.
  85302. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85303. */
  85304. wrapU: number;
  85305. /**
  85306. * Set the wrapping mode on V of all the textures we are rendering to.
  85307. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85308. */
  85309. wrapV: number;
  85310. /**
  85311. * Instantiate a new multi render target texture.
  85312. * A multi render target, like a render target provides the ability to render to a texture.
  85313. * Unlike the render target, it can render to several draw buffers in one draw.
  85314. * This is specially interesting in deferred rendering or for any effects requiring more than
  85315. * just one color from a single pass.
  85316. * @param name Define the name of the texture
  85317. * @param size Define the size of the buffers to render to
  85318. * @param count Define the number of target we are rendering into
  85319. * @param scene Define the scene the texture belongs to
  85320. * @param options Define the options used to create the multi render target
  85321. */
  85322. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85323. /** @hidden */
  85324. _rebuild(): void;
  85325. private _createInternalTextures;
  85326. private _createTextures;
  85327. /**
  85328. * Define the number of samples used if MSAA is enabled.
  85329. */
  85330. samples: number;
  85331. /**
  85332. * Resize all the textures in the multi render target.
  85333. * Be carrefull as it will recreate all the data in the new texture.
  85334. * @param size Define the new size
  85335. */
  85336. resize(size: any): void;
  85337. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85338. /**
  85339. * Dispose the render targets and their associated resources
  85340. */
  85341. dispose(): void;
  85342. /**
  85343. * Release all the underlying texture used as draw buffers.
  85344. */
  85345. releaseInternalTextures(): void;
  85346. }
  85347. }
  85348. declare module BABYLON {
  85349. /**
  85350. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85352. */
  85353. export class Analyser {
  85354. /**
  85355. * Gets or sets the smoothing
  85356. * @ignorenaming
  85357. */
  85358. SMOOTHING: number;
  85359. /**
  85360. * Gets or sets the FFT table size
  85361. * @ignorenaming
  85362. */
  85363. FFT_SIZE: number;
  85364. /**
  85365. * Gets or sets the bar graph amplitude
  85366. * @ignorenaming
  85367. */
  85368. BARGRAPHAMPLITUDE: number;
  85369. /**
  85370. * Gets or sets the position of the debug canvas
  85371. * @ignorenaming
  85372. */
  85373. DEBUGCANVASPOS: {
  85374. x: number;
  85375. y: number;
  85376. };
  85377. /**
  85378. * Gets or sets the debug canvas size
  85379. * @ignorenaming
  85380. */
  85381. DEBUGCANVASSIZE: {
  85382. width: number;
  85383. height: number;
  85384. };
  85385. private _byteFreqs;
  85386. private _byteTime;
  85387. private _floatFreqs;
  85388. private _webAudioAnalyser;
  85389. private _debugCanvas;
  85390. private _debugCanvasContext;
  85391. private _scene;
  85392. private _registerFunc;
  85393. private _audioEngine;
  85394. /**
  85395. * Creates a new analyser
  85396. * @param scene defines hosting scene
  85397. */
  85398. constructor(scene: Scene);
  85399. /**
  85400. * Get the number of data values you will have to play with for the visualization
  85401. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85402. * @returns a number
  85403. */
  85404. getFrequencyBinCount(): number;
  85405. /**
  85406. * Gets the current frequency data as a byte array
  85407. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85408. * @returns a Uint8Array
  85409. */
  85410. getByteFrequencyData(): Uint8Array;
  85411. /**
  85412. * Gets the current waveform as a byte array
  85413. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85414. * @returns a Uint8Array
  85415. */
  85416. getByteTimeDomainData(): Uint8Array;
  85417. /**
  85418. * Gets the current frequency data as a float array
  85419. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85420. * @returns a Float32Array
  85421. */
  85422. getFloatFrequencyData(): Float32Array;
  85423. /**
  85424. * Renders the debug canvas
  85425. */
  85426. drawDebugCanvas(): void;
  85427. /**
  85428. * Stops rendering the debug canvas and removes it
  85429. */
  85430. stopDebugCanvas(): void;
  85431. /**
  85432. * Connects two audio nodes
  85433. * @param inputAudioNode defines first node to connect
  85434. * @param outputAudioNode defines second node to connect
  85435. */
  85436. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85437. /**
  85438. * Releases all associated resources
  85439. */
  85440. dispose(): void;
  85441. }
  85442. }
  85443. declare module BABYLON {
  85444. /**
  85445. * This represents an audio engine and it is responsible
  85446. * to play, synchronize and analyse sounds throughout the application.
  85447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85448. */
  85449. export interface IAudioEngine extends IDisposable {
  85450. /**
  85451. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85452. */
  85453. readonly canUseWebAudio: boolean;
  85454. /**
  85455. * Gets the current AudioContext if available.
  85456. */
  85457. readonly audioContext: Nullable<AudioContext>;
  85458. /**
  85459. * The master gain node defines the global audio volume of your audio engine.
  85460. */
  85461. readonly masterGain: GainNode;
  85462. /**
  85463. * Gets whether or not mp3 are supported by your browser.
  85464. */
  85465. readonly isMP3supported: boolean;
  85466. /**
  85467. * Gets whether or not ogg are supported by your browser.
  85468. */
  85469. readonly isOGGsupported: boolean;
  85470. /**
  85471. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85472. * @ignoreNaming
  85473. */
  85474. WarnedWebAudioUnsupported: boolean;
  85475. /**
  85476. * Defines if the audio engine relies on a custom unlocked button.
  85477. * In this case, the embedded button will not be displayed.
  85478. */
  85479. useCustomUnlockedButton: boolean;
  85480. /**
  85481. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85482. */
  85483. readonly unlocked: boolean;
  85484. /**
  85485. * Event raised when audio has been unlocked on the browser.
  85486. */
  85487. onAudioUnlockedObservable: Observable<AudioEngine>;
  85488. /**
  85489. * Event raised when audio has been locked on the browser.
  85490. */
  85491. onAudioLockedObservable: Observable<AudioEngine>;
  85492. /**
  85493. * Flags the audio engine in Locked state.
  85494. * This happens due to new browser policies preventing audio to autoplay.
  85495. */
  85496. lock(): void;
  85497. /**
  85498. * Unlocks the audio engine once a user action has been done on the dom.
  85499. * This is helpful to resume play once browser policies have been satisfied.
  85500. */
  85501. unlock(): void;
  85502. }
  85503. /**
  85504. * This represents the default audio engine used in babylon.
  85505. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85507. */
  85508. export class AudioEngine implements IAudioEngine {
  85509. private _audioContext;
  85510. private _audioContextInitialized;
  85511. private _muteButton;
  85512. private _hostElement;
  85513. /**
  85514. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85515. */
  85516. canUseWebAudio: boolean;
  85517. /**
  85518. * The master gain node defines the global audio volume of your audio engine.
  85519. */
  85520. masterGain: GainNode;
  85521. /**
  85522. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85523. * @ignoreNaming
  85524. */
  85525. WarnedWebAudioUnsupported: boolean;
  85526. /**
  85527. * Gets whether or not mp3 are supported by your browser.
  85528. */
  85529. isMP3supported: boolean;
  85530. /**
  85531. * Gets whether or not ogg are supported by your browser.
  85532. */
  85533. isOGGsupported: boolean;
  85534. /**
  85535. * Gets whether audio has been unlocked on the device.
  85536. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85537. * a user interaction has happened.
  85538. */
  85539. unlocked: boolean;
  85540. /**
  85541. * Defines if the audio engine relies on a custom unlocked button.
  85542. * In this case, the embedded button will not be displayed.
  85543. */
  85544. useCustomUnlockedButton: boolean;
  85545. /**
  85546. * Event raised when audio has been unlocked on the browser.
  85547. */
  85548. onAudioUnlockedObservable: Observable<AudioEngine>;
  85549. /**
  85550. * Event raised when audio has been locked on the browser.
  85551. */
  85552. onAudioLockedObservable: Observable<AudioEngine>;
  85553. /**
  85554. * Gets the current AudioContext if available.
  85555. */
  85556. readonly audioContext: Nullable<AudioContext>;
  85557. private _connectedAnalyser;
  85558. /**
  85559. * Instantiates a new audio engine.
  85560. *
  85561. * There should be only one per page as some browsers restrict the number
  85562. * of audio contexts you can create.
  85563. * @param hostElement defines the host element where to display the mute icon if necessary
  85564. */
  85565. constructor(hostElement?: Nullable<HTMLElement>);
  85566. /**
  85567. * Flags the audio engine in Locked state.
  85568. * This happens due to new browser policies preventing audio to autoplay.
  85569. */
  85570. lock(): void;
  85571. /**
  85572. * Unlocks the audio engine once a user action has been done on the dom.
  85573. * This is helpful to resume play once browser policies have been satisfied.
  85574. */
  85575. unlock(): void;
  85576. private _resumeAudioContext;
  85577. private _initializeAudioContext;
  85578. private _tryToRun;
  85579. private _triggerRunningState;
  85580. private _triggerSuspendedState;
  85581. private _displayMuteButton;
  85582. private _moveButtonToTopLeft;
  85583. private _onResize;
  85584. private _hideMuteButton;
  85585. /**
  85586. * Destroy and release the resources associated with the audio ccontext.
  85587. */
  85588. dispose(): void;
  85589. /**
  85590. * Gets the global volume sets on the master gain.
  85591. * @returns the global volume if set or -1 otherwise
  85592. */
  85593. getGlobalVolume(): number;
  85594. /**
  85595. * Sets the global volume of your experience (sets on the master gain).
  85596. * @param newVolume Defines the new global volume of the application
  85597. */
  85598. setGlobalVolume(newVolume: number): void;
  85599. /**
  85600. * Connect the audio engine to an audio analyser allowing some amazing
  85601. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85603. * @param analyser The analyser to connect to the engine
  85604. */
  85605. connectToAnalyser(analyser: Analyser): void;
  85606. }
  85607. }
  85608. declare module BABYLON {
  85609. /**
  85610. * Interface used to present a loading screen while loading a scene
  85611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85612. */
  85613. export interface ILoadingScreen {
  85614. /**
  85615. * Function called to display the loading screen
  85616. */
  85617. displayLoadingUI: () => void;
  85618. /**
  85619. * Function called to hide the loading screen
  85620. */
  85621. hideLoadingUI: () => void;
  85622. /**
  85623. * Gets or sets the color to use for the background
  85624. */
  85625. loadingUIBackgroundColor: string;
  85626. /**
  85627. * Gets or sets the text to display while loading
  85628. */
  85629. loadingUIText: string;
  85630. }
  85631. /**
  85632. * Class used for the default loading screen
  85633. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85634. */
  85635. export class DefaultLoadingScreen implements ILoadingScreen {
  85636. private _renderingCanvas;
  85637. private _loadingText;
  85638. private _loadingDivBackgroundColor;
  85639. private _loadingDiv;
  85640. private _loadingTextDiv;
  85641. /**
  85642. * Creates a new default loading screen
  85643. * @param _renderingCanvas defines the canvas used to render the scene
  85644. * @param _loadingText defines the default text to display
  85645. * @param _loadingDivBackgroundColor defines the default background color
  85646. */
  85647. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85648. /**
  85649. * Function called to display the loading screen
  85650. */
  85651. displayLoadingUI(): void;
  85652. /**
  85653. * Function called to hide the loading screen
  85654. */
  85655. hideLoadingUI(): void;
  85656. /**
  85657. * Gets or sets the text to display while loading
  85658. */
  85659. loadingUIText: string;
  85660. /**
  85661. * Gets or sets the color to use for the background
  85662. */
  85663. loadingUIBackgroundColor: string;
  85664. private _resizeLoadingUI;
  85665. }
  85666. }
  85667. declare module BABYLON {
  85668. /**
  85669. * Settings for finer control over video usage
  85670. */
  85671. export interface VideoTextureSettings {
  85672. /**
  85673. * Applies `autoplay` to video, if specified
  85674. */
  85675. autoPlay?: boolean;
  85676. /**
  85677. * Applies `loop` to video, if specified
  85678. */
  85679. loop?: boolean;
  85680. /**
  85681. * Automatically updates internal texture from video at every frame in the render loop
  85682. */
  85683. autoUpdateTexture: boolean;
  85684. /**
  85685. * Image src displayed during the video loading or until the user interacts with the video.
  85686. */
  85687. poster?: string;
  85688. }
  85689. /**
  85690. * If you want to display a video in your scene, this is the special texture for that.
  85691. * This special texture works similar to other textures, with the exception of a few parameters.
  85692. * @see https://doc.babylonjs.com/how_to/video_texture
  85693. */
  85694. export class VideoTexture extends Texture {
  85695. /**
  85696. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85697. */
  85698. readonly autoUpdateTexture: boolean;
  85699. /**
  85700. * The video instance used by the texture internally
  85701. */
  85702. readonly video: HTMLVideoElement;
  85703. private _onUserActionRequestedObservable;
  85704. /**
  85705. * Event triggerd when a dom action is required by the user to play the video.
  85706. * This happens due to recent changes in browser policies preventing video to auto start.
  85707. */
  85708. readonly onUserActionRequestedObservable: Observable<Texture>;
  85709. private _generateMipMaps;
  85710. private _engine;
  85711. private _stillImageCaptured;
  85712. private _displayingPosterTexture;
  85713. private _settings;
  85714. private _createInternalTextureOnEvent;
  85715. /**
  85716. * Creates a video texture.
  85717. * If you want to display a video in your scene, this is the special texture for that.
  85718. * This special texture works similar to other textures, with the exception of a few parameters.
  85719. * @see https://doc.babylonjs.com/how_to/video_texture
  85720. * @param name optional name, will detect from video source, if not defined
  85721. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85722. * @param scene is obviously the current scene.
  85723. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85724. * @param invertY is false by default but can be used to invert video on Y axis
  85725. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85726. * @param settings allows finer control over video usage
  85727. */
  85728. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85729. private _getName;
  85730. private _getVideo;
  85731. private _createInternalTexture;
  85732. private reset;
  85733. /**
  85734. * @hidden Internal method to initiate `update`.
  85735. */
  85736. _rebuild(): void;
  85737. /**
  85738. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85739. */
  85740. update(): void;
  85741. /**
  85742. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85743. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85744. */
  85745. updateTexture(isVisible: boolean): void;
  85746. protected _updateInternalTexture: () => void;
  85747. /**
  85748. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85749. * @param url New url.
  85750. */
  85751. updateURL(url: string): void;
  85752. /**
  85753. * Dispose the texture and release its associated resources.
  85754. */
  85755. dispose(): void;
  85756. /**
  85757. * Creates a video texture straight from a stream.
  85758. * @param scene Define the scene the texture should be created in
  85759. * @param stream Define the stream the texture should be created from
  85760. * @returns The created video texture as a promise
  85761. */
  85762. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85763. /**
  85764. * Creates a video texture straight from your WebCam video feed.
  85765. * @param scene Define the scene the texture should be created in
  85766. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85767. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85768. * @returns The created video texture as a promise
  85769. */
  85770. static CreateFromWebCamAsync(scene: Scene, constraints: {
  85771. minWidth: number;
  85772. maxWidth: number;
  85773. minHeight: number;
  85774. maxHeight: number;
  85775. deviceId: string;
  85776. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  85777. /**
  85778. * Creates a video texture straight from your WebCam video feed.
  85779. * @param scene Define the scene the texture should be created in
  85780. * @param onReady Define a callback to triggered once the texture will be ready
  85781. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85782. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85783. */
  85784. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85785. minWidth: number;
  85786. maxWidth: number;
  85787. minHeight: number;
  85788. maxHeight: number;
  85789. deviceId: string;
  85790. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85791. }
  85792. }
  85793. declare module BABYLON {
  85794. /**
  85795. * Interface for attribute information associated with buffer instanciation
  85796. */
  85797. export class InstancingAttributeInfo {
  85798. /**
  85799. * Index/offset of the attribute in the vertex shader
  85800. */
  85801. index: number;
  85802. /**
  85803. * size of the attribute, 1, 2, 3 or 4
  85804. */
  85805. attributeSize: number;
  85806. /**
  85807. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85808. * default is FLOAT
  85809. */
  85810. attribyteType: number;
  85811. /**
  85812. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85813. */
  85814. normalized: boolean;
  85815. /**
  85816. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85817. */
  85818. offset: number;
  85819. /**
  85820. * Name of the GLSL attribute, for debugging purpose only
  85821. */
  85822. attributeName: string;
  85823. }
  85824. /**
  85825. * Define options used to create a depth texture
  85826. */
  85827. export class DepthTextureCreationOptions {
  85828. /** Specifies whether or not a stencil should be allocated in the texture */
  85829. generateStencil?: boolean;
  85830. /** Specifies whether or not bilinear filtering is enable on the texture */
  85831. bilinearFiltering?: boolean;
  85832. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85833. comparisonFunction?: number;
  85834. /** Specifies if the created texture is a cube texture */
  85835. isCube?: boolean;
  85836. }
  85837. /**
  85838. * Class used to describe the capabilities of the engine relatively to the current browser
  85839. */
  85840. export class EngineCapabilities {
  85841. /** Maximum textures units per fragment shader */
  85842. maxTexturesImageUnits: number;
  85843. /** Maximum texture units per vertex shader */
  85844. maxVertexTextureImageUnits: number;
  85845. /** Maximum textures units in the entire pipeline */
  85846. maxCombinedTexturesImageUnits: number;
  85847. /** Maximum texture size */
  85848. maxTextureSize: number;
  85849. /** Maximum cube texture size */
  85850. maxCubemapTextureSize: number;
  85851. /** Maximum render texture size */
  85852. maxRenderTextureSize: number;
  85853. /** Maximum number of vertex attributes */
  85854. maxVertexAttribs: number;
  85855. /** Maximum number of varyings */
  85856. maxVaryingVectors: number;
  85857. /** Maximum number of uniforms per vertex shader */
  85858. maxVertexUniformVectors: number;
  85859. /** Maximum number of uniforms per fragment shader */
  85860. maxFragmentUniformVectors: number;
  85861. /** Defines if standard derivates (dx/dy) are supported */
  85862. standardDerivatives: boolean;
  85863. /** Defines if s3tc texture compression is supported */
  85864. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85865. /** Defines if pvrtc texture compression is supported */
  85866. pvrtc: any;
  85867. /** Defines if etc1 texture compression is supported */
  85868. etc1: any;
  85869. /** Defines if etc2 texture compression is supported */
  85870. etc2: any;
  85871. /** Defines if astc texture compression is supported */
  85872. astc: any;
  85873. /** Defines if float textures are supported */
  85874. textureFloat: boolean;
  85875. /** Defines if vertex array objects are supported */
  85876. vertexArrayObject: boolean;
  85877. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85878. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85879. /** Gets the maximum level of anisotropy supported */
  85880. maxAnisotropy: number;
  85881. /** Defines if instancing is supported */
  85882. instancedArrays: boolean;
  85883. /** Defines if 32 bits indices are supported */
  85884. uintIndices: boolean;
  85885. /** Defines if high precision shaders are supported */
  85886. highPrecisionShaderSupported: boolean;
  85887. /** Defines if depth reading in the fragment shader is supported */
  85888. fragmentDepthSupported: boolean;
  85889. /** Defines if float texture linear filtering is supported*/
  85890. textureFloatLinearFiltering: boolean;
  85891. /** Defines if rendering to float textures is supported */
  85892. textureFloatRender: boolean;
  85893. /** Defines if half float textures are supported*/
  85894. textureHalfFloat: boolean;
  85895. /** Defines if half float texture linear filtering is supported*/
  85896. textureHalfFloatLinearFiltering: boolean;
  85897. /** Defines if rendering to half float textures is supported */
  85898. textureHalfFloatRender: boolean;
  85899. /** Defines if textureLOD shader command is supported */
  85900. textureLOD: boolean;
  85901. /** Defines if draw buffers extension is supported */
  85902. drawBuffersExtension: boolean;
  85903. /** Defines if depth textures are supported */
  85904. depthTextureExtension: boolean;
  85905. /** Defines if float color buffer are supported */
  85906. colorBufferFloat: boolean;
  85907. /** Gets disjoint timer query extension (null if not supported) */
  85908. timerQuery: EXT_disjoint_timer_query;
  85909. /** Defines if timestamp can be used with timer query */
  85910. canUseTimestampForTimerQuery: boolean;
  85911. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  85912. multiview: any;
  85913. /** Function used to let the system compiles shaders in background */
  85914. parallelShaderCompile: {
  85915. COMPLETION_STATUS_KHR: number;
  85916. };
  85917. }
  85918. /** Interface defining initialization parameters for Engine class */
  85919. export interface EngineOptions extends WebGLContextAttributes {
  85920. /**
  85921. * Defines if the engine should no exceed a specified device ratio
  85922. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85923. */
  85924. limitDeviceRatio?: number;
  85925. /**
  85926. * Defines if webvr should be enabled automatically
  85927. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85928. */
  85929. autoEnableWebVR?: boolean;
  85930. /**
  85931. * Defines if webgl2 should be turned off even if supported
  85932. * @see http://doc.babylonjs.com/features/webgl2
  85933. */
  85934. disableWebGL2Support?: boolean;
  85935. /**
  85936. * Defines if webaudio should be initialized as well
  85937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85938. */
  85939. audioEngine?: boolean;
  85940. /**
  85941. * Defines if animations should run using a deterministic lock step
  85942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85943. */
  85944. deterministicLockstep?: boolean;
  85945. /** Defines the maximum steps to use with deterministic lock step mode */
  85946. lockstepMaxSteps?: number;
  85947. /**
  85948. * Defines that engine should ignore context lost events
  85949. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85950. */
  85951. doNotHandleContextLost?: boolean;
  85952. /**
  85953. * Defines that engine should ignore modifying touch action attribute and style
  85954. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85955. */
  85956. doNotHandleTouchAction?: boolean;
  85957. /**
  85958. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85959. */
  85960. useHighPrecisionFloats?: boolean;
  85961. }
  85962. /**
  85963. * Defines the interface used by display changed events
  85964. */
  85965. export interface IDisplayChangedEventArgs {
  85966. /** Gets the vrDisplay object (if any) */
  85967. vrDisplay: Nullable<any>;
  85968. /** Gets a boolean indicating if webVR is supported */
  85969. vrSupported: boolean;
  85970. }
  85971. /**
  85972. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85973. */
  85974. export class Engine {
  85975. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85976. static ExceptionList: ({
  85977. key: string;
  85978. capture: string;
  85979. captureConstraint: number;
  85980. targets: string[];
  85981. } | {
  85982. key: string;
  85983. capture: null;
  85984. captureConstraint: null;
  85985. targets: string[];
  85986. })[];
  85987. /** Gets the list of created engines */
  85988. static readonly Instances: Engine[];
  85989. /**
  85990. * Gets the latest created engine
  85991. */
  85992. static readonly LastCreatedEngine: Nullable<Engine>;
  85993. /**
  85994. * Gets the latest created scene
  85995. */
  85996. static readonly LastCreatedScene: Nullable<Scene>;
  85997. /**
  85998. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85999. * @param flag defines which part of the materials must be marked as dirty
  86000. * @param predicate defines a predicate used to filter which materials should be affected
  86001. */
  86002. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86003. /**
  86004. * Hidden
  86005. */
  86006. static _TextureLoaders: IInternalTextureLoader[];
  86007. /** Defines that alpha blending is disabled */
  86008. static readonly ALPHA_DISABLE: number;
  86009. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86010. static readonly ALPHA_ADD: number;
  86011. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86012. static readonly ALPHA_COMBINE: number;
  86013. /** Defines that alpha blending to DEST - SRC * DEST */
  86014. static readonly ALPHA_SUBTRACT: number;
  86015. /** Defines that alpha blending to SRC * DEST */
  86016. static readonly ALPHA_MULTIPLY: number;
  86017. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86018. static readonly ALPHA_MAXIMIZED: number;
  86019. /** Defines that alpha blending to SRC + DEST */
  86020. static readonly ALPHA_ONEONE: number;
  86021. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86022. static readonly ALPHA_PREMULTIPLIED: number;
  86023. /**
  86024. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86025. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86026. */
  86027. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86028. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86029. static readonly ALPHA_INTERPOLATE: number;
  86030. /**
  86031. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86032. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86033. */
  86034. static readonly ALPHA_SCREENMODE: number;
  86035. /** Defines that the ressource is not delayed*/
  86036. static readonly DELAYLOADSTATE_NONE: number;
  86037. /** Defines that the ressource was successfully delay loaded */
  86038. static readonly DELAYLOADSTATE_LOADED: number;
  86039. /** Defines that the ressource is currently delay loading */
  86040. static readonly DELAYLOADSTATE_LOADING: number;
  86041. /** Defines that the ressource is delayed and has not started loading */
  86042. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86044. static readonly NEVER: number;
  86045. /** 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 */
  86046. static readonly ALWAYS: number;
  86047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86048. static readonly LESS: number;
  86049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86050. static readonly EQUAL: number;
  86051. /** 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 */
  86052. static readonly LEQUAL: number;
  86053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86054. static readonly GREATER: number;
  86055. /** 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 */
  86056. static readonly GEQUAL: number;
  86057. /** 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 */
  86058. static readonly NOTEQUAL: number;
  86059. /** Passed to stencilOperation to specify that stencil value must be kept */
  86060. static readonly KEEP: number;
  86061. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86062. static readonly REPLACE: number;
  86063. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86064. static readonly INCR: number;
  86065. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86066. static readonly DECR: number;
  86067. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86068. static readonly INVERT: number;
  86069. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86070. static readonly INCR_WRAP: number;
  86071. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86072. static readonly DECR_WRAP: number;
  86073. /** Texture is not repeating outside of 0..1 UVs */
  86074. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86075. /** Texture is repeating outside of 0..1 UVs */
  86076. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86077. /** Texture is repeating and mirrored */
  86078. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86079. /** ALPHA */
  86080. static readonly TEXTUREFORMAT_ALPHA: number;
  86081. /** LUMINANCE */
  86082. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86083. /** LUMINANCE_ALPHA */
  86084. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86085. /** RGB */
  86086. static readonly TEXTUREFORMAT_RGB: number;
  86087. /** RGBA */
  86088. static readonly TEXTUREFORMAT_RGBA: number;
  86089. /** RED */
  86090. static readonly TEXTUREFORMAT_RED: number;
  86091. /** RED (2nd reference) */
  86092. static readonly TEXTUREFORMAT_R: number;
  86093. /** RG */
  86094. static readonly TEXTUREFORMAT_RG: number;
  86095. /** RED_INTEGER */
  86096. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86097. /** RED_INTEGER (2nd reference) */
  86098. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86099. /** RG_INTEGER */
  86100. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86101. /** RGB_INTEGER */
  86102. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86103. /** RGBA_INTEGER */
  86104. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86105. /** UNSIGNED_BYTE */
  86106. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86107. /** UNSIGNED_BYTE (2nd reference) */
  86108. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86109. /** FLOAT */
  86110. static readonly TEXTURETYPE_FLOAT: number;
  86111. /** HALF_FLOAT */
  86112. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86113. /** BYTE */
  86114. static readonly TEXTURETYPE_BYTE: number;
  86115. /** SHORT */
  86116. static readonly TEXTURETYPE_SHORT: number;
  86117. /** UNSIGNED_SHORT */
  86118. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86119. /** INT */
  86120. static readonly TEXTURETYPE_INT: number;
  86121. /** UNSIGNED_INT */
  86122. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86123. /** UNSIGNED_SHORT_4_4_4_4 */
  86124. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86125. /** UNSIGNED_SHORT_5_5_5_1 */
  86126. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86127. /** UNSIGNED_SHORT_5_6_5 */
  86128. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86129. /** UNSIGNED_INT_2_10_10_10_REV */
  86130. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86131. /** UNSIGNED_INT_24_8 */
  86132. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86133. /** UNSIGNED_INT_10F_11F_11F_REV */
  86134. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86135. /** UNSIGNED_INT_5_9_9_9_REV */
  86136. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86137. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86138. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86139. /** nearest is mag = nearest and min = nearest and mip = linear */
  86140. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86142. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86143. /** Trilinear is mag = linear and min = linear and mip = linear */
  86144. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86145. /** nearest is mag = nearest and min = nearest and mip = linear */
  86146. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86148. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86149. /** Trilinear is mag = linear and min = linear and mip = linear */
  86150. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86151. /** mag = nearest and min = nearest and mip = nearest */
  86152. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86153. /** mag = nearest and min = linear and mip = nearest */
  86154. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86155. /** mag = nearest and min = linear and mip = linear */
  86156. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86157. /** mag = nearest and min = linear and mip = none */
  86158. static readonly TEXTURE_NEAREST_LINEAR: number;
  86159. /** mag = nearest and min = nearest and mip = none */
  86160. static readonly TEXTURE_NEAREST_NEAREST: number;
  86161. /** mag = linear and min = nearest and mip = nearest */
  86162. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86163. /** mag = linear and min = nearest and mip = linear */
  86164. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86165. /** mag = linear and min = linear and mip = none */
  86166. static readonly TEXTURE_LINEAR_LINEAR: number;
  86167. /** mag = linear and min = nearest and mip = none */
  86168. static readonly TEXTURE_LINEAR_NEAREST: number;
  86169. /** Explicit coordinates mode */
  86170. static readonly TEXTURE_EXPLICIT_MODE: number;
  86171. /** Spherical coordinates mode */
  86172. static readonly TEXTURE_SPHERICAL_MODE: number;
  86173. /** Planar coordinates mode */
  86174. static readonly TEXTURE_PLANAR_MODE: number;
  86175. /** Cubic coordinates mode */
  86176. static readonly TEXTURE_CUBIC_MODE: number;
  86177. /** Projection coordinates mode */
  86178. static readonly TEXTURE_PROJECTION_MODE: number;
  86179. /** Skybox coordinates mode */
  86180. static readonly TEXTURE_SKYBOX_MODE: number;
  86181. /** Inverse Cubic coordinates mode */
  86182. static readonly TEXTURE_INVCUBIC_MODE: number;
  86183. /** Equirectangular coordinates mode */
  86184. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86185. /** Equirectangular Fixed coordinates mode */
  86186. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86187. /** Equirectangular Fixed Mirrored coordinates mode */
  86188. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86189. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86190. static readonly SCALEMODE_FLOOR: number;
  86191. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86192. static readonly SCALEMODE_NEAREST: number;
  86193. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86194. static readonly SCALEMODE_CEILING: number;
  86195. /**
  86196. * Returns the current npm package of the sdk
  86197. */
  86198. static readonly NpmPackage: string;
  86199. /**
  86200. * Returns the current version of the framework
  86201. */
  86202. static readonly Version: string;
  86203. /**
  86204. * Returns a string describing the current engine
  86205. */
  86206. readonly description: string;
  86207. /**
  86208. * Gets or sets the epsilon value used by collision engine
  86209. */
  86210. static CollisionsEpsilon: number;
  86211. /**
  86212. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86213. */
  86214. static ShadersRepository: string;
  86215. /**
  86216. * Method called to create the default loading screen.
  86217. * This can be overriden in your own app.
  86218. * @param canvas The rendering canvas element
  86219. * @returns The loading screen
  86220. */
  86221. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86222. /**
  86223. * Method called to create the default rescale post process on each engine.
  86224. */
  86225. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86226. /**
  86227. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86228. */
  86229. forcePOTTextures: boolean;
  86230. /**
  86231. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86232. */
  86233. isFullscreen: boolean;
  86234. /**
  86235. * Gets a boolean indicating if the pointer is currently locked
  86236. */
  86237. isPointerLock: boolean;
  86238. /**
  86239. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86240. */
  86241. cullBackFaces: boolean;
  86242. /**
  86243. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86244. */
  86245. renderEvenInBackground: boolean;
  86246. /**
  86247. * Gets or sets a boolean indicating that cache can be kept between frames
  86248. */
  86249. preventCacheWipeBetweenFrames: boolean;
  86250. /**
  86251. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86252. **/
  86253. enableOfflineSupport: boolean;
  86254. /**
  86255. * 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)
  86256. **/
  86257. disableManifestCheck: boolean;
  86258. /**
  86259. * Gets the list of created scenes
  86260. */
  86261. scenes: Scene[];
  86262. /**
  86263. * Event raised when a new scene is created
  86264. */
  86265. onNewSceneAddedObservable: Observable<Scene>;
  86266. /**
  86267. * Gets the list of created postprocesses
  86268. */
  86269. postProcesses: PostProcess[];
  86270. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86271. validateShaderPrograms: boolean;
  86272. /**
  86273. * Observable event triggered each time the rendering canvas is resized
  86274. */
  86275. onResizeObservable: Observable<Engine>;
  86276. /**
  86277. * Observable event triggered each time the canvas loses focus
  86278. */
  86279. onCanvasBlurObservable: Observable<Engine>;
  86280. /**
  86281. * Observable event triggered each time the canvas gains focus
  86282. */
  86283. onCanvasFocusObservable: Observable<Engine>;
  86284. /**
  86285. * Observable event triggered each time the canvas receives pointerout event
  86286. */
  86287. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86288. /**
  86289. * Observable event triggered before each texture is initialized
  86290. */
  86291. onBeforeTextureInitObservable: Observable<Texture>;
  86292. private _vrDisplay;
  86293. private _vrSupported;
  86294. private _oldSize;
  86295. private _oldHardwareScaleFactor;
  86296. private _vrExclusivePointerMode;
  86297. private _webVRInitPromise;
  86298. /**
  86299. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86300. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86301. */
  86302. readonly isInVRExclusivePointerMode: boolean;
  86303. /**
  86304. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86305. */
  86306. disableUniformBuffers: boolean;
  86307. /** @hidden */
  86308. _uniformBuffers: UniformBuffer[];
  86309. /**
  86310. * Gets a boolean indicating that the engine supports uniform buffers
  86311. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86312. */
  86313. readonly supportsUniformBuffers: boolean;
  86314. /**
  86315. * Observable raised when the engine begins a new frame
  86316. */
  86317. onBeginFrameObservable: Observable<Engine>;
  86318. /**
  86319. * If set, will be used to request the next animation frame for the render loop
  86320. */
  86321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86322. /**
  86323. * Observable raised when the engine ends the current frame
  86324. */
  86325. onEndFrameObservable: Observable<Engine>;
  86326. /**
  86327. * Observable raised when the engine is about to compile a shader
  86328. */
  86329. onBeforeShaderCompilationObservable: Observable<Engine>;
  86330. /**
  86331. * Observable raised when the engine has jsut compiled a shader
  86332. */
  86333. onAfterShaderCompilationObservable: Observable<Engine>;
  86334. /** @hidden */
  86335. _gl: WebGLRenderingContext;
  86336. private _renderingCanvas;
  86337. private _windowIsBackground;
  86338. private _webGLVersion;
  86339. protected _highPrecisionShadersAllowed: boolean;
  86340. /** @hidden */
  86341. readonly _shouldUseHighPrecisionShader: boolean;
  86342. /**
  86343. * Gets a boolean indicating that only power of 2 textures are supported
  86344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86345. */
  86346. readonly needPOTTextures: boolean;
  86347. /** @hidden */
  86348. _badOS: boolean;
  86349. /** @hidden */
  86350. _badDesktopOS: boolean;
  86351. /**
  86352. * Gets or sets a value indicating if we want to disable texture binding optimization.
  86353. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  86354. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  86355. */
  86356. disableTextureBindingOptimization: boolean;
  86357. /**
  86358. * Gets the audio engine
  86359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86360. * @ignorenaming
  86361. */
  86362. static audioEngine: IAudioEngine;
  86363. /**
  86364. * Default AudioEngine factory responsible of creating the Audio Engine.
  86365. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86366. */
  86367. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86368. /**
  86369. * Default offline support factory responsible of creating a tool used to store data locally.
  86370. * By default, this will create a Database object if the workload has been embedded.
  86371. */
  86372. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86373. private _onFocus;
  86374. private _onBlur;
  86375. private _onCanvasPointerOut;
  86376. private _onCanvasBlur;
  86377. private _onCanvasFocus;
  86378. private _onFullscreenChange;
  86379. private _onPointerLockChange;
  86380. private _onVRDisplayPointerRestricted;
  86381. private _onVRDisplayPointerUnrestricted;
  86382. private _onVrDisplayConnect;
  86383. private _onVrDisplayDisconnect;
  86384. private _onVrDisplayPresentChange;
  86385. /**
  86386. * Observable signaled when VR display mode changes
  86387. */
  86388. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86389. /**
  86390. * Observable signaled when VR request present is complete
  86391. */
  86392. onVRRequestPresentComplete: Observable<boolean>;
  86393. /**
  86394. * Observable signaled when VR request present starts
  86395. */
  86396. onVRRequestPresentStart: Observable<Engine>;
  86397. private _hardwareScalingLevel;
  86398. /** @hidden */
  86399. protected _caps: EngineCapabilities;
  86400. private _pointerLockRequested;
  86401. private _isStencilEnable;
  86402. private _colorWrite;
  86403. private _loadingScreen;
  86404. /** @hidden */
  86405. _drawCalls: PerfCounter;
  86406. /** @hidden */
  86407. _textureCollisions: PerfCounter;
  86408. private _glVersion;
  86409. private _glRenderer;
  86410. private _glVendor;
  86411. private _videoTextureSupported;
  86412. private _renderingQueueLaunched;
  86413. private _activeRenderLoops;
  86414. private _deterministicLockstep;
  86415. private _lockstepMaxSteps;
  86416. /**
  86417. * Observable signaled when a context lost event is raised
  86418. */
  86419. onContextLostObservable: Observable<Engine>;
  86420. /**
  86421. * Observable signaled when a context restored event is raised
  86422. */
  86423. onContextRestoredObservable: Observable<Engine>;
  86424. private _onContextLost;
  86425. private _onContextRestored;
  86426. private _contextWasLost;
  86427. private _doNotHandleContextLost;
  86428. /**
  86429. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86431. */
  86432. doNotHandleContextLost: boolean;
  86433. private _performanceMonitor;
  86434. private _fps;
  86435. private _deltaTime;
  86436. /**
  86437. * Turn this value on if you want to pause FPS computation when in background
  86438. */
  86439. disablePerformanceMonitorInBackground: boolean;
  86440. /**
  86441. * Gets the performance monitor attached to this engine
  86442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86443. */
  86444. readonly performanceMonitor: PerformanceMonitor;
  86445. /**
  86446. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86447. */
  86448. disableVertexArrayObjects: boolean;
  86449. /** @hidden */
  86450. protected _depthCullingState: _DepthCullingState;
  86451. /** @hidden */
  86452. protected _stencilState: _StencilState;
  86453. /** @hidden */
  86454. protected _alphaState: _AlphaState;
  86455. /** @hidden */
  86456. protected _alphaMode: number;
  86457. protected _internalTexturesCache: InternalTexture[];
  86458. /** @hidden */
  86459. protected _activeChannel: number;
  86460. private _currentTextureChannel;
  86461. /** @hidden */
  86462. protected _boundTexturesCache: {
  86463. [key: string]: Nullable<InternalTexture>;
  86464. };
  86465. /** @hidden */
  86466. protected _currentEffect: Nullable<Effect>;
  86467. /** @hidden */
  86468. protected _currentProgram: Nullable<WebGLProgram>;
  86469. private _compiledEffects;
  86470. private _vertexAttribArraysEnabled;
  86471. /** @hidden */
  86472. protected _cachedViewport: Nullable<Viewport>;
  86473. private _cachedVertexArrayObject;
  86474. /** @hidden */
  86475. protected _cachedVertexBuffers: any;
  86476. /** @hidden */
  86477. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86478. /** @hidden */
  86479. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86480. /** @hidden */
  86481. protected _currentRenderTarget: Nullable<InternalTexture>;
  86482. private _uintIndicesCurrentlySet;
  86483. private _currentBoundBuffer;
  86484. /** @hidden */
  86485. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86486. private _currentBufferPointers;
  86487. private _currentInstanceLocations;
  86488. private _currentInstanceBuffers;
  86489. private _textureUnits;
  86490. private _firstBoundInternalTextureTracker;
  86491. private _lastBoundInternalTextureTracker;
  86492. private _workingCanvas;
  86493. private _workingContext;
  86494. private _rescalePostProcess;
  86495. private _dummyFramebuffer;
  86496. private _externalData;
  86497. private _bindedRenderFunction;
  86498. private _vaoRecordInProgress;
  86499. private _mustWipeVertexAttributes;
  86500. private _emptyTexture;
  86501. private _emptyCubeTexture;
  86502. private _emptyTexture3D;
  86503. /** @hidden */
  86504. _frameHandler: number;
  86505. private _nextFreeTextureSlots;
  86506. private _maxSimultaneousTextures;
  86507. private _activeRequests;
  86508. private _texturesSupported;
  86509. private _textureFormatInUse;
  86510. /**
  86511. * Gets the list of texture formats supported
  86512. */
  86513. readonly texturesSupported: Array<string>;
  86514. /**
  86515. * Gets the list of texture formats in use
  86516. */
  86517. readonly textureFormatInUse: Nullable<string>;
  86518. /**
  86519. * Gets the current viewport
  86520. */
  86521. readonly currentViewport: Nullable<Viewport>;
  86522. /**
  86523. * Gets the default empty texture
  86524. */
  86525. readonly emptyTexture: InternalTexture;
  86526. /**
  86527. * Gets the default empty 3D texture
  86528. */
  86529. readonly emptyTexture3D: InternalTexture;
  86530. /**
  86531. * Gets the default empty cube texture
  86532. */
  86533. readonly emptyCubeTexture: InternalTexture;
  86534. /**
  86535. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86536. */
  86537. readonly premultipliedAlpha: boolean;
  86538. /**
  86539. * Creates a new engine
  86540. * @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
  86541. * @param antialias defines enable antialiasing (default: false)
  86542. * @param options defines further options to be sent to the getContext() function
  86543. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86544. */
  86545. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86546. private _disableTouchAction;
  86547. private _rebuildInternalTextures;
  86548. private _rebuildEffects;
  86549. /**
  86550. * Gets a boolean indicating if all created effects are ready
  86551. * @returns true if all effects are ready
  86552. */
  86553. areAllEffectsReady(): boolean;
  86554. private _rebuildBuffers;
  86555. private _initGLContext;
  86556. /**
  86557. * Gets version of the current webGL context
  86558. */
  86559. readonly webGLVersion: number;
  86560. /**
  86561. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86562. */
  86563. readonly isStencilEnable: boolean;
  86564. private _prepareWorkingCanvas;
  86565. /**
  86566. * Reset the texture cache to empty state
  86567. */
  86568. resetTextureCache(): void;
  86569. /**
  86570. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86572. * @returns true if engine is in deterministic lock step mode
  86573. */
  86574. isDeterministicLockStep(): boolean;
  86575. /**
  86576. * Gets the max steps when engine is running in deterministic lock step
  86577. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86578. * @returns the max steps
  86579. */
  86580. getLockstepMaxSteps(): number;
  86581. /**
  86582. * Gets an object containing information about the current webGL context
  86583. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86584. */
  86585. getGlInfo(): {
  86586. vendor: string;
  86587. renderer: string;
  86588. version: string;
  86589. };
  86590. /**
  86591. * Gets current aspect ratio
  86592. * @param camera defines the camera to use to get the aspect ratio
  86593. * @param useScreen defines if screen size must be used (or the current render target if any)
  86594. * @returns a number defining the aspect ratio
  86595. */
  86596. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86597. /**
  86598. * Gets current screen aspect ratio
  86599. * @returns a number defining the aspect ratio
  86600. */
  86601. getScreenAspectRatio(): number;
  86602. /**
  86603. * Gets the current render width
  86604. * @param useScreen defines if screen size must be used (or the current render target if any)
  86605. * @returns a number defining the current render width
  86606. */
  86607. getRenderWidth(useScreen?: boolean): number;
  86608. /**
  86609. * Gets the current render height
  86610. * @param useScreen defines if screen size must be used (or the current render target if any)
  86611. * @returns a number defining the current render height
  86612. */
  86613. getRenderHeight(useScreen?: boolean): number;
  86614. /**
  86615. * Gets the HTML canvas attached with the current webGL context
  86616. * @returns a HTML canvas
  86617. */
  86618. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86619. /**
  86620. * Gets the client rect of the HTML canvas attached with the current webGL context
  86621. * @returns a client rectanglee
  86622. */
  86623. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86624. /**
  86625. * Defines the hardware scaling level.
  86626. * By default the hardware scaling level is computed from the window device ratio.
  86627. * 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.
  86628. * @param level defines the level to use
  86629. */
  86630. setHardwareScalingLevel(level: number): void;
  86631. /**
  86632. * Gets the current hardware scaling level.
  86633. * By default the hardware scaling level is computed from the window device ratio.
  86634. * 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.
  86635. * @returns a number indicating the current hardware scaling level
  86636. */
  86637. getHardwareScalingLevel(): number;
  86638. /**
  86639. * Gets the list of loaded textures
  86640. * @returns an array containing all loaded textures
  86641. */
  86642. getLoadedTexturesCache(): InternalTexture[];
  86643. /**
  86644. * Gets the object containing all engine capabilities
  86645. * @returns the EngineCapabilities object
  86646. */
  86647. getCaps(): EngineCapabilities;
  86648. /**
  86649. * Gets the current depth function
  86650. * @returns a number defining the depth function
  86651. */
  86652. getDepthFunction(): Nullable<number>;
  86653. /**
  86654. * Sets the current depth function
  86655. * @param depthFunc defines the function to use
  86656. */
  86657. setDepthFunction(depthFunc: number): void;
  86658. /**
  86659. * Sets the current depth function to GREATER
  86660. */
  86661. setDepthFunctionToGreater(): void;
  86662. /**
  86663. * Sets the current depth function to GEQUAL
  86664. */
  86665. setDepthFunctionToGreaterOrEqual(): void;
  86666. /**
  86667. * Sets the current depth function to LESS
  86668. */
  86669. setDepthFunctionToLess(): void;
  86670. private _cachedStencilBuffer;
  86671. private _cachedStencilFunction;
  86672. private _cachedStencilMask;
  86673. private _cachedStencilOperationPass;
  86674. private _cachedStencilOperationFail;
  86675. private _cachedStencilOperationDepthFail;
  86676. private _cachedStencilReference;
  86677. /**
  86678. * Caches the the state of the stencil buffer
  86679. */
  86680. cacheStencilState(): void;
  86681. /**
  86682. * Restores the state of the stencil buffer
  86683. */
  86684. restoreStencilState(): void;
  86685. /**
  86686. * Sets the current depth function to LEQUAL
  86687. */
  86688. setDepthFunctionToLessOrEqual(): void;
  86689. /**
  86690. * Gets a boolean indicating if stencil buffer is enabled
  86691. * @returns the current stencil buffer state
  86692. */
  86693. getStencilBuffer(): boolean;
  86694. /**
  86695. * Enable or disable the stencil buffer
  86696. * @param enable defines if the stencil buffer must be enabled or disabled
  86697. */
  86698. setStencilBuffer(enable: boolean): void;
  86699. /**
  86700. * Gets the current stencil mask
  86701. * @returns a number defining the new stencil mask to use
  86702. */
  86703. getStencilMask(): number;
  86704. /**
  86705. * Sets the current stencil mask
  86706. * @param mask defines the new stencil mask to use
  86707. */
  86708. setStencilMask(mask: number): void;
  86709. /**
  86710. * Gets the current stencil function
  86711. * @returns a number defining the stencil function to use
  86712. */
  86713. getStencilFunction(): number;
  86714. /**
  86715. * Gets the current stencil reference value
  86716. * @returns a number defining the stencil reference value to use
  86717. */
  86718. getStencilFunctionReference(): number;
  86719. /**
  86720. * Gets the current stencil mask
  86721. * @returns a number defining the stencil mask to use
  86722. */
  86723. getStencilFunctionMask(): number;
  86724. /**
  86725. * Sets the current stencil function
  86726. * @param stencilFunc defines the new stencil function to use
  86727. */
  86728. setStencilFunction(stencilFunc: number): void;
  86729. /**
  86730. * Sets the current stencil reference
  86731. * @param reference defines the new stencil reference to use
  86732. */
  86733. setStencilFunctionReference(reference: number): void;
  86734. /**
  86735. * Sets the current stencil mask
  86736. * @param mask defines the new stencil mask to use
  86737. */
  86738. setStencilFunctionMask(mask: number): void;
  86739. /**
  86740. * Gets the current stencil operation when stencil fails
  86741. * @returns a number defining stencil operation to use when stencil fails
  86742. */
  86743. getStencilOperationFail(): number;
  86744. /**
  86745. * Gets the current stencil operation when depth fails
  86746. * @returns a number defining stencil operation to use when depth fails
  86747. */
  86748. getStencilOperationDepthFail(): number;
  86749. /**
  86750. * Gets the current stencil operation when stencil passes
  86751. * @returns a number defining stencil operation to use when stencil passes
  86752. */
  86753. getStencilOperationPass(): number;
  86754. /**
  86755. * Sets the stencil operation to use when stencil fails
  86756. * @param operation defines the stencil operation to use when stencil fails
  86757. */
  86758. setStencilOperationFail(operation: number): void;
  86759. /**
  86760. * Sets the stencil operation to use when depth fails
  86761. * @param operation defines the stencil operation to use when depth fails
  86762. */
  86763. setStencilOperationDepthFail(operation: number): void;
  86764. /**
  86765. * Sets the stencil operation to use when stencil passes
  86766. * @param operation defines the stencil operation to use when stencil passes
  86767. */
  86768. setStencilOperationPass(operation: number): void;
  86769. /**
  86770. * Sets a boolean indicating if the dithering state is enabled or disabled
  86771. * @param value defines the dithering state
  86772. */
  86773. setDitheringState(value: boolean): void;
  86774. /**
  86775. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86776. * @param value defines the rasterizer state
  86777. */
  86778. setRasterizerState(value: boolean): void;
  86779. /**
  86780. * stop executing a render loop function and remove it from the execution array
  86781. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  86782. */
  86783. stopRenderLoop(renderFunction?: () => void): void;
  86784. /** @hidden */
  86785. _renderLoop(): void;
  86786. /**
  86787. * Register and execute a render loop. The engine can have more than one render function
  86788. * @param renderFunction defines the function to continuously execute
  86789. */
  86790. runRenderLoop(renderFunction: () => void): void;
  86791. /**
  86792. * Toggle full screen mode
  86793. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86794. */
  86795. switchFullscreen(requestPointerLock: boolean): void;
  86796. /**
  86797. * Enters full screen mode
  86798. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86799. */
  86800. enterFullscreen(requestPointerLock: boolean): void;
  86801. /**
  86802. * Exits full screen mode
  86803. */
  86804. exitFullscreen(): void;
  86805. /**
  86806. * Clear the current render buffer or the current render target (if any is set up)
  86807. * @param color defines the color to use
  86808. * @param backBuffer defines if the back buffer must be cleared
  86809. * @param depth defines if the depth buffer must be cleared
  86810. * @param stencil defines if the stencil buffer must be cleared
  86811. */
  86812. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86813. /**
  86814. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86815. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86816. * @param y defines the y-coordinate of the corner of the clear rectangle
  86817. * @param width defines the width of the clear rectangle
  86818. * @param height defines the height of the clear rectangle
  86819. * @param clearColor defines the clear color
  86820. */
  86821. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86822. /**
  86823. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86824. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86825. * @param y defines the y-coordinate of the corner of the clear rectangle
  86826. * @param width defines the width of the clear rectangle
  86827. * @param height defines the height of the clear rectangle
  86828. */
  86829. enableScissor(x: number, y: number, width: number, height: number): void;
  86830. /**
  86831. * Disable previously set scissor test rectangle
  86832. */
  86833. disableScissor(): void;
  86834. private _viewportCached;
  86835. /** @hidden */
  86836. _viewport(x: number, y: number, width: number, height: number): void;
  86837. /**
  86838. * Set the WebGL's viewport
  86839. * @param viewport defines the viewport element to be used
  86840. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86841. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86842. */
  86843. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86844. /**
  86845. * Directly set the WebGL Viewport
  86846. * @param x defines the x coordinate of the viewport (in screen space)
  86847. * @param y defines the y coordinate of the viewport (in screen space)
  86848. * @param width defines the width of the viewport (in screen space)
  86849. * @param height defines the height of the viewport (in screen space)
  86850. * @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
  86851. */
  86852. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86853. /**
  86854. * Begin a new frame
  86855. */
  86856. beginFrame(): void;
  86857. /**
  86858. * Enf the current frame
  86859. */
  86860. endFrame(): void;
  86861. /**
  86862. * Resize the view according to the canvas' size
  86863. */
  86864. resize(): void;
  86865. /**
  86866. * Force a specific size of the canvas
  86867. * @param width defines the new canvas' width
  86868. * @param height defines the new canvas' height
  86869. */
  86870. setSize(width: number, height: number): void;
  86871. /**
  86872. * Gets a boolean indicating if a webVR device was detected
  86873. * @returns true if a webVR device was detected
  86874. */
  86875. isVRDevicePresent(): boolean;
  86876. /**
  86877. * Gets the current webVR device
  86878. * @returns the current webVR device (or null)
  86879. */
  86880. getVRDevice(): any;
  86881. /**
  86882. * Initializes a webVR display and starts listening to display change events
  86883. * The onVRDisplayChangedObservable will be notified upon these changes
  86884. * @returns The onVRDisplayChangedObservable
  86885. */
  86886. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86887. /**
  86888. * Initializes a webVR display and starts listening to display change events
  86889. * The onVRDisplayChangedObservable will be notified upon these changes
  86890. * @returns A promise containing a VRDisplay and if vr is supported
  86891. */
  86892. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86893. /**
  86894. * Call this function to switch to webVR mode
  86895. * Will do nothing if webVR is not supported or if there is no webVR device
  86896. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86897. */
  86898. enableVR(): void;
  86899. /**
  86900. * Call this function to leave webVR mode
  86901. * Will do nothing if webVR is not supported or if there is no webVR device
  86902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86903. */
  86904. disableVR(): void;
  86905. private _onVRFullScreenTriggered;
  86906. private _getVRDisplaysAsync;
  86907. /**
  86908. * Binds the frame buffer to the specified texture.
  86909. * @param texture The texture to render to or null for the default canvas
  86910. * @param faceIndex The face of the texture to render to in case of cube texture
  86911. * @param requiredWidth The width of the target to render to
  86912. * @param requiredHeight The height of the target to render to
  86913. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86914. * @param depthStencilTexture The depth stencil texture to use to render
  86915. * @param lodLevel defines le lod level to bind to the frame buffer
  86916. */
  86917. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86918. private bindUnboundFramebuffer;
  86919. /**
  86920. * Unbind the current render target texture from the webGL context
  86921. * @param texture defines the render target texture to unbind
  86922. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86923. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86924. */
  86925. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86926. /**
  86927. * Unbind a list of render target textures from the webGL context
  86928. * This is used only when drawBuffer extension or webGL2 are active
  86929. * @param textures defines the render target textures to unbind
  86930. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86931. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86932. */
  86933. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86934. /**
  86935. * Force the mipmap generation for the given render target texture
  86936. * @param texture defines the render target texture to use
  86937. */
  86938. generateMipMapsForCubemap(texture: InternalTexture): void;
  86939. /**
  86940. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86941. */
  86942. flushFramebuffer(): void;
  86943. /**
  86944. * Unbind the current render target and bind the default framebuffer
  86945. */
  86946. restoreDefaultFramebuffer(): void;
  86947. /**
  86948. * Create an uniform buffer
  86949. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86950. * @param elements defines the content of the uniform buffer
  86951. * @returns the webGL uniform buffer
  86952. */
  86953. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86954. /**
  86955. * Create a dynamic uniform buffer
  86956. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86957. * @param elements defines the content of the uniform buffer
  86958. * @returns the webGL uniform buffer
  86959. */
  86960. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86961. /**
  86962. * Update an existing uniform buffer
  86963. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86964. * @param uniformBuffer defines the target uniform buffer
  86965. * @param elements defines the content to update
  86966. * @param offset defines the offset in the uniform buffer where update should start
  86967. * @param count defines the size of the data to update
  86968. */
  86969. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86970. private _resetVertexBufferBinding;
  86971. /**
  86972. * Creates a vertex buffer
  86973. * @param data the data for the vertex buffer
  86974. * @returns the new WebGL static buffer
  86975. */
  86976. createVertexBuffer(data: DataArray): WebGLBuffer;
  86977. /**
  86978. * Creates a dynamic vertex buffer
  86979. * @param data the data for the dynamic vertex buffer
  86980. * @returns the new WebGL dynamic buffer
  86981. */
  86982. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86983. /**
  86984. * Update a dynamic index buffer
  86985. * @param indexBuffer defines the target index buffer
  86986. * @param indices defines the data to update
  86987. * @param offset defines the offset in the target index buffer where update should start
  86988. */
  86989. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86990. /**
  86991. * Updates a dynamic vertex buffer.
  86992. * @param vertexBuffer the vertex buffer to update
  86993. * @param data the data used to update the vertex buffer
  86994. * @param byteOffset the byte offset of the data
  86995. * @param byteLength the byte length of the data
  86996. */
  86997. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86998. private _resetIndexBufferBinding;
  86999. /**
  87000. * Creates a new index buffer
  87001. * @param indices defines the content of the index buffer
  87002. * @param updatable defines if the index buffer must be updatable
  87003. * @returns a new webGL buffer
  87004. */
  87005. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87006. /**
  87007. * Bind a webGL buffer to the webGL context
  87008. * @param buffer defines the buffer to bind
  87009. */
  87010. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87011. /**
  87012. * Bind an uniform buffer to the current webGL context
  87013. * @param buffer defines the buffer to bind
  87014. */
  87015. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87016. /**
  87017. * Bind a buffer to the current webGL context at a given location
  87018. * @param buffer defines the buffer to bind
  87019. * @param location defines the index where to bind the buffer
  87020. */
  87021. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87022. /**
  87023. * Bind a specific block at a given index in a specific shader program
  87024. * @param shaderProgram defines the shader program
  87025. * @param blockName defines the block name
  87026. * @param index defines the index where to bind the block
  87027. */
  87028. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87029. private bindIndexBuffer;
  87030. private bindBuffer;
  87031. /**
  87032. * update the bound buffer with the given data
  87033. * @param data defines the data to update
  87034. */
  87035. updateArrayBuffer(data: Float32Array): void;
  87036. private _vertexAttribPointer;
  87037. private _bindIndexBufferWithCache;
  87038. private _bindVertexBuffersAttributes;
  87039. /**
  87040. * Records a vertex array object
  87041. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87042. * @param vertexBuffers defines the list of vertex buffers to store
  87043. * @param indexBuffer defines the index buffer to store
  87044. * @param effect defines the effect to store
  87045. * @returns the new vertex array object
  87046. */
  87047. recordVertexArrayObject(vertexBuffers: {
  87048. [key: string]: VertexBuffer;
  87049. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87050. /**
  87051. * Bind a specific vertex array object
  87052. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87053. * @param vertexArrayObject defines the vertex array object to bind
  87054. * @param indexBuffer defines the index buffer to bind
  87055. */
  87056. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87057. /**
  87058. * Bind webGl buffers directly to the webGL context
  87059. * @param vertexBuffer defines the vertex buffer to bind
  87060. * @param indexBuffer defines the index buffer to bind
  87061. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87062. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87063. * @param effect defines the effect associated with the vertex buffer
  87064. */
  87065. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87066. private _unbindVertexArrayObject;
  87067. /**
  87068. * Bind a list of vertex buffers to the webGL context
  87069. * @param vertexBuffers defines the list of vertex buffers to bind
  87070. * @param indexBuffer defines the index buffer to bind
  87071. * @param effect defines the effect associated with the vertex buffers
  87072. */
  87073. bindBuffers(vertexBuffers: {
  87074. [key: string]: Nullable<VertexBuffer>;
  87075. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87076. /**
  87077. * Unbind all instance attributes
  87078. */
  87079. unbindInstanceAttributes(): void;
  87080. /**
  87081. * Release and free the memory of a vertex array object
  87082. * @param vao defines the vertex array object to delete
  87083. */
  87084. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87085. /** @hidden */
  87086. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87087. /**
  87088. * Creates a webGL buffer to use with instanciation
  87089. * @param capacity defines the size of the buffer
  87090. * @returns the webGL buffer
  87091. */
  87092. createInstancesBuffer(capacity: number): WebGLBuffer;
  87093. /**
  87094. * Delete a webGL buffer used with instanciation
  87095. * @param buffer defines the webGL buffer to delete
  87096. */
  87097. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87098. /**
  87099. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87100. * @param instancesBuffer defines the webGL buffer to update and bind
  87101. * @param data defines the data to store in the buffer
  87102. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87103. */
  87104. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87105. /**
  87106. * Apply all cached states (depth, culling, stencil and alpha)
  87107. */
  87108. applyStates(): void;
  87109. /**
  87110. * Send a draw order
  87111. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87112. * @param indexStart defines the starting index
  87113. * @param indexCount defines the number of index to draw
  87114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87115. */
  87116. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87117. /**
  87118. * Draw a list of points
  87119. * @param verticesStart defines the index of first vertex to draw
  87120. * @param verticesCount defines the count of vertices to draw
  87121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87122. */
  87123. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87124. /**
  87125. * Draw a list of unindexed primitives
  87126. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87127. * @param verticesStart defines the index of first vertex to draw
  87128. * @param verticesCount defines the count of vertices to draw
  87129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87130. */
  87131. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87132. /**
  87133. * Draw a list of indexed primitives
  87134. * @param fillMode defines the primitive to use
  87135. * @param indexStart defines the starting index
  87136. * @param indexCount defines the number of index to draw
  87137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87138. */
  87139. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87140. /**
  87141. * Draw a list of unindexed primitives
  87142. * @param fillMode defines the primitive to use
  87143. * @param verticesStart defines the index of first vertex to draw
  87144. * @param verticesCount defines the count of vertices to draw
  87145. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87146. */
  87147. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87148. private _drawMode;
  87149. /** @hidden */
  87150. _releaseEffect(effect: Effect): void;
  87151. /** @hidden */
  87152. _deleteProgram(program: WebGLProgram): void;
  87153. /**
  87154. * Create a new effect (used to store vertex/fragment shaders)
  87155. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87156. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87157. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87158. * @param samplers defines an array of string used to represent textures
  87159. * @param defines defines the string containing the defines to use to compile the shaders
  87160. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87161. * @param onCompiled defines a function to call when the effect creation is successful
  87162. * @param onError defines a function to call when the effect creation has failed
  87163. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87164. * @returns the new Effect
  87165. */
  87166. 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;
  87167. private _compileShader;
  87168. private _compileRawShader;
  87169. /**
  87170. * Directly creates a webGL program
  87171. * @param vertexCode defines the vertex shader code to use
  87172. * @param fragmentCode defines the fragment shader code to use
  87173. * @param context defines the webGL context to use (if not set, the current one will be used)
  87174. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87175. * @returns the new webGL program
  87176. */
  87177. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87178. /**
  87179. * Creates a webGL program
  87180. * @param vertexCode defines the vertex shader code to use
  87181. * @param fragmentCode defines the fragment shader code to use
  87182. * @param defines defines the string containing the defines to use to compile the shaders
  87183. * @param context defines the webGL context to use (if not set, the current one will be used)
  87184. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87185. * @returns the new webGL program
  87186. */
  87187. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87188. private _createShaderProgram;
  87189. private _finalizeProgram;
  87190. /** @hidden */
  87191. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87192. /** @hidden */
  87193. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87194. /**
  87195. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87196. * @param shaderProgram defines the webGL program to use
  87197. * @param uniformsNames defines the list of uniform names
  87198. * @returns an array of webGL uniform locations
  87199. */
  87200. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87201. /**
  87202. * Gets the lsit of active attributes for a given webGL program
  87203. * @param shaderProgram defines the webGL program to use
  87204. * @param attributesNames defines the list of attribute names to get
  87205. * @returns an array of indices indicating the offset of each attribute
  87206. */
  87207. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87208. /**
  87209. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87210. * @param effect defines the effect to activate
  87211. */
  87212. enableEffect(effect: Nullable<Effect>): void;
  87213. /**
  87214. * Set the value of an uniform to an array of int32
  87215. * @param uniform defines the webGL uniform location where to store the value
  87216. * @param array defines the array of int32 to store
  87217. */
  87218. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87219. /**
  87220. * Set the value of an uniform to an array of int32 (stored as vec2)
  87221. * @param uniform defines the webGL uniform location where to store the value
  87222. * @param array defines the array of int32 to store
  87223. */
  87224. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87225. /**
  87226. * Set the value of an uniform to an array of int32 (stored as vec3)
  87227. * @param uniform defines the webGL uniform location where to store the value
  87228. * @param array defines the array of int32 to store
  87229. */
  87230. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87231. /**
  87232. * Set the value of an uniform to an array of int32 (stored as vec4)
  87233. * @param uniform defines the webGL uniform location where to store the value
  87234. * @param array defines the array of int32 to store
  87235. */
  87236. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87237. /**
  87238. * Set the value of an uniform to an array of float32
  87239. * @param uniform defines the webGL uniform location where to store the value
  87240. * @param array defines the array of float32 to store
  87241. */
  87242. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87243. /**
  87244. * Set the value of an uniform to an array of float32 (stored as vec2)
  87245. * @param uniform defines the webGL uniform location where to store the value
  87246. * @param array defines the array of float32 to store
  87247. */
  87248. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87249. /**
  87250. * Set the value of an uniform to an array of float32 (stored as vec3)
  87251. * @param uniform defines the webGL uniform location where to store the value
  87252. * @param array defines the array of float32 to store
  87253. */
  87254. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87255. /**
  87256. * Set the value of an uniform to an array of float32 (stored as vec4)
  87257. * @param uniform defines the webGL uniform location where to store the value
  87258. * @param array defines the array of float32 to store
  87259. */
  87260. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87261. /**
  87262. * Set the value of an uniform to an array of number
  87263. * @param uniform defines the webGL uniform location where to store the value
  87264. * @param array defines the array of number to store
  87265. */
  87266. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87267. /**
  87268. * Set the value of an uniform to an array of number (stored as vec2)
  87269. * @param uniform defines the webGL uniform location where to store the value
  87270. * @param array defines the array of number to store
  87271. */
  87272. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87273. /**
  87274. * Set the value of an uniform to an array of number (stored as vec3)
  87275. * @param uniform defines the webGL uniform location where to store the value
  87276. * @param array defines the array of number to store
  87277. */
  87278. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87279. /**
  87280. * Set the value of an uniform to an array of number (stored as vec4)
  87281. * @param uniform defines the webGL uniform location where to store the value
  87282. * @param array defines the array of number to store
  87283. */
  87284. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87285. /**
  87286. * Set the value of an uniform to an array of float32 (stored as matrices)
  87287. * @param uniform defines the webGL uniform location where to store the value
  87288. * @param matrices defines the array of float32 to store
  87289. */
  87290. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87291. /**
  87292. * Set the value of an uniform to a matrix
  87293. * @param uniform defines the webGL uniform location where to store the value
  87294. * @param matrix defines the matrix to store
  87295. */
  87296. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87297. /**
  87298. * Set the value of an uniform to a matrix (3x3)
  87299. * @param uniform defines the webGL uniform location where to store the value
  87300. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87301. */
  87302. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87303. /**
  87304. * Set the value of an uniform to a matrix (2x2)
  87305. * @param uniform defines the webGL uniform location where to store the value
  87306. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87307. */
  87308. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87309. /**
  87310. * Set the value of an uniform to a number (int)
  87311. * @param uniform defines the webGL uniform location where to store the value
  87312. * @param value defines the int number to store
  87313. */
  87314. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87315. /**
  87316. * Set the value of an uniform to a number (float)
  87317. * @param uniform defines the webGL uniform location where to store the value
  87318. * @param value defines the float number to store
  87319. */
  87320. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87321. /**
  87322. * Set the value of an uniform to a vec2
  87323. * @param uniform defines the webGL uniform location where to store the value
  87324. * @param x defines the 1st component of the value
  87325. * @param y defines the 2nd component of the value
  87326. */
  87327. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87328. /**
  87329. * Set the value of an uniform to a vec3
  87330. * @param uniform defines the webGL uniform location where to store the value
  87331. * @param x defines the 1st component of the value
  87332. * @param y defines the 2nd component of the value
  87333. * @param z defines the 3rd component of the value
  87334. */
  87335. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87336. /**
  87337. * Set the value of an uniform to a boolean
  87338. * @param uniform defines the webGL uniform location where to store the value
  87339. * @param bool defines the boolean to store
  87340. */
  87341. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87342. /**
  87343. * Set the value of an uniform to a vec4
  87344. * @param uniform defines the webGL uniform location where to store the value
  87345. * @param x defines the 1st component of the value
  87346. * @param y defines the 2nd component of the value
  87347. * @param z defines the 3rd component of the value
  87348. * @param w defines the 4th component of the value
  87349. */
  87350. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87351. /**
  87352. * Set the value of an uniform to a Color3
  87353. * @param uniform defines the webGL uniform location where to store the value
  87354. * @param color3 defines the color to store
  87355. */
  87356. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87357. /**
  87358. * Set the value of an uniform to a Color3 and an alpha value
  87359. * @param uniform defines the webGL uniform location where to store the value
  87360. * @param color3 defines the color to store
  87361. * @param alpha defines the alpha component to store
  87362. */
  87363. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87364. /**
  87365. * Sets a Color4 on a uniform variable
  87366. * @param uniform defines the uniform location
  87367. * @param color4 defines the value to be set
  87368. */
  87369. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87370. /**
  87371. * Set various states to the webGL context
  87372. * @param culling defines backface culling state
  87373. * @param zOffset defines the value to apply to zOffset (0 by default)
  87374. * @param force defines if states must be applied even if cache is up to date
  87375. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87376. */
  87377. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87378. /**
  87379. * Set the z offset to apply to current rendering
  87380. * @param value defines the offset to apply
  87381. */
  87382. setZOffset(value: number): void;
  87383. /**
  87384. * Gets the current value of the zOffset
  87385. * @returns the current zOffset state
  87386. */
  87387. getZOffset(): number;
  87388. /**
  87389. * Enable or disable depth buffering
  87390. * @param enable defines the state to set
  87391. */
  87392. setDepthBuffer(enable: boolean): void;
  87393. /**
  87394. * Gets a boolean indicating if depth writing is enabled
  87395. * @returns the current depth writing state
  87396. */
  87397. getDepthWrite(): boolean;
  87398. /**
  87399. * Enable or disable depth writing
  87400. * @param enable defines the state to set
  87401. */
  87402. setDepthWrite(enable: boolean): void;
  87403. /**
  87404. * Enable or disable color writing
  87405. * @param enable defines the state to set
  87406. */
  87407. setColorWrite(enable: boolean): void;
  87408. /**
  87409. * Gets a boolean indicating if color writing is enabled
  87410. * @returns the current color writing state
  87411. */
  87412. getColorWrite(): boolean;
  87413. /**
  87414. * Sets alpha constants used by some alpha blending modes
  87415. * @param r defines the red component
  87416. * @param g defines the green component
  87417. * @param b defines the blue component
  87418. * @param a defines the alpha component
  87419. */
  87420. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87421. /**
  87422. * Sets the current alpha mode
  87423. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87424. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87426. */
  87427. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87428. /**
  87429. * Gets the current alpha mode
  87430. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87431. * @returns the current alpha mode
  87432. */
  87433. getAlphaMode(): number;
  87434. /**
  87435. * Clears the list of texture accessible through engine.
  87436. * This can help preventing texture load conflict due to name collision.
  87437. */
  87438. clearInternalTexturesCache(): void;
  87439. /**
  87440. * Force the entire cache to be cleared
  87441. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87442. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87443. */
  87444. wipeCaches(bruteForce?: boolean): void;
  87445. /**
  87446. * Set the compressed texture format to use, based on the formats you have, and the formats
  87447. * supported by the hardware / browser.
  87448. *
  87449. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87450. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87451. * to API arguments needed to compressed textures. This puts the burden on the container
  87452. * generator to house the arcane code for determining these for current & future formats.
  87453. *
  87454. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87455. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87456. *
  87457. * Note: The result of this call is not taken into account when a texture is base64.
  87458. *
  87459. * @param formatsAvailable defines the list of those format families you have created
  87460. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87461. *
  87462. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87463. * @returns The extension selected.
  87464. */
  87465. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87466. private _getSamplingParameters;
  87467. private _partialLoadImg;
  87468. private _cascadeLoadImgs;
  87469. /** @hidden */
  87470. _createTexture(): WebGLTexture;
  87471. /**
  87472. * Usually called from Texture.ts.
  87473. * Passed information to create a WebGLTexture
  87474. * @param urlArg defines a value which contains one of the following:
  87475. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87476. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87477. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87478. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87479. * @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)
  87480. * @param scene needed for loading to the correct scene
  87481. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87482. * @param onLoad optional callback to be called upon successful completion
  87483. * @param onError optional callback to be called upon failure
  87484. * @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
  87485. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87486. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87487. * @param forcedExtension defines the extension to use to pick the right loader
  87488. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87489. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87490. */
  87491. 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;
  87492. private _rescaleTexture;
  87493. /**
  87494. * Update a raw texture
  87495. * @param texture defines the texture to update
  87496. * @param data defines the data to store in the texture
  87497. * @param format defines the format of the data
  87498. * @param invertY defines if data must be stored with Y axis inverted
  87499. * @param compression defines the compression used (null by default)
  87500. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87501. */
  87502. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87503. /**
  87504. * Creates a raw texture
  87505. * @param data defines the data to store in the texture
  87506. * @param width defines the width of the texture
  87507. * @param height defines the height of the texture
  87508. * @param format defines the format of the data
  87509. * @param generateMipMaps defines if the engine should generate the mip levels
  87510. * @param invertY defines if data must be stored with Y axis inverted
  87511. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87512. * @param compression defines the compression used (null by default)
  87513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87514. * @returns the raw texture inside an InternalTexture
  87515. */
  87516. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87517. private _unpackFlipYCached;
  87518. /**
  87519. * In case you are sharing the context with other applications, it might
  87520. * be interested to not cache the unpack flip y state to ensure a consistent
  87521. * value would be set.
  87522. */
  87523. enableUnpackFlipYCached: boolean;
  87524. /** @hidden */
  87525. _unpackFlipY(value: boolean): void;
  87526. /** @hidden */
  87527. _getUnpackAlignement(): number;
  87528. /**
  87529. * Creates a dynamic texture
  87530. * @param width defines the width of the texture
  87531. * @param height defines the height of the texture
  87532. * @param generateMipMaps defines if the engine should generate the mip levels
  87533. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87534. * @returns the dynamic texture inside an InternalTexture
  87535. */
  87536. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87537. /**
  87538. * Update the sampling mode of a given texture
  87539. * @param samplingMode defines the required sampling mode
  87540. * @param texture defines the texture to update
  87541. */
  87542. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87543. /**
  87544. * Update the content of a dynamic texture
  87545. * @param texture defines the texture to update
  87546. * @param canvas defines the canvas containing the source
  87547. * @param invertY defines if data must be stored with Y axis inverted
  87548. * @param premulAlpha defines if alpha is stored as premultiplied
  87549. * @param format defines the format of the data
  87550. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87551. */
  87552. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87553. /**
  87554. * Update a video texture
  87555. * @param texture defines the texture to update
  87556. * @param video defines the video element to use
  87557. * @param invertY defines if data must be stored with Y axis inverted
  87558. */
  87559. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87560. /**
  87561. * Updates a depth texture Comparison Mode and Function.
  87562. * If the comparison Function is equal to 0, the mode will be set to none.
  87563. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87564. * @param texture The texture to set the comparison function for
  87565. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87566. */
  87567. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87568. private _setupDepthStencilTexture;
  87569. /**
  87570. * Creates a depth stencil texture.
  87571. * This is only available in WebGL 2 or with the depth texture extension available.
  87572. * @param size The size of face edge in the texture.
  87573. * @param options The options defining the texture.
  87574. * @returns The texture
  87575. */
  87576. createDepthStencilTexture(size: number | {
  87577. width: number;
  87578. height: number;
  87579. }, options: DepthTextureCreationOptions): InternalTexture;
  87580. /**
  87581. * Creates a depth stencil texture.
  87582. * This is only available in WebGL 2 or with the depth texture extension available.
  87583. * @param size The size of face edge in the texture.
  87584. * @param options The options defining the texture.
  87585. * @returns The texture
  87586. */
  87587. private _createDepthStencilTexture;
  87588. /**
  87589. * Creates a depth stencil cube texture.
  87590. * This is only available in WebGL 2.
  87591. * @param size The size of face edge in the cube texture.
  87592. * @param options The options defining the cube texture.
  87593. * @returns The cube texture
  87594. */
  87595. private _createDepthStencilCubeTexture;
  87596. /**
  87597. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87598. * @param renderTarget The render target to set the frame buffer for
  87599. */
  87600. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87601. /**
  87602. * Creates a new render target texture
  87603. * @param size defines the size of the texture
  87604. * @param options defines the options used to create the texture
  87605. * @returns a new render target texture stored in an InternalTexture
  87606. */
  87607. createRenderTargetTexture(size: number | {
  87608. width: number;
  87609. height: number;
  87610. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87611. /**
  87612. * Create a multi render target texture
  87613. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87614. * @param size defines the size of the texture
  87615. * @param options defines the creation options
  87616. * @returns the cube texture as an InternalTexture
  87617. */
  87618. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87619. private _setupFramebufferDepthAttachments;
  87620. /**
  87621. * Updates the sample count of a render target texture
  87622. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87623. * @param texture defines the texture to update
  87624. * @param samples defines the sample count to set
  87625. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87626. */
  87627. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87628. /**
  87629. * Update the sample count for a given multiple render target texture
  87630. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87631. * @param textures defines the textures to update
  87632. * @param samples defines the sample count to set
  87633. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87634. */
  87635. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87636. /** @hidden */
  87637. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87638. /** @hidden */
  87639. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87640. /** @hidden */
  87641. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87642. /** @hidden */
  87643. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87644. /**
  87645. * Creates a new render target cube texture
  87646. * @param size defines the size of the texture
  87647. * @param options defines the options used to create the texture
  87648. * @returns a new render target cube texture stored in an InternalTexture
  87649. */
  87650. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87651. /**
  87652. * Creates a cube texture
  87653. * @param rootUrl defines the url where the files to load is located
  87654. * @param scene defines the current scene
  87655. * @param files defines the list of files to load (1 per face)
  87656. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87657. * @param onLoad defines an optional callback raised when the texture is loaded
  87658. * @param onError defines an optional callback raised if there is an issue to load the texture
  87659. * @param format defines the format of the data
  87660. * @param forcedExtension defines the extension to use to pick the right loader
  87661. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87662. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87663. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87664. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87665. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87666. * @returns the cube texture as an InternalTexture
  87667. */
  87668. 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;
  87669. /**
  87670. * @hidden
  87671. */
  87672. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87673. /**
  87674. * Update a raw cube texture
  87675. * @param texture defines the texture to udpdate
  87676. * @param data defines the data to store
  87677. * @param format defines the data format
  87678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87679. * @param invertY defines if data must be stored with Y axis inverted
  87680. * @param compression defines the compression used (null by default)
  87681. * @param level defines which level of the texture to update
  87682. */
  87683. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87684. /**
  87685. * Creates a new raw cube texture
  87686. * @param data defines the array of data to use to create each face
  87687. * @param size defines the size of the textures
  87688. * @param format defines the format of the data
  87689. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87690. * @param generateMipMaps defines if the engine should generate the mip levels
  87691. * @param invertY defines if data must be stored with Y axis inverted
  87692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87693. * @param compression defines the compression used (null by default)
  87694. * @returns the cube texture as an InternalTexture
  87695. */
  87696. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87697. /**
  87698. * Creates a new raw cube texture from a specified url
  87699. * @param url defines the url where the data is located
  87700. * @param scene defines the current scene
  87701. * @param size defines the size of the textures
  87702. * @param format defines the format of the data
  87703. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87704. * @param noMipmap defines if the engine should avoid generating the mip levels
  87705. * @param callback defines a callback used to extract texture data from loaded data
  87706. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87707. * @param onLoad defines a callback called when texture is loaded
  87708. * @param onError defines a callback called if there is an error
  87709. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87710. * @param invertY defines if data must be stored with Y axis inverted
  87711. * @returns the cube texture as an InternalTexture
  87712. */
  87713. 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;
  87714. /**
  87715. * Update a raw 3D texture
  87716. * @param texture defines the texture to update
  87717. * @param data defines the data to store
  87718. * @param format defines the data format
  87719. * @param invertY defines if data must be stored with Y axis inverted
  87720. * @param compression defines the used compression (can be null)
  87721. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87722. */
  87723. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87724. /**
  87725. * Creates a new raw 3D texture
  87726. * @param data defines the data used to create the texture
  87727. * @param width defines the width of the texture
  87728. * @param height defines the height of the texture
  87729. * @param depth defines the depth of the texture
  87730. * @param format defines the format of the texture
  87731. * @param generateMipMaps defines if the engine must generate mip levels
  87732. * @param invertY defines if data must be stored with Y axis inverted
  87733. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87734. * @param compression defines the compressed used (can be null)
  87735. * @param textureType defines the compressed used (can be null)
  87736. * @returns a new raw 3D texture (stored in an InternalTexture)
  87737. */
  87738. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87739. private _prepareWebGLTextureContinuation;
  87740. private _prepareWebGLTexture;
  87741. private _convertRGBtoRGBATextureData;
  87742. /** @hidden */
  87743. _releaseFramebufferObjects(texture: InternalTexture): void;
  87744. /** @hidden */
  87745. _releaseTexture(texture: InternalTexture): void;
  87746. private setProgram;
  87747. private _boundUniforms;
  87748. /**
  87749. * Binds an effect to the webGL context
  87750. * @param effect defines the effect to bind
  87751. */
  87752. bindSamplers(effect: Effect): void;
  87753. private _moveBoundTextureOnTop;
  87754. private _getCorrectTextureChannel;
  87755. private _linkTrackers;
  87756. private _removeDesignatedSlot;
  87757. private _activateCurrentTexture;
  87758. /** @hidden */
  87759. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87760. /** @hidden */
  87761. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87762. /**
  87763. * Sets a texture to the webGL context from a postprocess
  87764. * @param channel defines the channel to use
  87765. * @param postProcess defines the source postprocess
  87766. */
  87767. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87768. /**
  87769. * Binds the output of the passed in post process to the texture channel specified
  87770. * @param channel The channel the texture should be bound to
  87771. * @param postProcess The post process which's output should be bound
  87772. */
  87773. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87774. /**
  87775. * Unbind all textures from the webGL context
  87776. */
  87777. unbindAllTextures(): void;
  87778. /**
  87779. * Sets a texture to the according uniform.
  87780. * @param channel The texture channel
  87781. * @param uniform The uniform to set
  87782. * @param texture The texture to apply
  87783. */
  87784. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87785. /**
  87786. * Sets a depth stencil texture from a render target to the according uniform.
  87787. * @param channel The texture channel
  87788. * @param uniform The uniform to set
  87789. * @param texture The render target texture containing the depth stencil texture to apply
  87790. */
  87791. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87792. private _bindSamplerUniformToChannel;
  87793. private _getTextureWrapMode;
  87794. private _setTexture;
  87795. /**
  87796. * Sets an array of texture to the webGL context
  87797. * @param channel defines the channel where the texture array must be set
  87798. * @param uniform defines the associated uniform location
  87799. * @param textures defines the array of textures to bind
  87800. */
  87801. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87802. /** @hidden */
  87803. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87804. private _setTextureParameterFloat;
  87805. private _setTextureParameterInteger;
  87806. /**
  87807. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87808. * @param x defines the x coordinate of the rectangle where pixels must be read
  87809. * @param y defines the y coordinate of the rectangle where pixels must be read
  87810. * @param width defines the width of the rectangle where pixels must be read
  87811. * @param height defines the height of the rectangle where pixels must be read
  87812. * @returns a Uint8Array containing RGBA colors
  87813. */
  87814. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87815. /**
  87816. * Add an externaly attached data from its key.
  87817. * This method call will fail and return false, if such key already exists.
  87818. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87819. * @param key the unique key that identifies the data
  87820. * @param data the data object to associate to the key for this Engine instance
  87821. * @return true if no such key were already present and the data was added successfully, false otherwise
  87822. */
  87823. addExternalData<T>(key: string, data: T): boolean;
  87824. /**
  87825. * Get an externaly attached data from its key
  87826. * @param key the unique key that identifies the data
  87827. * @return the associated data, if present (can be null), or undefined if not present
  87828. */
  87829. getExternalData<T>(key: string): T;
  87830. /**
  87831. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87832. * @param key the unique key that identifies the data
  87833. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87834. * @return the associated data, can be null if the factory returned null.
  87835. */
  87836. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87837. /**
  87838. * Remove an externaly attached data from the Engine instance
  87839. * @param key the unique key that identifies the data
  87840. * @return true if the data was successfully removed, false if it doesn't exist
  87841. */
  87842. removeExternalData(key: string): boolean;
  87843. /**
  87844. * Unbind all vertex attributes from the webGL context
  87845. */
  87846. unbindAllAttributes(): void;
  87847. /**
  87848. * 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
  87849. */
  87850. releaseEffects(): void;
  87851. /**
  87852. * Dispose and release all associated resources
  87853. */
  87854. dispose(): void;
  87855. /**
  87856. * Display the loading screen
  87857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87858. */
  87859. displayLoadingUI(): void;
  87860. /**
  87861. * Hide the loading screen
  87862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87863. */
  87864. hideLoadingUI(): void;
  87865. /**
  87866. * Gets the current loading screen object
  87867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87868. */
  87869. /**
  87870. * Sets the current loading screen object
  87871. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87872. */
  87873. loadingScreen: ILoadingScreen;
  87874. /**
  87875. * Sets the current loading screen text
  87876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87877. */
  87878. loadingUIText: string;
  87879. /**
  87880. * Sets the current loading screen background color
  87881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87882. */
  87883. loadingUIBackgroundColor: string;
  87884. /**
  87885. * Attach a new callback raised when context lost event is fired
  87886. * @param callback defines the callback to call
  87887. */
  87888. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87889. /**
  87890. * Attach a new callback raised when context restored event is fired
  87891. * @param callback defines the callback to call
  87892. */
  87893. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87894. /**
  87895. * Gets the source code of the vertex shader associated with a specific webGL program
  87896. * @param program defines the program to use
  87897. * @returns a string containing the source code of the vertex shader associated with the program
  87898. */
  87899. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87900. /**
  87901. * Gets the source code of the fragment shader associated with a specific webGL program
  87902. * @param program defines the program to use
  87903. * @returns a string containing the source code of the fragment shader associated with the program
  87904. */
  87905. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87906. /**
  87907. * Get the current error code of the webGL context
  87908. * @returns the error code
  87909. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87910. */
  87911. getError(): number;
  87912. /**
  87913. * Gets the current framerate
  87914. * @returns a number representing the framerate
  87915. */
  87916. getFps(): number;
  87917. /**
  87918. * Gets the time spent between current and previous frame
  87919. * @returns a number representing the delta time in ms
  87920. */
  87921. getDeltaTime(): number;
  87922. private _measureFps;
  87923. /** @hidden */
  87924. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87925. private _canRenderToFloatFramebuffer;
  87926. private _canRenderToHalfFloatFramebuffer;
  87927. private _canRenderToFramebuffer;
  87928. /** @hidden */
  87929. _getWebGLTextureType(type: number): number;
  87930. private _getInternalFormat;
  87931. /** @hidden */
  87932. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87933. /** @hidden */
  87934. _getRGBAMultiSampleBufferFormat(type: number): number;
  87935. /** @hidden */
  87936. _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;
  87937. /** @hidden */
  87938. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87939. private _partialLoadFile;
  87940. private _cascadeLoadFiles;
  87941. /**
  87942. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87943. * @returns true if the engine can be created
  87944. * @ignorenaming
  87945. */
  87946. static isSupported(): boolean;
  87947. }
  87948. }
  87949. declare module BABYLON {
  87950. /**
  87951. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87952. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87953. */
  87954. export class EffectFallbacks {
  87955. private _defines;
  87956. private _currentRank;
  87957. private _maxRank;
  87958. private _mesh;
  87959. /**
  87960. * Removes the fallback from the bound mesh.
  87961. */
  87962. unBindMesh(): void;
  87963. /**
  87964. * Adds a fallback on the specified property.
  87965. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87966. * @param define The name of the define in the shader
  87967. */
  87968. addFallback(rank: number, define: string): void;
  87969. /**
  87970. * Sets the mesh to use CPU skinning when needing to fallback.
  87971. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87972. * @param mesh The mesh to use the fallbacks.
  87973. */
  87974. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87975. /**
  87976. * Checks to see if more fallbacks are still availible.
  87977. */
  87978. readonly isMoreFallbacks: boolean;
  87979. /**
  87980. * Removes the defines that shoould be removed when falling back.
  87981. * @param currentDefines defines the current define statements for the shader.
  87982. * @param effect defines the current effect we try to compile
  87983. * @returns The resulting defines with defines of the current rank removed.
  87984. */
  87985. reduce(currentDefines: string, effect: Effect): string;
  87986. }
  87987. /**
  87988. * Options to be used when creating an effect.
  87989. */
  87990. export class EffectCreationOptions {
  87991. /**
  87992. * Atrributes that will be used in the shader.
  87993. */
  87994. attributes: string[];
  87995. /**
  87996. * Uniform varible names that will be set in the shader.
  87997. */
  87998. uniformsNames: string[];
  87999. /**
  88000. * Uniform buffer varible names that will be set in the shader.
  88001. */
  88002. uniformBuffersNames: string[];
  88003. /**
  88004. * Sampler texture variable names that will be set in the shader.
  88005. */
  88006. samplers: string[];
  88007. /**
  88008. * Define statements that will be set in the shader.
  88009. */
  88010. defines: any;
  88011. /**
  88012. * Possible fallbacks for this effect to improve performance when needed.
  88013. */
  88014. fallbacks: Nullable<EffectFallbacks>;
  88015. /**
  88016. * Callback that will be called when the shader is compiled.
  88017. */
  88018. onCompiled: Nullable<(effect: Effect) => void>;
  88019. /**
  88020. * Callback that will be called if an error occurs during shader compilation.
  88021. */
  88022. onError: Nullable<(effect: Effect, errors: string) => void>;
  88023. /**
  88024. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88025. */
  88026. indexParameters: any;
  88027. /**
  88028. * Max number of lights that can be used in the shader.
  88029. */
  88030. maxSimultaneousLights: number;
  88031. /**
  88032. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88033. */
  88034. transformFeedbackVaryings: Nullable<string[]>;
  88035. }
  88036. /**
  88037. * Effect containing vertex and fragment shader that can be executed on an object.
  88038. */
  88039. export class Effect {
  88040. /**
  88041. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88042. */
  88043. static ShadersRepository: string;
  88044. /**
  88045. * Name of the effect.
  88046. */
  88047. name: any;
  88048. /**
  88049. * String container all the define statements that should be set on the shader.
  88050. */
  88051. defines: string;
  88052. /**
  88053. * Callback that will be called when the shader is compiled.
  88054. */
  88055. onCompiled: Nullable<(effect: Effect) => void>;
  88056. /**
  88057. * Callback that will be called if an error occurs during shader compilation.
  88058. */
  88059. onError: Nullable<(effect: Effect, errors: string) => void>;
  88060. /**
  88061. * Callback that will be called when effect is bound.
  88062. */
  88063. onBind: Nullable<(effect: Effect) => void>;
  88064. /**
  88065. * Unique ID of the effect.
  88066. */
  88067. uniqueId: number;
  88068. /**
  88069. * Observable that will be called when the shader is compiled.
  88070. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88071. */
  88072. onCompileObservable: Observable<Effect>;
  88073. /**
  88074. * Observable that will be called if an error occurs during shader compilation.
  88075. */
  88076. onErrorObservable: Observable<Effect>;
  88077. /** @hidden */
  88078. _onBindObservable: Nullable<Observable<Effect>>;
  88079. /**
  88080. * Observable that will be called when effect is bound.
  88081. */
  88082. readonly onBindObservable: Observable<Effect>;
  88083. /** @hidden */
  88084. _bonesComputationForcedToCPU: boolean;
  88085. private static _uniqueIdSeed;
  88086. private _engine;
  88087. private _uniformBuffersNames;
  88088. private _uniformsNames;
  88089. private _samplers;
  88090. private _isReady;
  88091. private _compilationError;
  88092. private _attributesNames;
  88093. private _attributes;
  88094. private _uniforms;
  88095. /**
  88096. * Key for the effect.
  88097. * @hidden
  88098. */
  88099. _key: string;
  88100. private _indexParameters;
  88101. private _fallbacks;
  88102. private _vertexSourceCode;
  88103. private _fragmentSourceCode;
  88104. private _vertexSourceCodeOverride;
  88105. private _fragmentSourceCodeOverride;
  88106. private _transformFeedbackVaryings;
  88107. /**
  88108. * Compiled shader to webGL program.
  88109. * @hidden
  88110. */
  88111. _program: WebGLProgram;
  88112. private _valueCache;
  88113. private static _baseCache;
  88114. /**
  88115. * Instantiates an effect.
  88116. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88117. * @param baseName Name of the effect.
  88118. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88119. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88120. * @param samplers List of sampler variables that will be passed to the shader.
  88121. * @param engine Engine to be used to render the effect
  88122. * @param defines Define statements to be added to the shader.
  88123. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88124. * @param onCompiled Callback that will be called when the shader is compiled.
  88125. * @param onError Callback that will be called if an error occurs during shader compilation.
  88126. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88127. */
  88128. 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);
  88129. /**
  88130. * Unique key for this effect
  88131. */
  88132. readonly key: string;
  88133. /**
  88134. * If the effect has been compiled and prepared.
  88135. * @returns if the effect is compiled and prepared.
  88136. */
  88137. isReady(): boolean;
  88138. /**
  88139. * The engine the effect was initialized with.
  88140. * @returns the engine.
  88141. */
  88142. getEngine(): Engine;
  88143. /**
  88144. * The compiled webGL program for the effect
  88145. * @returns the webGL program.
  88146. */
  88147. getProgram(): WebGLProgram;
  88148. /**
  88149. * The set of names of attribute variables for the shader.
  88150. * @returns An array of attribute names.
  88151. */
  88152. getAttributesNames(): string[];
  88153. /**
  88154. * Returns the attribute at the given index.
  88155. * @param index The index of the attribute.
  88156. * @returns The location of the attribute.
  88157. */
  88158. getAttributeLocation(index: number): number;
  88159. /**
  88160. * Returns the attribute based on the name of the variable.
  88161. * @param name of the attribute to look up.
  88162. * @returns the attribute location.
  88163. */
  88164. getAttributeLocationByName(name: string): number;
  88165. /**
  88166. * The number of attributes.
  88167. * @returns the numnber of attributes.
  88168. */
  88169. getAttributesCount(): number;
  88170. /**
  88171. * Gets the index of a uniform variable.
  88172. * @param uniformName of the uniform to look up.
  88173. * @returns the index.
  88174. */
  88175. getUniformIndex(uniformName: string): number;
  88176. /**
  88177. * Returns the attribute based on the name of the variable.
  88178. * @param uniformName of the uniform to look up.
  88179. * @returns the location of the uniform.
  88180. */
  88181. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88182. /**
  88183. * Returns an array of sampler variable names
  88184. * @returns The array of sampler variable neames.
  88185. */
  88186. getSamplers(): string[];
  88187. /**
  88188. * The error from the last compilation.
  88189. * @returns the error string.
  88190. */
  88191. getCompilationError(): string;
  88192. /**
  88193. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88194. * @param func The callback to be used.
  88195. */
  88196. executeWhenCompiled(func: (effect: Effect) => void): void;
  88197. private _checkIsReady;
  88198. /** @hidden */
  88199. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88200. /** @hidden */
  88201. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88202. /** @hidden */
  88203. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88204. private _processShaderConversion;
  88205. private _processIncludes;
  88206. private _processPrecision;
  88207. /**
  88208. * Recompiles the webGL program
  88209. * @param vertexSourceCode The source code for the vertex shader.
  88210. * @param fragmentSourceCode The source code for the fragment shader.
  88211. * @param onCompiled Callback called when completed.
  88212. * @param onError Callback called on error.
  88213. * @hidden
  88214. */
  88215. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88216. /**
  88217. * Gets the uniform locations of the the specified variable names
  88218. * @param names THe names of the variables to lookup.
  88219. * @returns Array of locations in the same order as variable names.
  88220. */
  88221. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88222. /**
  88223. * Prepares the effect
  88224. * @hidden
  88225. */
  88226. _prepareEffect(): void;
  88227. /**
  88228. * Checks if the effect is supported. (Must be called after compilation)
  88229. */
  88230. readonly isSupported: boolean;
  88231. /**
  88232. * Binds a texture to the engine to be used as output of the shader.
  88233. * @param channel Name of the output variable.
  88234. * @param texture Texture to bind.
  88235. * @hidden
  88236. */
  88237. _bindTexture(channel: string, texture: InternalTexture): void;
  88238. /**
  88239. * Sets a texture on the engine to be used in the shader.
  88240. * @param channel Name of the sampler variable.
  88241. * @param texture Texture to set.
  88242. */
  88243. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88244. /**
  88245. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88246. * @param channel Name of the sampler variable.
  88247. * @param texture Texture to set.
  88248. */
  88249. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88250. /**
  88251. * Sets an array of textures on the engine to be used in the shader.
  88252. * @param channel Name of the variable.
  88253. * @param textures Textures to set.
  88254. */
  88255. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88256. /**
  88257. * 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)
  88258. * @param channel Name of the sampler variable.
  88259. * @param postProcess Post process to get the input texture from.
  88260. */
  88261. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88262. /**
  88263. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88264. * 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)
  88265. * @param channel Name of the sampler variable.
  88266. * @param postProcess Post process to get the output texture from.
  88267. */
  88268. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88269. /** @hidden */
  88270. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88271. /** @hidden */
  88272. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88273. /** @hidden */
  88274. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88275. /** @hidden */
  88276. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88277. /**
  88278. * Binds a buffer to a uniform.
  88279. * @param buffer Buffer to bind.
  88280. * @param name Name of the uniform variable to bind to.
  88281. */
  88282. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88283. /**
  88284. * Binds block to a uniform.
  88285. * @param blockName Name of the block to bind.
  88286. * @param index Index to bind.
  88287. */
  88288. bindUniformBlock(blockName: string, index: number): void;
  88289. /**
  88290. * Sets an interger value on a uniform variable.
  88291. * @param uniformName Name of the variable.
  88292. * @param value Value to be set.
  88293. * @returns this effect.
  88294. */
  88295. setInt(uniformName: string, value: number): Effect;
  88296. /**
  88297. * Sets an int array on a uniform variable.
  88298. * @param uniformName Name of the variable.
  88299. * @param array array to be set.
  88300. * @returns this effect.
  88301. */
  88302. setIntArray(uniformName: string, array: Int32Array): Effect;
  88303. /**
  88304. * 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)
  88305. * @param uniformName Name of the variable.
  88306. * @param array array to be set.
  88307. * @returns this effect.
  88308. */
  88309. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88310. /**
  88311. * 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)
  88312. * @param uniformName Name of the variable.
  88313. * @param array array to be set.
  88314. * @returns this effect.
  88315. */
  88316. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88317. /**
  88318. * 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)
  88319. * @param uniformName Name of the variable.
  88320. * @param array array to be set.
  88321. * @returns this effect.
  88322. */
  88323. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88324. /**
  88325. * Sets an float array on a uniform variable.
  88326. * @param uniformName Name of the variable.
  88327. * @param array array to be set.
  88328. * @returns this effect.
  88329. */
  88330. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88331. /**
  88332. * 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)
  88333. * @param uniformName Name of the variable.
  88334. * @param array array to be set.
  88335. * @returns this effect.
  88336. */
  88337. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88338. /**
  88339. * 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)
  88340. * @param uniformName Name of the variable.
  88341. * @param array array to be set.
  88342. * @returns this effect.
  88343. */
  88344. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88345. /**
  88346. * 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)
  88347. * @param uniformName Name of the variable.
  88348. * @param array array to be set.
  88349. * @returns this effect.
  88350. */
  88351. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88352. /**
  88353. * Sets an array on a uniform variable.
  88354. * @param uniformName Name of the variable.
  88355. * @param array array to be set.
  88356. * @returns this effect.
  88357. */
  88358. setArray(uniformName: string, array: number[]): Effect;
  88359. /**
  88360. * 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)
  88361. * @param uniformName Name of the variable.
  88362. * @param array array to be set.
  88363. * @returns this effect.
  88364. */
  88365. setArray2(uniformName: string, array: number[]): Effect;
  88366. /**
  88367. * 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)
  88368. * @param uniformName Name of the variable.
  88369. * @param array array to be set.
  88370. * @returns this effect.
  88371. */
  88372. setArray3(uniformName: string, array: number[]): Effect;
  88373. /**
  88374. * 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)
  88375. * @param uniformName Name of the variable.
  88376. * @param array array to be set.
  88377. * @returns this effect.
  88378. */
  88379. setArray4(uniformName: string, array: number[]): Effect;
  88380. /**
  88381. * Sets matrices on a uniform variable.
  88382. * @param uniformName Name of the variable.
  88383. * @param matrices matrices to be set.
  88384. * @returns this effect.
  88385. */
  88386. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88387. /**
  88388. * Sets matrix on a uniform variable.
  88389. * @param uniformName Name of the variable.
  88390. * @param matrix matrix to be set.
  88391. * @returns this effect.
  88392. */
  88393. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88394. /**
  88395. * 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)
  88396. * @param uniformName Name of the variable.
  88397. * @param matrix matrix to be set.
  88398. * @returns this effect.
  88399. */
  88400. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88401. /**
  88402. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88403. * @param uniformName Name of the variable.
  88404. * @param matrix matrix to be set.
  88405. * @returns this effect.
  88406. */
  88407. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88408. /**
  88409. * Sets a float on a uniform variable.
  88410. * @param uniformName Name of the variable.
  88411. * @param value value to be set.
  88412. * @returns this effect.
  88413. */
  88414. setFloat(uniformName: string, value: number): Effect;
  88415. /**
  88416. * Sets a boolean on a uniform variable.
  88417. * @param uniformName Name of the variable.
  88418. * @param bool value to be set.
  88419. * @returns this effect.
  88420. */
  88421. setBool(uniformName: string, bool: boolean): Effect;
  88422. /**
  88423. * Sets a Vector2 on a uniform variable.
  88424. * @param uniformName Name of the variable.
  88425. * @param vector2 vector2 to be set.
  88426. * @returns this effect.
  88427. */
  88428. setVector2(uniformName: string, vector2: Vector2): Effect;
  88429. /**
  88430. * Sets a float2 on a uniform variable.
  88431. * @param uniformName Name of the variable.
  88432. * @param x First float in float2.
  88433. * @param y Second float in float2.
  88434. * @returns this effect.
  88435. */
  88436. setFloat2(uniformName: string, x: number, y: number): Effect;
  88437. /**
  88438. * Sets a Vector3 on a uniform variable.
  88439. * @param uniformName Name of the variable.
  88440. * @param vector3 Value to be set.
  88441. * @returns this effect.
  88442. */
  88443. setVector3(uniformName: string, vector3: Vector3): Effect;
  88444. /**
  88445. * Sets a float3 on a uniform variable.
  88446. * @param uniformName Name of the variable.
  88447. * @param x First float in float3.
  88448. * @param y Second float in float3.
  88449. * @param z Third float in float3.
  88450. * @returns this effect.
  88451. */
  88452. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88453. /**
  88454. * Sets a Vector4 on a uniform variable.
  88455. * @param uniformName Name of the variable.
  88456. * @param vector4 Value to be set.
  88457. * @returns this effect.
  88458. */
  88459. setVector4(uniformName: string, vector4: Vector4): Effect;
  88460. /**
  88461. * Sets a float4 on a uniform variable.
  88462. * @param uniformName Name of the variable.
  88463. * @param x First float in float4.
  88464. * @param y Second float in float4.
  88465. * @param z Third float in float4.
  88466. * @param w Fourth float in float4.
  88467. * @returns this effect.
  88468. */
  88469. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88470. /**
  88471. * Sets a Color3 on a uniform variable.
  88472. * @param uniformName Name of the variable.
  88473. * @param color3 Value to be set.
  88474. * @returns this effect.
  88475. */
  88476. setColor3(uniformName: string, color3: Color3): Effect;
  88477. /**
  88478. * Sets a Color4 on a uniform variable.
  88479. * @param uniformName Name of the variable.
  88480. * @param color3 Value to be set.
  88481. * @param alpha Alpha value to be set.
  88482. * @returns this effect.
  88483. */
  88484. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88485. /**
  88486. * Sets a Color4 on a uniform variable
  88487. * @param uniformName defines the name of the variable
  88488. * @param color4 defines the value to be set
  88489. * @returns this effect.
  88490. */
  88491. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88492. /**
  88493. * This function will add a new shader to the shader store
  88494. * @param name the name of the shader
  88495. * @param pixelShader optional pixel shader content
  88496. * @param vertexShader optional vertex shader content
  88497. */
  88498. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88499. /**
  88500. * Store of each shader (The can be looked up using effect.key)
  88501. */
  88502. static ShadersStore: {
  88503. [key: string]: string;
  88504. };
  88505. /**
  88506. * Store of each included file for a shader (The can be looked up using effect.key)
  88507. */
  88508. static IncludesShadersStore: {
  88509. [key: string]: string;
  88510. };
  88511. /**
  88512. * Resets the cache of effects.
  88513. */
  88514. static ResetCache(): void;
  88515. }
  88516. }
  88517. declare module BABYLON {
  88518. /**
  88519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88521. * 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;
  88522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88523. */
  88524. export class ColorCurves {
  88525. private _dirty;
  88526. private _tempColor;
  88527. private _globalCurve;
  88528. private _highlightsCurve;
  88529. private _midtonesCurve;
  88530. private _shadowsCurve;
  88531. private _positiveCurve;
  88532. private _negativeCurve;
  88533. private _globalHue;
  88534. private _globalDensity;
  88535. private _globalSaturation;
  88536. private _globalExposure;
  88537. /**
  88538. * Gets the global Hue value.
  88539. * 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).
  88540. */
  88541. /**
  88542. * Sets the global Hue value.
  88543. * 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).
  88544. */
  88545. globalHue: number;
  88546. /**
  88547. * Gets the global Density value.
  88548. * 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.
  88549. * Values less than zero provide a filter of opposite hue.
  88550. */
  88551. /**
  88552. * Sets the global Density value.
  88553. * 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.
  88554. * Values less than zero provide a filter of opposite hue.
  88555. */
  88556. globalDensity: number;
  88557. /**
  88558. * Gets the global Saturation value.
  88559. * 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.
  88560. */
  88561. /**
  88562. * Sets the global Saturation value.
  88563. * 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.
  88564. */
  88565. globalSaturation: number;
  88566. /**
  88567. * Gets the global Exposure value.
  88568. * 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.
  88569. */
  88570. /**
  88571. * Sets the global Exposure value.
  88572. * 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.
  88573. */
  88574. globalExposure: number;
  88575. private _highlightsHue;
  88576. private _highlightsDensity;
  88577. private _highlightsSaturation;
  88578. private _highlightsExposure;
  88579. /**
  88580. * Gets the highlights Hue value.
  88581. * 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).
  88582. */
  88583. /**
  88584. * Sets the highlights Hue value.
  88585. * 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).
  88586. */
  88587. highlightsHue: number;
  88588. /**
  88589. * Gets the highlights Density value.
  88590. * 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.
  88591. * Values less than zero provide a filter of opposite hue.
  88592. */
  88593. /**
  88594. * Sets the highlights Density value.
  88595. * 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.
  88596. * Values less than zero provide a filter of opposite hue.
  88597. */
  88598. highlightsDensity: number;
  88599. /**
  88600. * Gets the highlights Saturation value.
  88601. * 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.
  88602. */
  88603. /**
  88604. * Sets the highlights Saturation value.
  88605. * 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.
  88606. */
  88607. highlightsSaturation: number;
  88608. /**
  88609. * Gets the highlights Exposure value.
  88610. * 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.
  88611. */
  88612. /**
  88613. * Sets the highlights Exposure value.
  88614. * 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.
  88615. */
  88616. highlightsExposure: number;
  88617. private _midtonesHue;
  88618. private _midtonesDensity;
  88619. private _midtonesSaturation;
  88620. private _midtonesExposure;
  88621. /**
  88622. * Gets the midtones Hue value.
  88623. * 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).
  88624. */
  88625. /**
  88626. * Sets the midtones Hue value.
  88627. * 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).
  88628. */
  88629. midtonesHue: number;
  88630. /**
  88631. * Gets the midtones Density value.
  88632. * 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.
  88633. * Values less than zero provide a filter of opposite hue.
  88634. */
  88635. /**
  88636. * Sets the midtones Density value.
  88637. * 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.
  88638. * Values less than zero provide a filter of opposite hue.
  88639. */
  88640. midtonesDensity: number;
  88641. /**
  88642. * Gets the midtones Saturation value.
  88643. * 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.
  88644. */
  88645. /**
  88646. * Sets the midtones Saturation value.
  88647. * 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.
  88648. */
  88649. midtonesSaturation: number;
  88650. /**
  88651. * Gets the midtones Exposure value.
  88652. * 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.
  88653. */
  88654. /**
  88655. * Sets the midtones Exposure value.
  88656. * 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.
  88657. */
  88658. midtonesExposure: number;
  88659. private _shadowsHue;
  88660. private _shadowsDensity;
  88661. private _shadowsSaturation;
  88662. private _shadowsExposure;
  88663. /**
  88664. * Gets the shadows Hue value.
  88665. * 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).
  88666. */
  88667. /**
  88668. * Sets the shadows Hue value.
  88669. * 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).
  88670. */
  88671. shadowsHue: number;
  88672. /**
  88673. * Gets the shadows Density value.
  88674. * 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.
  88675. * Values less than zero provide a filter of opposite hue.
  88676. */
  88677. /**
  88678. * Sets the shadows Density value.
  88679. * 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.
  88680. * Values less than zero provide a filter of opposite hue.
  88681. */
  88682. shadowsDensity: number;
  88683. /**
  88684. * Gets the shadows Saturation value.
  88685. * 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.
  88686. */
  88687. /**
  88688. * Sets the shadows Saturation value.
  88689. * 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.
  88690. */
  88691. shadowsSaturation: number;
  88692. /**
  88693. * Gets the shadows Exposure value.
  88694. * 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.
  88695. */
  88696. /**
  88697. * Sets the shadows Exposure value.
  88698. * 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.
  88699. */
  88700. shadowsExposure: number;
  88701. /**
  88702. * Returns the class name
  88703. * @returns The class name
  88704. */
  88705. getClassName(): string;
  88706. /**
  88707. * Binds the color curves to the shader.
  88708. * @param colorCurves The color curve to bind
  88709. * @param effect The effect to bind to
  88710. * @param positiveUniform The positive uniform shader parameter
  88711. * @param neutralUniform The neutral uniform shader parameter
  88712. * @param negativeUniform The negative uniform shader parameter
  88713. */
  88714. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88715. /**
  88716. * Prepare the list of uniforms associated with the ColorCurves effects.
  88717. * @param uniformsList The list of uniforms used in the effect
  88718. */
  88719. static PrepareUniforms(uniformsList: string[]): void;
  88720. /**
  88721. * Returns color grading data based on a hue, density, saturation and exposure value.
  88722. * @param filterHue The hue of the color filter.
  88723. * @param filterDensity The density of the color filter.
  88724. * @param saturation The saturation.
  88725. * @param exposure The exposure.
  88726. * @param result The result data container.
  88727. */
  88728. private getColorGradingDataToRef;
  88729. /**
  88730. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88731. * @param value The input slider value in range [-100,100].
  88732. * @returns Adjusted value.
  88733. */
  88734. private static applyColorGradingSliderNonlinear;
  88735. /**
  88736. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88737. * @param hue The hue (H) input.
  88738. * @param saturation The saturation (S) input.
  88739. * @param brightness The brightness (B) input.
  88740. * @result An RGBA color represented as Vector4.
  88741. */
  88742. private static fromHSBToRef;
  88743. /**
  88744. * Returns a value clamped between min and max
  88745. * @param value The value to clamp
  88746. * @param min The minimum of value
  88747. * @param max The maximum of value
  88748. * @returns The clamped value.
  88749. */
  88750. private static clamp;
  88751. /**
  88752. * Clones the current color curve instance.
  88753. * @return The cloned curves
  88754. */
  88755. clone(): ColorCurves;
  88756. /**
  88757. * Serializes the current color curve instance to a json representation.
  88758. * @return a JSON representation
  88759. */
  88760. serialize(): any;
  88761. /**
  88762. * Parses the color curve from a json representation.
  88763. * @param source the JSON source to parse
  88764. * @return The parsed curves
  88765. */
  88766. static Parse(source: any): ColorCurves;
  88767. }
  88768. }
  88769. declare module BABYLON {
  88770. /**
  88771. * Interface to follow in your material defines to integrate easily the
  88772. * Image proccessing functions.
  88773. * @hidden
  88774. */
  88775. export interface IImageProcessingConfigurationDefines {
  88776. IMAGEPROCESSING: boolean;
  88777. VIGNETTE: boolean;
  88778. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88779. VIGNETTEBLENDMODEOPAQUE: boolean;
  88780. TONEMAPPING: boolean;
  88781. TONEMAPPING_ACES: boolean;
  88782. CONTRAST: boolean;
  88783. EXPOSURE: boolean;
  88784. COLORCURVES: boolean;
  88785. COLORGRADING: boolean;
  88786. COLORGRADING3D: boolean;
  88787. SAMPLER3DGREENDEPTH: boolean;
  88788. SAMPLER3DBGRMAP: boolean;
  88789. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88790. }
  88791. /**
  88792. * @hidden
  88793. */
  88794. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88795. IMAGEPROCESSING: boolean;
  88796. VIGNETTE: boolean;
  88797. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88798. VIGNETTEBLENDMODEOPAQUE: boolean;
  88799. TONEMAPPING: boolean;
  88800. TONEMAPPING_ACES: boolean;
  88801. CONTRAST: boolean;
  88802. COLORCURVES: boolean;
  88803. COLORGRADING: boolean;
  88804. COLORGRADING3D: boolean;
  88805. SAMPLER3DGREENDEPTH: boolean;
  88806. SAMPLER3DBGRMAP: boolean;
  88807. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88808. EXPOSURE: boolean;
  88809. constructor();
  88810. }
  88811. /**
  88812. * This groups together the common properties used for image processing either in direct forward pass
  88813. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88814. * or not.
  88815. */
  88816. export class ImageProcessingConfiguration {
  88817. /**
  88818. * Default tone mapping applied in BabylonJS.
  88819. */
  88820. static readonly TONEMAPPING_STANDARD: number;
  88821. /**
  88822. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88823. * to other engines rendering to increase portability.
  88824. */
  88825. static readonly TONEMAPPING_ACES: number;
  88826. /**
  88827. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88828. */
  88829. colorCurves: Nullable<ColorCurves>;
  88830. private _colorCurvesEnabled;
  88831. /**
  88832. * Gets wether the color curves effect is enabled.
  88833. */
  88834. /**
  88835. * Sets wether the color curves effect is enabled.
  88836. */
  88837. colorCurvesEnabled: boolean;
  88838. private _colorGradingTexture;
  88839. /**
  88840. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88841. */
  88842. /**
  88843. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88844. */
  88845. colorGradingTexture: Nullable<BaseTexture>;
  88846. private _colorGradingEnabled;
  88847. /**
  88848. * Gets wether the color grading effect is enabled.
  88849. */
  88850. /**
  88851. * Sets wether the color grading effect is enabled.
  88852. */
  88853. colorGradingEnabled: boolean;
  88854. private _colorGradingWithGreenDepth;
  88855. /**
  88856. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88857. */
  88858. /**
  88859. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88860. */
  88861. colorGradingWithGreenDepth: boolean;
  88862. private _colorGradingBGR;
  88863. /**
  88864. * Gets wether the color grading texture contains BGR values.
  88865. */
  88866. /**
  88867. * Sets wether the color grading texture contains BGR values.
  88868. */
  88869. colorGradingBGR: boolean;
  88870. /** @hidden */
  88871. _exposure: number;
  88872. /**
  88873. * Gets the Exposure used in the effect.
  88874. */
  88875. /**
  88876. * Sets the Exposure used in the effect.
  88877. */
  88878. exposure: number;
  88879. private _toneMappingEnabled;
  88880. /**
  88881. * Gets wether the tone mapping effect is enabled.
  88882. */
  88883. /**
  88884. * Sets wether the tone mapping effect is enabled.
  88885. */
  88886. toneMappingEnabled: boolean;
  88887. private _toneMappingType;
  88888. /**
  88889. * Gets the type of tone mapping effect.
  88890. */
  88891. /**
  88892. * Sets the type of tone mapping effect used in BabylonJS.
  88893. */
  88894. toneMappingType: number;
  88895. protected _contrast: number;
  88896. /**
  88897. * Gets the contrast used in the effect.
  88898. */
  88899. /**
  88900. * Sets the contrast used in the effect.
  88901. */
  88902. contrast: number;
  88903. /**
  88904. * Vignette stretch size.
  88905. */
  88906. vignetteStretch: number;
  88907. /**
  88908. * Vignette centre X Offset.
  88909. */
  88910. vignetteCentreX: number;
  88911. /**
  88912. * Vignette centre Y Offset.
  88913. */
  88914. vignetteCentreY: number;
  88915. /**
  88916. * Vignette weight or intensity of the vignette effect.
  88917. */
  88918. vignetteWeight: number;
  88919. /**
  88920. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88921. * if vignetteEnabled is set to true.
  88922. */
  88923. vignetteColor: Color4;
  88924. /**
  88925. * Camera field of view used by the Vignette effect.
  88926. */
  88927. vignetteCameraFov: number;
  88928. private _vignetteBlendMode;
  88929. /**
  88930. * Gets the vignette blend mode allowing different kind of effect.
  88931. */
  88932. /**
  88933. * Sets the vignette blend mode allowing different kind of effect.
  88934. */
  88935. vignetteBlendMode: number;
  88936. private _vignetteEnabled;
  88937. /**
  88938. * Gets wether the vignette effect is enabled.
  88939. */
  88940. /**
  88941. * Sets wether the vignette effect is enabled.
  88942. */
  88943. vignetteEnabled: boolean;
  88944. private _applyByPostProcess;
  88945. /**
  88946. * Gets wether the image processing is applied through a post process or not.
  88947. */
  88948. /**
  88949. * Sets wether the image processing is applied through a post process or not.
  88950. */
  88951. applyByPostProcess: boolean;
  88952. private _isEnabled;
  88953. /**
  88954. * Gets wether the image processing is enabled or not.
  88955. */
  88956. /**
  88957. * Sets wether the image processing is enabled or not.
  88958. */
  88959. isEnabled: boolean;
  88960. /**
  88961. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88962. */
  88963. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88964. /**
  88965. * Method called each time the image processing information changes requires to recompile the effect.
  88966. */
  88967. protected _updateParameters(): void;
  88968. /**
  88969. * Gets the current class name.
  88970. * @return "ImageProcessingConfiguration"
  88971. */
  88972. getClassName(): string;
  88973. /**
  88974. * Prepare the list of uniforms associated with the Image Processing effects.
  88975. * @param uniforms The list of uniforms used in the effect
  88976. * @param defines the list of defines currently in use
  88977. */
  88978. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88979. /**
  88980. * Prepare the list of samplers associated with the Image Processing effects.
  88981. * @param samplersList The list of uniforms used in the effect
  88982. * @param defines the list of defines currently in use
  88983. */
  88984. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88985. /**
  88986. * Prepare the list of defines associated to the shader.
  88987. * @param defines the list of defines to complete
  88988. * @param forPostProcess Define if we are currently in post process mode or not
  88989. */
  88990. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88991. /**
  88992. * Returns true if all the image processing information are ready.
  88993. * @returns True if ready, otherwise, false
  88994. */
  88995. isReady(): boolean;
  88996. /**
  88997. * Binds the image processing to the shader.
  88998. * @param effect The effect to bind to
  88999. * @param aspectRatio Define the current aspect ratio of the effect
  89000. */
  89001. bind(effect: Effect, aspectRatio?: number): void;
  89002. /**
  89003. * Clones the current image processing instance.
  89004. * @return The cloned image processing
  89005. */
  89006. clone(): ImageProcessingConfiguration;
  89007. /**
  89008. * Serializes the current image processing instance to a json representation.
  89009. * @return a JSON representation
  89010. */
  89011. serialize(): any;
  89012. /**
  89013. * Parses the image processing from a json representation.
  89014. * @param source the JSON source to parse
  89015. * @return The parsed image processing
  89016. */
  89017. static Parse(source: any): ImageProcessingConfiguration;
  89018. private static _VIGNETTEMODE_MULTIPLY;
  89019. private static _VIGNETTEMODE_OPAQUE;
  89020. /**
  89021. * Used to apply the vignette as a mix with the pixel color.
  89022. */
  89023. static readonly VIGNETTEMODE_MULTIPLY: number;
  89024. /**
  89025. * Used to apply the vignette as a replacement of the pixel color.
  89026. */
  89027. static readonly VIGNETTEMODE_OPAQUE: number;
  89028. }
  89029. }
  89030. declare module BABYLON {
  89031. /**
  89032. * This represents all the required information to add a fresnel effect on a material:
  89033. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89034. */
  89035. export class FresnelParameters {
  89036. private _isEnabled;
  89037. /**
  89038. * Define if the fresnel effect is enable or not.
  89039. */
  89040. isEnabled: boolean;
  89041. /**
  89042. * Define the color used on edges (grazing angle)
  89043. */
  89044. leftColor: Color3;
  89045. /**
  89046. * Define the color used on center
  89047. */
  89048. rightColor: Color3;
  89049. /**
  89050. * Define bias applied to computed fresnel term
  89051. */
  89052. bias: number;
  89053. /**
  89054. * Defined the power exponent applied to fresnel term
  89055. */
  89056. power: number;
  89057. /**
  89058. * Clones the current fresnel and its valuues
  89059. * @returns a clone fresnel configuration
  89060. */
  89061. clone(): FresnelParameters;
  89062. /**
  89063. * Serializes the current fresnel parameters to a JSON representation.
  89064. * @return the JSON serialization
  89065. */
  89066. serialize(): any;
  89067. /**
  89068. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89069. * @param parsedFresnelParameters Define the JSON representation
  89070. * @returns the parsed parameters
  89071. */
  89072. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89073. }
  89074. }
  89075. declare module BABYLON {
  89076. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89077. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89078. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89079. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89080. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89081. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89082. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89083. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89084. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89085. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89086. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89087. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89088. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89089. /**
  89090. * Decorator used to define property that can be serialized as reference to a camera
  89091. * @param sourceName defines the name of the property to decorate
  89092. */
  89093. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89094. /**
  89095. * Class used to help serialization objects
  89096. */
  89097. export class SerializationHelper {
  89098. /** hidden */
  89099. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89100. /** hidden */
  89101. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89102. /** hidden */
  89103. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89104. /** hidden */
  89105. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89106. /**
  89107. * Appends the serialized animations from the source animations
  89108. * @param source Source containing the animations
  89109. * @param destination Target to store the animations
  89110. */
  89111. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89112. /**
  89113. * Static function used to serialized a specific entity
  89114. * @param entity defines the entity to serialize
  89115. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89116. * @returns a JSON compatible object representing the serialization of the entity
  89117. */
  89118. static Serialize<T>(entity: T, serializationObject?: any): any;
  89119. /**
  89120. * Creates a new entity from a serialization data object
  89121. * @param creationFunction defines a function used to instanciated the new entity
  89122. * @param source defines the source serialization data
  89123. * @param scene defines the hosting scene
  89124. * @param rootUrl defines the root url for resources
  89125. * @returns a new entity
  89126. */
  89127. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89128. /**
  89129. * Clones an object
  89130. * @param creationFunction defines the function used to instanciate the new object
  89131. * @param source defines the source object
  89132. * @returns the cloned object
  89133. */
  89134. static Clone<T>(creationFunction: () => T, source: T): T;
  89135. /**
  89136. * Instanciates a new object based on a source one (some data will be shared between both object)
  89137. * @param creationFunction defines the function used to instanciate the new object
  89138. * @param source defines the source object
  89139. * @returns the new object
  89140. */
  89141. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89142. }
  89143. }
  89144. declare module BABYLON {
  89145. /**
  89146. * This is the base class of all the camera used in the application.
  89147. * @see http://doc.babylonjs.com/features/cameras
  89148. */
  89149. export class Camera extends Node {
  89150. /** @hidden */
  89151. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89152. /**
  89153. * This is the default projection mode used by the cameras.
  89154. * It helps recreating a feeling of perspective and better appreciate depth.
  89155. * This is the best way to simulate real life cameras.
  89156. */
  89157. static readonly PERSPECTIVE_CAMERA: number;
  89158. /**
  89159. * This helps creating camera with an orthographic mode.
  89160. * 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.
  89161. */
  89162. static readonly ORTHOGRAPHIC_CAMERA: number;
  89163. /**
  89164. * This is the default FOV mode for perspective cameras.
  89165. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89166. */
  89167. static readonly FOVMODE_VERTICAL_FIXED: number;
  89168. /**
  89169. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89170. */
  89171. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89172. /**
  89173. * This specifies ther is no need for a camera rig.
  89174. * Basically only one eye is rendered corresponding to the camera.
  89175. */
  89176. static readonly RIG_MODE_NONE: number;
  89177. /**
  89178. * Simulates a camera Rig with one blue eye and one red eye.
  89179. * This can be use with 3d blue and red glasses.
  89180. */
  89181. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89182. /**
  89183. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89184. */
  89185. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89186. /**
  89187. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89188. */
  89189. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89190. /**
  89191. * Defines that both eyes of the camera will be rendered over under each other.
  89192. */
  89193. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89194. /**
  89195. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89196. */
  89197. static readonly RIG_MODE_VR: number;
  89198. /**
  89199. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89200. */
  89201. static readonly RIG_MODE_WEBVR: number;
  89202. /**
  89203. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89204. */
  89205. static readonly RIG_MODE_CUSTOM: number;
  89206. /**
  89207. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89208. */
  89209. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89210. /**
  89211. * Define the input manager associated with the camera.
  89212. */
  89213. inputs: CameraInputsManager<Camera>;
  89214. /** @hidden */
  89215. _position: Vector3;
  89216. /**
  89217. * Define the current local position of the camera in the scene
  89218. */
  89219. position: Vector3;
  89220. /**
  89221. * The vector the camera should consider as up.
  89222. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89223. */
  89224. upVector: Vector3;
  89225. /**
  89226. * Define the current limit on the left side for an orthographic camera
  89227. * In scene unit
  89228. */
  89229. orthoLeft: Nullable<number>;
  89230. /**
  89231. * Define the current limit on the right side for an orthographic camera
  89232. * In scene unit
  89233. */
  89234. orthoRight: Nullable<number>;
  89235. /**
  89236. * Define the current limit on the bottom side for an orthographic camera
  89237. * In scene unit
  89238. */
  89239. orthoBottom: Nullable<number>;
  89240. /**
  89241. * Define the current limit on the top side for an orthographic camera
  89242. * In scene unit
  89243. */
  89244. orthoTop: Nullable<number>;
  89245. /**
  89246. * Field Of View is set in Radians. (default is 0.8)
  89247. */
  89248. fov: number;
  89249. /**
  89250. * Define the minimum distance the camera can see from.
  89251. * This is important to note that the depth buffer are not infinite and the closer it starts
  89252. * the more your scene might encounter depth fighting issue.
  89253. */
  89254. minZ: number;
  89255. /**
  89256. * Define the maximum distance the camera can see to.
  89257. * This is important to note that the depth buffer are not infinite and the further it end
  89258. * the more your scene might encounter depth fighting issue.
  89259. */
  89260. maxZ: number;
  89261. /**
  89262. * Define the default inertia of the camera.
  89263. * This helps giving a smooth feeling to the camera movement.
  89264. */
  89265. inertia: number;
  89266. /**
  89267. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89268. */
  89269. mode: number;
  89270. /**
  89271. * Define wether the camera is intermediate.
  89272. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89273. */
  89274. isIntermediate: boolean;
  89275. /**
  89276. * Define the viewport of the camera.
  89277. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89278. */
  89279. viewport: Viewport;
  89280. /**
  89281. * Restricts the camera to viewing objects with the same layerMask.
  89282. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89283. */
  89284. layerMask: number;
  89285. /**
  89286. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89287. */
  89288. fovMode: number;
  89289. /**
  89290. * Rig mode of the camera.
  89291. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89292. * This is normally controlled byt the camera themselves as internal use.
  89293. */
  89294. cameraRigMode: number;
  89295. /**
  89296. * Defines the distance between both "eyes" in case of a RIG
  89297. */
  89298. interaxialDistance: number;
  89299. /**
  89300. * Defines if stereoscopic rendering is done side by side or over under.
  89301. */
  89302. isStereoscopicSideBySide: boolean;
  89303. /**
  89304. * 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
  89305. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89306. * else in the scene.
  89307. */
  89308. customRenderTargets: RenderTargetTexture[];
  89309. /**
  89310. * When set, the camera will render to this render target instead of the default canvas
  89311. */
  89312. outputRenderTarget: Nullable<RenderTargetTexture>;
  89313. /**
  89314. * Observable triggered when the camera view matrix has changed.
  89315. */
  89316. onViewMatrixChangedObservable: Observable<Camera>;
  89317. /**
  89318. * Observable triggered when the camera Projection matrix has changed.
  89319. */
  89320. onProjectionMatrixChangedObservable: Observable<Camera>;
  89321. /**
  89322. * Observable triggered when the inputs have been processed.
  89323. */
  89324. onAfterCheckInputsObservable: Observable<Camera>;
  89325. /**
  89326. * Observable triggered when reset has been called and applied to the camera.
  89327. */
  89328. onRestoreStateObservable: Observable<Camera>;
  89329. /** @hidden */
  89330. _cameraRigParams: any;
  89331. /** @hidden */
  89332. _rigCameras: Camera[];
  89333. /** @hidden */
  89334. _rigPostProcess: Nullable<PostProcess>;
  89335. protected _webvrViewMatrix: Matrix;
  89336. /** @hidden */
  89337. _skipRendering: boolean;
  89338. /** @hidden */
  89339. _projectionMatrix: Matrix;
  89340. /** @hidden */
  89341. _postProcesses: Nullable<PostProcess>[];
  89342. /** @hidden */
  89343. _activeMeshes: SmartArray<AbstractMesh>;
  89344. protected _globalPosition: Vector3;
  89345. /** hidden */
  89346. _computedViewMatrix: Matrix;
  89347. private _doNotComputeProjectionMatrix;
  89348. private _transformMatrix;
  89349. private _frustumPlanes;
  89350. private _refreshFrustumPlanes;
  89351. private _storedFov;
  89352. private _stateStored;
  89353. /**
  89354. * Instantiates a new camera object.
  89355. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89356. * @see http://doc.babylonjs.com/features/cameras
  89357. * @param name Defines the name of the camera in the scene
  89358. * @param position Defines the position of the camera
  89359. * @param scene Defines the scene the camera belongs too
  89360. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89361. */
  89362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89363. /**
  89364. * Store current camera state (fov, position, etc..)
  89365. * @returns the camera
  89366. */
  89367. storeState(): Camera;
  89368. /**
  89369. * Restores the camera state values if it has been stored. You must call storeState() first
  89370. */
  89371. protected _restoreStateValues(): boolean;
  89372. /**
  89373. * Restored camera state. You must call storeState() first.
  89374. * @returns true if restored and false otherwise
  89375. */
  89376. restoreState(): boolean;
  89377. /**
  89378. * Gets the class name of the camera.
  89379. * @returns the class name
  89380. */
  89381. getClassName(): string;
  89382. /** @hidden */
  89383. readonly _isCamera: boolean;
  89384. /**
  89385. * Gets a string representation of the camera useful for debug purpose.
  89386. * @param fullDetails Defines that a more verboe level of logging is required
  89387. * @returns the string representation
  89388. */
  89389. toString(fullDetails?: boolean): string;
  89390. /**
  89391. * Gets the current world space position of the camera.
  89392. */
  89393. readonly globalPosition: Vector3;
  89394. /**
  89395. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89396. * @returns the active meshe list
  89397. */
  89398. getActiveMeshes(): SmartArray<AbstractMesh>;
  89399. /**
  89400. * Check wether a mesh is part of the current active mesh list of the camera
  89401. * @param mesh Defines the mesh to check
  89402. * @returns true if active, false otherwise
  89403. */
  89404. isActiveMesh(mesh: Mesh): boolean;
  89405. /**
  89406. * Is this camera ready to be used/rendered
  89407. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89408. * @return true if the camera is ready
  89409. */
  89410. isReady(completeCheck?: boolean): boolean;
  89411. /** @hidden */
  89412. _initCache(): void;
  89413. /** @hidden */
  89414. _updateCache(ignoreParentClass?: boolean): void;
  89415. /** @hidden */
  89416. _isSynchronized(): boolean;
  89417. /** @hidden */
  89418. _isSynchronizedViewMatrix(): boolean;
  89419. /** @hidden */
  89420. _isSynchronizedProjectionMatrix(): boolean;
  89421. /**
  89422. * Attach the input controls to a specific dom element to get the input from.
  89423. * @param element Defines the element the controls should be listened from
  89424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89425. */
  89426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89427. /**
  89428. * Detach the current controls from the specified dom element.
  89429. * @param element Defines the element to stop listening the inputs from
  89430. */
  89431. detachControl(element: HTMLElement): void;
  89432. /**
  89433. * Update the camera state according to the different inputs gathered during the frame.
  89434. */
  89435. update(): void;
  89436. /** @hidden */
  89437. _checkInputs(): void;
  89438. /** @hidden */
  89439. readonly rigCameras: Camera[];
  89440. /**
  89441. * Gets the post process used by the rig cameras
  89442. */
  89443. readonly rigPostProcess: Nullable<PostProcess>;
  89444. /**
  89445. * Internal, gets the first post proces.
  89446. * @returns the first post process to be run on this camera.
  89447. */
  89448. _getFirstPostProcess(): Nullable<PostProcess>;
  89449. private _cascadePostProcessesToRigCams;
  89450. /**
  89451. * Attach a post process to the camera.
  89452. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89453. * @param postProcess The post process to attach to the camera
  89454. * @param insertAt The position of the post process in case several of them are in use in the scene
  89455. * @returns the position the post process has been inserted at
  89456. */
  89457. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89458. /**
  89459. * Detach a post process to the camera.
  89460. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89461. * @param postProcess The post process to detach from the camera
  89462. */
  89463. detachPostProcess(postProcess: PostProcess): void;
  89464. /**
  89465. * Gets the current world matrix of the camera
  89466. */
  89467. getWorldMatrix(): Matrix;
  89468. /** @hidden */
  89469. _getViewMatrix(): Matrix;
  89470. /**
  89471. * Gets the current view matrix of the camera.
  89472. * @param force forces the camera to recompute the matrix without looking at the cached state
  89473. * @returns the view matrix
  89474. */
  89475. getViewMatrix(force?: boolean): Matrix;
  89476. /**
  89477. * Freeze the projection matrix.
  89478. * It will prevent the cache check of the camera projection compute and can speed up perf
  89479. * if no parameter of the camera are meant to change
  89480. * @param projection Defines manually a projection if necessary
  89481. */
  89482. freezeProjectionMatrix(projection?: Matrix): void;
  89483. /**
  89484. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89485. */
  89486. unfreezeProjectionMatrix(): void;
  89487. /**
  89488. * Gets the current projection matrix of the camera.
  89489. * @param force forces the camera to recompute the matrix without looking at the cached state
  89490. * @returns the projection matrix
  89491. */
  89492. getProjectionMatrix(force?: boolean): Matrix;
  89493. /**
  89494. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89495. * @returns a Matrix
  89496. */
  89497. getTransformationMatrix(): Matrix;
  89498. private _updateFrustumPlanes;
  89499. /**
  89500. * Checks if a cullable object (mesh...) is in the camera frustum
  89501. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89502. * @param target The object to check
  89503. * @returns true if the object is in frustum otherwise false
  89504. */
  89505. isInFrustum(target: ICullable): boolean;
  89506. /**
  89507. * Checks if a cullable object (mesh...) is in the camera frustum
  89508. * Unlike isInFrustum this cheks the full bounding box
  89509. * @param target The object to check
  89510. * @returns true if the object is in frustum otherwise false
  89511. */
  89512. isCompletelyInFrustum(target: ICullable): boolean;
  89513. /**
  89514. * Gets a ray in the forward direction from the camera.
  89515. * @param length Defines the length of the ray to create
  89516. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89517. * @param origin Defines the start point of the ray which defaults to the camera position
  89518. * @returns the forward ray
  89519. */
  89520. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89521. /**
  89522. * Releases resources associated with this node.
  89523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89525. */
  89526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89527. /** @hidden */
  89528. _isLeftCamera: boolean;
  89529. /**
  89530. * Gets the left camera of a rig setup in case of Rigged Camera
  89531. */
  89532. readonly isLeftCamera: boolean;
  89533. /** @hidden */
  89534. _isRightCamera: boolean;
  89535. /**
  89536. * Gets the right camera of a rig setup in case of Rigged Camera
  89537. */
  89538. readonly isRightCamera: boolean;
  89539. /**
  89540. * Gets the left camera of a rig setup in case of Rigged Camera
  89541. */
  89542. readonly leftCamera: Nullable<FreeCamera>;
  89543. /**
  89544. * Gets the right camera of a rig setup in case of Rigged Camera
  89545. */
  89546. readonly rightCamera: Nullable<FreeCamera>;
  89547. /**
  89548. * Gets the left camera target of a rig setup in case of Rigged Camera
  89549. * @returns the target position
  89550. */
  89551. getLeftTarget(): Nullable<Vector3>;
  89552. /**
  89553. * Gets the right camera target of a rig setup in case of Rigged Camera
  89554. * @returns the target position
  89555. */
  89556. getRightTarget(): Nullable<Vector3>;
  89557. /**
  89558. * @hidden
  89559. */
  89560. setCameraRigMode(mode: number, rigParams: any): void;
  89561. /** @hidden */
  89562. static _setStereoscopicRigMode(camera: Camera): void;
  89563. /** @hidden */
  89564. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89565. /** @hidden */
  89566. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89567. /** @hidden */
  89568. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89569. /** @hidden */
  89570. _getVRProjectionMatrix(): Matrix;
  89571. protected _updateCameraRotationMatrix(): void;
  89572. protected _updateWebVRCameraRotationMatrix(): void;
  89573. /**
  89574. * This function MUST be overwritten by the different WebVR cameras available.
  89575. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89576. * @hidden
  89577. */
  89578. _getWebVRProjectionMatrix(): Matrix;
  89579. /**
  89580. * This function MUST be overwritten by the different WebVR cameras available.
  89581. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89582. * @hidden
  89583. */
  89584. _getWebVRViewMatrix(): Matrix;
  89585. /** @hidden */
  89586. setCameraRigParameter(name: string, value: any): void;
  89587. /**
  89588. * needs to be overridden by children so sub has required properties to be copied
  89589. * @hidden
  89590. */
  89591. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89592. /**
  89593. * May need to be overridden by children
  89594. * @hidden
  89595. */
  89596. _updateRigCameras(): void;
  89597. /** @hidden */
  89598. _setupInputs(): void;
  89599. /**
  89600. * Serialiaze the camera setup to a json represention
  89601. * @returns the JSON representation
  89602. */
  89603. serialize(): any;
  89604. /**
  89605. * Clones the current camera.
  89606. * @param name The cloned camera name
  89607. * @returns the cloned camera
  89608. */
  89609. clone(name: string): Camera;
  89610. /**
  89611. * Gets the direction of the camera relative to a given local axis.
  89612. * @param localAxis Defines the reference axis to provide a relative direction.
  89613. * @return the direction
  89614. */
  89615. getDirection(localAxis: Vector3): Vector3;
  89616. /**
  89617. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89618. * @param localAxis Defines the reference axis to provide a relative direction.
  89619. * @param result Defines the vector to store the result in
  89620. */
  89621. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89622. /**
  89623. * Gets a camera constructor for a given camera type
  89624. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89625. * @param name The name of the camera the result will be able to instantiate
  89626. * @param scene The scene the result will construct the camera in
  89627. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89628. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89629. * @returns a factory method to construc the camera
  89630. */
  89631. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89632. /**
  89633. * Compute the world matrix of the camera.
  89634. * @returns the camera workd matrix
  89635. */
  89636. computeWorldMatrix(): Matrix;
  89637. /**
  89638. * Parse a JSON and creates the camera from the parsed information
  89639. * @param parsedCamera The JSON to parse
  89640. * @param scene The scene to instantiate the camera in
  89641. * @returns the newly constructed camera
  89642. */
  89643. static Parse(parsedCamera: any, scene: Scene): Camera;
  89644. }
  89645. }
  89646. declare module BABYLON {
  89647. /**
  89648. * Interface for any object that can request an animation frame
  89649. */
  89650. export interface ICustomAnimationFrameRequester {
  89651. /**
  89652. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89653. */
  89654. renderFunction?: Function;
  89655. /**
  89656. * Called to request the next frame to render to
  89657. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89658. */
  89659. requestAnimationFrame: Function;
  89660. /**
  89661. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89662. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89663. */
  89664. requestID?: number;
  89665. }
  89666. /**
  89667. * Interface containing an array of animations
  89668. */
  89669. export interface IAnimatable {
  89670. /**
  89671. * Array of animations
  89672. */
  89673. animations: Array<Animation>;
  89674. }
  89675. /** Interface used by value gradients (color, factor, ...) */
  89676. export interface IValueGradient {
  89677. /**
  89678. * Gets or sets the gradient value (between 0 and 1)
  89679. */
  89680. gradient: number;
  89681. }
  89682. /** Class used to store color4 gradient */
  89683. export class ColorGradient implements IValueGradient {
  89684. /**
  89685. * Gets or sets the gradient value (between 0 and 1)
  89686. */
  89687. gradient: number;
  89688. /**
  89689. * Gets or sets first associated color
  89690. */
  89691. color1: Color4;
  89692. /**
  89693. * Gets or sets second associated color
  89694. */
  89695. color2?: Color4;
  89696. /**
  89697. * Will get a color picked randomly between color1 and color2.
  89698. * If color2 is undefined then color1 will be used
  89699. * @param result defines the target Color4 to store the result in
  89700. */
  89701. getColorToRef(result: Color4): void;
  89702. }
  89703. /** Class used to store color 3 gradient */
  89704. export class Color3Gradient implements IValueGradient {
  89705. /**
  89706. * Gets or sets the gradient value (between 0 and 1)
  89707. */
  89708. gradient: number;
  89709. /**
  89710. * Gets or sets the associated color
  89711. */
  89712. color: Color3;
  89713. }
  89714. /** Class used to store factor gradient */
  89715. export class FactorGradient implements IValueGradient {
  89716. /**
  89717. * Gets or sets the gradient value (between 0 and 1)
  89718. */
  89719. gradient: number;
  89720. /**
  89721. * Gets or sets first associated factor
  89722. */
  89723. factor1: number;
  89724. /**
  89725. * Gets or sets second associated factor
  89726. */
  89727. factor2?: number;
  89728. /**
  89729. * Will get a number picked randomly between factor1 and factor2.
  89730. * If factor2 is undefined then factor1 will be used
  89731. * @returns the picked number
  89732. */
  89733. getFactor(): number;
  89734. }
  89735. /**
  89736. * @ignore
  89737. * Application error to support additional information when loading a file
  89738. */
  89739. export class LoadFileError extends Error {
  89740. /** defines the optional web request */
  89741. request?: WebRequest | undefined;
  89742. private static _setPrototypeOf;
  89743. /**
  89744. * Creates a new LoadFileError
  89745. * @param message defines the message of the error
  89746. * @param request defines the optional web request
  89747. */
  89748. constructor(message: string,
  89749. /** defines the optional web request */
  89750. request?: WebRequest | undefined);
  89751. }
  89752. /**
  89753. * Class used to define a retry strategy when error happens while loading assets
  89754. */
  89755. export class RetryStrategy {
  89756. /**
  89757. * Function used to defines an exponential back off strategy
  89758. * @param maxRetries defines the maximum number of retries (3 by default)
  89759. * @param baseInterval defines the interval between retries
  89760. * @returns the strategy function to use
  89761. */
  89762. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89763. }
  89764. /**
  89765. * File request interface
  89766. */
  89767. export interface IFileRequest {
  89768. /**
  89769. * Raised when the request is complete (success or error).
  89770. */
  89771. onCompleteObservable: Observable<IFileRequest>;
  89772. /**
  89773. * Aborts the request for a file.
  89774. */
  89775. abort: () => void;
  89776. }
  89777. /**
  89778. * Class containing a set of static utilities functions
  89779. */
  89780. export class Tools {
  89781. /**
  89782. * Gets or sets the base URL to use to load assets
  89783. */
  89784. static BaseUrl: string;
  89785. /**
  89786. * Enable/Disable Custom HTTP Request Headers globally.
  89787. * default = false
  89788. * @see CustomRequestHeaders
  89789. */
  89790. static UseCustomRequestHeaders: boolean;
  89791. /**
  89792. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89793. * i.e. when loading files, where the server/service expects an Authorization header
  89794. */
  89795. static CustomRequestHeaders: {
  89796. [key: string]: string;
  89797. };
  89798. /**
  89799. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89800. */
  89801. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89802. /**
  89803. * Default behaviour for cors in the application.
  89804. * It can be a string if the expected behavior is identical in the entire app.
  89805. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89806. */
  89807. static CorsBehavior: string | ((url: string | string[]) => string);
  89808. /**
  89809. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89810. * @ignorenaming
  89811. */
  89812. static UseFallbackTexture: boolean;
  89813. /**
  89814. * Use this object to register external classes like custom textures or material
  89815. * to allow the laoders to instantiate them
  89816. */
  89817. static RegisteredExternalClasses: {
  89818. [key: string]: Object;
  89819. };
  89820. /**
  89821. * Texture content used if a texture cannot loaded
  89822. * @ignorenaming
  89823. */
  89824. static fallbackTexture: string;
  89825. /**
  89826. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89827. * @param u defines the coordinate on X axis
  89828. * @param v defines the coordinate on Y axis
  89829. * @param width defines the width of the source data
  89830. * @param height defines the height of the source data
  89831. * @param pixels defines the source byte array
  89832. * @param color defines the output color
  89833. */
  89834. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89835. /**
  89836. * Interpolates between a and b via alpha
  89837. * @param a The lower value (returned when alpha = 0)
  89838. * @param b The upper value (returned when alpha = 1)
  89839. * @param alpha The interpolation-factor
  89840. * @return The mixed value
  89841. */
  89842. static Mix(a: number, b: number, alpha: number): number;
  89843. /**
  89844. * Tries to instantiate a new object from a given class name
  89845. * @param className defines the class name to instantiate
  89846. * @returns the new object or null if the system was not able to do the instantiation
  89847. */
  89848. static Instantiate(className: string): any;
  89849. /**
  89850. * Provides a slice function that will work even on IE
  89851. * @param data defines the array to slice
  89852. * @param start defines the start of the data (optional)
  89853. * @param end defines the end of the data (optional)
  89854. * @returns the new sliced array
  89855. */
  89856. static Slice<T>(data: T, start?: number, end?: number): T;
  89857. /**
  89858. * Polyfill for setImmediate
  89859. * @param action defines the action to execute after the current execution block
  89860. */
  89861. static SetImmediate(action: () => void): void;
  89862. /**
  89863. * Function indicating if a number is an exponent of 2
  89864. * @param value defines the value to test
  89865. * @returns true if the value is an exponent of 2
  89866. */
  89867. static IsExponentOfTwo(value: number): boolean;
  89868. private static _tmpFloatArray;
  89869. /**
  89870. * Returns the nearest 32-bit single precision float representation of a Number
  89871. * @param value A Number. If the parameter is of a different type, it will get converted
  89872. * to a number or to NaN if it cannot be converted
  89873. * @returns number
  89874. */
  89875. static FloatRound(value: number): number;
  89876. /**
  89877. * Find the next highest power of two.
  89878. * @param x Number to start search from.
  89879. * @return Next highest power of two.
  89880. */
  89881. static CeilingPOT(x: number): number;
  89882. /**
  89883. * Find the next lowest power of two.
  89884. * @param x Number to start search from.
  89885. * @return Next lowest power of two.
  89886. */
  89887. static FloorPOT(x: number): number;
  89888. /**
  89889. * Find the nearest power of two.
  89890. * @param x Number to start search from.
  89891. * @return Next nearest power of two.
  89892. */
  89893. static NearestPOT(x: number): number;
  89894. /**
  89895. * Get the closest exponent of two
  89896. * @param value defines the value to approximate
  89897. * @param max defines the maximum value to return
  89898. * @param mode defines how to define the closest value
  89899. * @returns closest exponent of two of the given value
  89900. */
  89901. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89902. /**
  89903. * Extracts the filename from a path
  89904. * @param path defines the path to use
  89905. * @returns the filename
  89906. */
  89907. static GetFilename(path: string): string;
  89908. /**
  89909. * Extracts the "folder" part of a path (everything before the filename).
  89910. * @param uri The URI to extract the info from
  89911. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89912. * @returns The "folder" part of the path
  89913. */
  89914. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89915. /**
  89916. * Extracts text content from a DOM element hierarchy
  89917. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89918. */
  89919. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89920. /**
  89921. * Convert an angle in radians to degrees
  89922. * @param angle defines the angle to convert
  89923. * @returns the angle in degrees
  89924. */
  89925. static ToDegrees(angle: number): number;
  89926. /**
  89927. * Convert an angle in degrees to radians
  89928. * @param angle defines the angle to convert
  89929. * @returns the angle in radians
  89930. */
  89931. static ToRadians(angle: number): number;
  89932. /**
  89933. * Encode a buffer to a base64 string
  89934. * @param buffer defines the buffer to encode
  89935. * @returns the encoded string
  89936. */
  89937. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89938. /**
  89939. * Extracts minimum and maximum values from a list of indexed positions
  89940. * @param positions defines the positions to use
  89941. * @param indices defines the indices to the positions
  89942. * @param indexStart defines the start index
  89943. * @param indexCount defines the end index
  89944. * @param bias defines bias value to add to the result
  89945. * @return minimum and maximum values
  89946. */
  89947. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89948. minimum: Vector3;
  89949. maximum: Vector3;
  89950. };
  89951. /**
  89952. * Extracts minimum and maximum values from a list of positions
  89953. * @param positions defines the positions to use
  89954. * @param start defines the start index in the positions array
  89955. * @param count defines the number of positions to handle
  89956. * @param bias defines bias value to add to the result
  89957. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89958. * @return minimum and maximum values
  89959. */
  89960. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89961. minimum: Vector3;
  89962. maximum: Vector3;
  89963. };
  89964. /**
  89965. * Returns an array if obj is not an array
  89966. * @param obj defines the object to evaluate as an array
  89967. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89968. * @returns either obj directly if obj is an array or a new array containing obj
  89969. */
  89970. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89971. /**
  89972. * Gets the pointer prefix to use
  89973. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89974. */
  89975. static GetPointerPrefix(): string;
  89976. /**
  89977. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89978. * @param func - the function to be called
  89979. * @param requester - the object that will request the next frame. Falls back to window.
  89980. * @returns frame number
  89981. */
  89982. static QueueNewFrame(func: () => void, requester?: any): number;
  89983. /**
  89984. * Ask the browser to promote the current element to fullscreen rendering mode
  89985. * @param element defines the DOM element to promote
  89986. */
  89987. static RequestFullscreen(element: HTMLElement): void;
  89988. /**
  89989. * Asks the browser to exit fullscreen mode
  89990. */
  89991. static ExitFullscreen(): void;
  89992. /**
  89993. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89994. * @param url define the url we are trying
  89995. * @param element define the dom element where to configure the cors policy
  89996. */
  89997. static SetCorsBehavior(url: string | string[], element: {
  89998. crossOrigin: string | null;
  89999. }): void;
  90000. /**
  90001. * Removes unwanted characters from an url
  90002. * @param url defines the url to clean
  90003. * @returns the cleaned url
  90004. */
  90005. static CleanUrl(url: string): string;
  90006. /**
  90007. * Gets or sets a function used to pre-process url before using them to load assets
  90008. */
  90009. static PreprocessUrl: (url: string) => string;
  90010. /**
  90011. * Loads an image as an HTMLImageElement.
  90012. * @param input url string, ArrayBuffer, or Blob to load
  90013. * @param onLoad callback called when the image successfully loads
  90014. * @param onError callback called when the image fails to load
  90015. * @param offlineProvider offline provider for caching
  90016. * @returns the HTMLImageElement of the loaded image
  90017. */
  90018. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90019. /**
  90020. * Loads a file
  90021. * @param url url string, ArrayBuffer, or Blob to load
  90022. * @param onSuccess callback called when the file successfully loads
  90023. * @param onProgress callback called while file is loading (if the server supports this mode)
  90024. * @param offlineProvider defines the offline provider for caching
  90025. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90026. * @param onError callback called when the file fails to load
  90027. * @returns a file request object
  90028. */
  90029. 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;
  90030. /**
  90031. * Load a script (identified by an url). When the url returns, the
  90032. * content of this file is added into a new script element, attached to the DOM (body element)
  90033. * @param scriptUrl defines the url of the script to laod
  90034. * @param onSuccess defines the callback called when the script is loaded
  90035. * @param onError defines the callback to call if an error occurs
  90036. * @param scriptId defines the id of the script element
  90037. */
  90038. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90039. /**
  90040. * Load an asynchronous script (identified by an url). When the url returns, the
  90041. * content of this file is added into a new script element, attached to the DOM (body element)
  90042. * @param scriptUrl defines the url of the script to laod
  90043. * @param scriptId defines the id of the script element
  90044. * @returns a promise request object
  90045. */
  90046. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90047. /**
  90048. * Loads a file from a blob
  90049. * @param fileToLoad defines the blob to use
  90050. * @param callback defines the callback to call when data is loaded
  90051. * @param progressCallback defines the callback to call during loading process
  90052. * @returns a file request object
  90053. */
  90054. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90055. /**
  90056. * Loads a file
  90057. * @param fileToLoad defines the file to load
  90058. * @param callback defines the callback to call when data is loaded
  90059. * @param progressCallBack defines the callback to call during loading process
  90060. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90061. * @returns a file request object
  90062. */
  90063. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90064. /**
  90065. * Creates a data url from a given string content
  90066. * @param content defines the content to convert
  90067. * @returns the new data url link
  90068. */
  90069. static FileAsURL(content: string): string;
  90070. /**
  90071. * Format the given number to a specific decimal format
  90072. * @param value defines the number to format
  90073. * @param decimals defines the number of decimals to use
  90074. * @returns the formatted string
  90075. */
  90076. static Format(value: number, decimals?: number): string;
  90077. /**
  90078. * Checks if a given vector is inside a specific range
  90079. * @param v defines the vector to test
  90080. * @param min defines the minimum range
  90081. * @param max defines the maximum range
  90082. */
  90083. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90084. /**
  90085. * Tries to copy an object by duplicating every property
  90086. * @param source defines the source object
  90087. * @param destination defines the target object
  90088. * @param doNotCopyList defines a list of properties to avoid
  90089. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90090. */
  90091. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90092. /**
  90093. * Gets a boolean indicating if the given object has no own property
  90094. * @param obj defines the object to test
  90095. * @returns true if object has no own property
  90096. */
  90097. static IsEmpty(obj: any): boolean;
  90098. /**
  90099. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90100. * @param str Source string
  90101. * @param suffix Suffix to search for in the source string
  90102. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90103. */
  90104. static EndsWith(str: string, suffix: string): boolean;
  90105. /**
  90106. * Function used to register events at window level
  90107. * @param events defines the events to register
  90108. */
  90109. static RegisterTopRootEvents(events: {
  90110. name: string;
  90111. handler: Nullable<(e: FocusEvent) => any>;
  90112. }[]): void;
  90113. /**
  90114. * Function used to unregister events from window level
  90115. * @param events defines the events to unregister
  90116. */
  90117. static UnregisterTopRootEvents(events: {
  90118. name: string;
  90119. handler: Nullable<(e: FocusEvent) => any>;
  90120. }[]): void;
  90121. /**
  90122. * @ignore
  90123. */
  90124. static _ScreenshotCanvas: HTMLCanvasElement;
  90125. /**
  90126. * Dumps the current bound framebuffer
  90127. * @param width defines the rendering width
  90128. * @param height defines the rendering height
  90129. * @param engine defines the hosting engine
  90130. * @param successCallback defines the callback triggered once the data are available
  90131. * @param mimeType defines the mime type of the result
  90132. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90133. */
  90134. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90135. /**
  90136. * Converts the canvas data to blob.
  90137. * This acts as a polyfill for browsers not supporting the to blob function.
  90138. * @param canvas Defines the canvas to extract the data from
  90139. * @param successCallback Defines the callback triggered once the data are available
  90140. * @param mimeType Defines the mime type of the result
  90141. */
  90142. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90143. /**
  90144. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90145. * @param successCallback defines the callback triggered once the data are available
  90146. * @param mimeType defines the mime type of the result
  90147. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90148. */
  90149. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90150. /**
  90151. * Downloads a blob in the browser
  90152. * @param blob defines the blob to download
  90153. * @param fileName defines the name of the downloaded file
  90154. */
  90155. static Download(blob: Blob, fileName: string): void;
  90156. /**
  90157. * Captures a screenshot of the current rendering
  90158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90159. * @param engine defines the rendering engine
  90160. * @param camera defines the source camera
  90161. * @param size This parameter can be set to a single number or to an object with the
  90162. * following (optional) properties: precision, width, height. If a single number is passed,
  90163. * it will be used for both width and height. If an object is passed, the screenshot size
  90164. * will be derived from the parameters. The precision property is a multiplier allowing
  90165. * rendering at a higher or lower resolution
  90166. * @param successCallback defines the callback receives a single parameter which contains the
  90167. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90168. * src parameter of an <img> to display it
  90169. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90170. * Check your browser for supported MIME types
  90171. */
  90172. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90173. /**
  90174. * Generates an image screenshot from the specified camera.
  90175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90176. * @param engine The engine to use for rendering
  90177. * @param camera The camera to use for rendering
  90178. * @param size This parameter can be set to a single number or to an object with the
  90179. * following (optional) properties: precision, width, height. If a single number is passed,
  90180. * it will be used for both width and height. If an object is passed, the screenshot size
  90181. * will be derived from the parameters. The precision property is a multiplier allowing
  90182. * rendering at a higher or lower resolution
  90183. * @param successCallback The callback receives a single parameter which contains the
  90184. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90185. * src parameter of an <img> to display it
  90186. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90187. * Check your browser for supported MIME types
  90188. * @param samples Texture samples (default: 1)
  90189. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90190. * @param fileName A name for for the downloaded file.
  90191. */
  90192. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90193. /**
  90194. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90195. * Be aware Math.random() could cause collisions, but:
  90196. * "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"
  90197. * @returns a pseudo random id
  90198. */
  90199. static RandomId(): string;
  90200. /**
  90201. * Test if the given uri is a base64 string
  90202. * @param uri The uri to test
  90203. * @return True if the uri is a base64 string or false otherwise
  90204. */
  90205. static IsBase64(uri: string): boolean;
  90206. /**
  90207. * Decode the given base64 uri.
  90208. * @param uri The uri to decode
  90209. * @return The decoded base64 data.
  90210. */
  90211. static DecodeBase64(uri: string): ArrayBuffer;
  90212. /**
  90213. * No log
  90214. */
  90215. static readonly NoneLogLevel: number;
  90216. /**
  90217. * Only message logs
  90218. */
  90219. static readonly MessageLogLevel: number;
  90220. /**
  90221. * Only warning logs
  90222. */
  90223. static readonly WarningLogLevel: number;
  90224. /**
  90225. * Only error logs
  90226. */
  90227. static readonly ErrorLogLevel: number;
  90228. /**
  90229. * All logs
  90230. */
  90231. static readonly AllLogLevel: number;
  90232. /**
  90233. * Gets a value indicating the number of loading errors
  90234. * @ignorenaming
  90235. */
  90236. static readonly errorsCount: number;
  90237. /**
  90238. * Callback called when a new log is added
  90239. */
  90240. static OnNewCacheEntry: (entry: string) => void;
  90241. /**
  90242. * Log a message to the console
  90243. * @param message defines the message to log
  90244. */
  90245. static Log(message: string): void;
  90246. /**
  90247. * Write a warning message to the console
  90248. * @param message defines the message to log
  90249. */
  90250. static Warn(message: string): void;
  90251. /**
  90252. * Write an error message to the console
  90253. * @param message defines the message to log
  90254. */
  90255. static Error(message: string): void;
  90256. /**
  90257. * Gets current log cache (list of logs)
  90258. */
  90259. static readonly LogCache: string;
  90260. /**
  90261. * Clears the log cache
  90262. */
  90263. static ClearLogCache(): void;
  90264. /**
  90265. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90266. */
  90267. static LogLevels: number;
  90268. /**
  90269. * Checks if the loaded document was accessed via `file:`-Protocol.
  90270. * @returns boolean
  90271. */
  90272. static IsFileURL(): boolean;
  90273. /**
  90274. * Checks if the window object exists
  90275. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90276. */
  90277. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90278. /**
  90279. * No performance log
  90280. */
  90281. static readonly PerformanceNoneLogLevel: number;
  90282. /**
  90283. * Use user marks to log performance
  90284. */
  90285. static readonly PerformanceUserMarkLogLevel: number;
  90286. /**
  90287. * Log performance to the console
  90288. */
  90289. static readonly PerformanceConsoleLogLevel: number;
  90290. private static _performance;
  90291. /**
  90292. * Sets the current performance log level
  90293. */
  90294. static PerformanceLogLevel: number;
  90295. private static _StartPerformanceCounterDisabled;
  90296. private static _EndPerformanceCounterDisabled;
  90297. private static _StartUserMark;
  90298. private static _EndUserMark;
  90299. private static _StartPerformanceConsole;
  90300. private static _EndPerformanceConsole;
  90301. /**
  90302. * Starts a performance counter
  90303. */
  90304. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90305. /**
  90306. * Ends a specific performance coutner
  90307. */
  90308. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90309. /**
  90310. * Gets either window.performance.now() if supported or Date.now() else
  90311. */
  90312. static readonly Now: number;
  90313. /**
  90314. * This method will return the name of the class used to create the instance of the given object.
  90315. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90316. * @param object the object to get the class name from
  90317. * @param isType defines if the object is actually a type
  90318. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90319. */
  90320. static GetClassName(object: any, isType?: boolean): string;
  90321. /**
  90322. * Gets the first element of an array satisfying a given predicate
  90323. * @param array defines the array to browse
  90324. * @param predicate defines the predicate to use
  90325. * @returns null if not found or the element
  90326. */
  90327. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90328. /**
  90329. * This method will return the name of the full name of the class, including its owning module (if any).
  90330. * 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).
  90331. * @param object the object to get the class name from
  90332. * @param isType defines if the object is actually a type
  90333. * @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.
  90334. * @ignorenaming
  90335. */
  90336. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90337. /**
  90338. * Returns a promise that resolves after the given amount of time.
  90339. * @param delay Number of milliseconds to delay
  90340. * @returns Promise that resolves after the given amount of time
  90341. */
  90342. static DelayAsync(delay: number): Promise<void>;
  90343. /**
  90344. * Gets the current gradient from an array of IValueGradient
  90345. * @param ratio defines the current ratio to get
  90346. * @param gradients defines the array of IValueGradient
  90347. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90348. */
  90349. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90350. }
  90351. /**
  90352. * This class is used to track a performance counter which is number based.
  90353. * The user has access to many properties which give statistics of different nature.
  90354. *
  90355. * The implementer can track two kinds of Performance Counter: time and count.
  90356. * 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.
  90357. * 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.
  90358. */
  90359. export class PerfCounter {
  90360. /**
  90361. * Gets or sets a global boolean to turn on and off all the counters
  90362. */
  90363. static Enabled: boolean;
  90364. /**
  90365. * Returns the smallest value ever
  90366. */
  90367. readonly min: number;
  90368. /**
  90369. * Returns the biggest value ever
  90370. */
  90371. readonly max: number;
  90372. /**
  90373. * Returns the average value since the performance counter is running
  90374. */
  90375. readonly average: number;
  90376. /**
  90377. * Returns the average value of the last second the counter was monitored
  90378. */
  90379. readonly lastSecAverage: number;
  90380. /**
  90381. * Returns the current value
  90382. */
  90383. readonly current: number;
  90384. /**
  90385. * Gets the accumulated total
  90386. */
  90387. readonly total: number;
  90388. /**
  90389. * Gets the total value count
  90390. */
  90391. readonly count: number;
  90392. /**
  90393. * Creates a new counter
  90394. */
  90395. constructor();
  90396. /**
  90397. * Call this method to start monitoring a new frame.
  90398. * 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.
  90399. */
  90400. fetchNewFrame(): void;
  90401. /**
  90402. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90403. * @param newCount the count value to add to the monitored count
  90404. * @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.
  90405. */
  90406. addCount(newCount: number, fetchResult: boolean): void;
  90407. /**
  90408. * Start monitoring this performance counter
  90409. */
  90410. beginMonitoring(): void;
  90411. /**
  90412. * Compute the time lapsed since the previous beginMonitoring() call.
  90413. * @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
  90414. */
  90415. endMonitoring(newFrame?: boolean): void;
  90416. private _fetchResult;
  90417. private _startMonitoringTime;
  90418. private _min;
  90419. private _max;
  90420. private _average;
  90421. private _current;
  90422. private _totalValueCount;
  90423. private _totalAccumulated;
  90424. private _lastSecAverage;
  90425. private _lastSecAccumulated;
  90426. private _lastSecTime;
  90427. private _lastSecValueCount;
  90428. }
  90429. /**
  90430. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90431. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90432. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90433. * @param name The name of the class, case should be preserved
  90434. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90435. */
  90436. export function className(name: string, module?: string): (target: Object) => void;
  90437. /**
  90438. * An implementation of a loop for asynchronous functions.
  90439. */
  90440. export class AsyncLoop {
  90441. /**
  90442. * Defines the number of iterations for the loop
  90443. */
  90444. iterations: number;
  90445. /**
  90446. * Defines the current index of the loop.
  90447. */
  90448. index: number;
  90449. private _done;
  90450. private _fn;
  90451. private _successCallback;
  90452. /**
  90453. * Constructor.
  90454. * @param iterations the number of iterations.
  90455. * @param func the function to run each iteration
  90456. * @param successCallback the callback that will be called upon succesful execution
  90457. * @param offset starting offset.
  90458. */
  90459. constructor(
  90460. /**
  90461. * Defines the number of iterations for the loop
  90462. */
  90463. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90464. /**
  90465. * Execute the next iteration. Must be called after the last iteration was finished.
  90466. */
  90467. executeNext(): void;
  90468. /**
  90469. * Break the loop and run the success callback.
  90470. */
  90471. breakLoop(): void;
  90472. /**
  90473. * Create and run an async loop.
  90474. * @param iterations the number of iterations.
  90475. * @param fn the function to run each iteration
  90476. * @param successCallback the callback that will be called upon succesful execution
  90477. * @param offset starting offset.
  90478. * @returns the created async loop object
  90479. */
  90480. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90481. /**
  90482. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90483. * @param iterations total number of iterations
  90484. * @param syncedIterations number of synchronous iterations in each async iteration.
  90485. * @param fn the function to call each iteration.
  90486. * @param callback a success call back that will be called when iterating stops.
  90487. * @param breakFunction a break condition (optional)
  90488. * @param timeout timeout settings for the setTimeout function. default - 0.
  90489. * @returns the created async loop object
  90490. */
  90491. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90492. }
  90493. }
  90494. declare module BABYLON {
  90495. /** @hidden */
  90496. export interface ICollisionCoordinator {
  90497. createCollider(): Collider;
  90498. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90499. init(scene: Scene): void;
  90500. }
  90501. /** @hidden */
  90502. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90503. private _scene;
  90504. private _scaledPosition;
  90505. private _scaledVelocity;
  90506. private _finalPosition;
  90507. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90508. createCollider(): Collider;
  90509. init(scene: Scene): void;
  90510. private _collideWithWorld;
  90511. }
  90512. }
  90513. declare module BABYLON {
  90514. /**
  90515. * This class defines the direct association between an animation and a target
  90516. */
  90517. export class TargetedAnimation {
  90518. /**
  90519. * Animation to perform
  90520. */
  90521. animation: Animation;
  90522. /**
  90523. * Target to animate
  90524. */
  90525. target: any;
  90526. }
  90527. /**
  90528. * Use this class to create coordinated animations on multiple targets
  90529. */
  90530. export class AnimationGroup implements IDisposable {
  90531. /** The name of the animation group */
  90532. name: string;
  90533. private _scene;
  90534. private _targetedAnimations;
  90535. private _animatables;
  90536. private _from;
  90537. private _to;
  90538. private _isStarted;
  90539. private _isPaused;
  90540. private _speedRatio;
  90541. /**
  90542. * Gets or sets the unique id of the node
  90543. */
  90544. uniqueId: number;
  90545. /**
  90546. * This observable will notify when one animation have ended
  90547. */
  90548. onAnimationEndObservable: Observable<TargetedAnimation>;
  90549. /**
  90550. * Observer raised when one animation loops
  90551. */
  90552. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90553. /**
  90554. * This observable will notify when all animations have ended.
  90555. */
  90556. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90557. /**
  90558. * This observable will notify when all animations have paused.
  90559. */
  90560. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90561. /**
  90562. * This observable will notify when all animations are playing.
  90563. */
  90564. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90565. /**
  90566. * Gets the first frame
  90567. */
  90568. readonly from: number;
  90569. /**
  90570. * Gets the last frame
  90571. */
  90572. readonly to: number;
  90573. /**
  90574. * Define if the animations are started
  90575. */
  90576. readonly isStarted: boolean;
  90577. /**
  90578. * Gets a value indicating that the current group is playing
  90579. */
  90580. readonly isPlaying: boolean;
  90581. /**
  90582. * Gets or sets the speed ratio to use for all animations
  90583. */
  90584. /**
  90585. * Gets or sets the speed ratio to use for all animations
  90586. */
  90587. speedRatio: number;
  90588. /**
  90589. * Gets the targeted animations for this animation group
  90590. */
  90591. readonly targetedAnimations: Array<TargetedAnimation>;
  90592. /**
  90593. * returning the list of animatables controlled by this animation group.
  90594. */
  90595. readonly animatables: Array<Animatable>;
  90596. /**
  90597. * Instantiates a new Animation Group.
  90598. * This helps managing several animations at once.
  90599. * @see http://doc.babylonjs.com/how_to/group
  90600. * @param name Defines the name of the group
  90601. * @param scene Defines the scene the group belongs to
  90602. */
  90603. constructor(
  90604. /** The name of the animation group */
  90605. name: string, scene?: Nullable<Scene>);
  90606. /**
  90607. * Add an animation (with its target) in the group
  90608. * @param animation defines the animation we want to add
  90609. * @param target defines the target of the animation
  90610. * @returns the TargetedAnimation object
  90611. */
  90612. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90613. /**
  90614. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90615. * It can add constant keys at begin or end
  90616. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90617. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90618. * @returns the animation group
  90619. */
  90620. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90621. /**
  90622. * Start all animations on given targets
  90623. * @param loop defines if animations must loop
  90624. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90625. * @param from defines the from key (optional)
  90626. * @param to defines the to key (optional)
  90627. * @returns the current animation group
  90628. */
  90629. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90630. /**
  90631. * Pause all animations
  90632. * @returns the animation group
  90633. */
  90634. pause(): AnimationGroup;
  90635. /**
  90636. * Play all animations to initial state
  90637. * This function will start() the animations if they were not started or will restart() them if they were paused
  90638. * @param loop defines if animations must loop
  90639. * @returns the animation group
  90640. */
  90641. play(loop?: boolean): AnimationGroup;
  90642. /**
  90643. * Reset all animations to initial state
  90644. * @returns the animation group
  90645. */
  90646. reset(): AnimationGroup;
  90647. /**
  90648. * Restart animations from key 0
  90649. * @returns the animation group
  90650. */
  90651. restart(): AnimationGroup;
  90652. /**
  90653. * Stop all animations
  90654. * @returns the animation group
  90655. */
  90656. stop(): AnimationGroup;
  90657. /**
  90658. * Set animation weight for all animatables
  90659. * @param weight defines the weight to use
  90660. * @return the animationGroup
  90661. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90662. */
  90663. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90664. /**
  90665. * Synchronize and normalize all animatables with a source animatable
  90666. * @param root defines the root animatable to synchronize with
  90667. * @return the animationGroup
  90668. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90669. */
  90670. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90671. /**
  90672. * Goes to a specific frame in this animation group
  90673. * @param frame the frame number to go to
  90674. * @return the animationGroup
  90675. */
  90676. goToFrame(frame: number): AnimationGroup;
  90677. /**
  90678. * Dispose all associated resources
  90679. */
  90680. dispose(): void;
  90681. private _checkAnimationGroupEnded;
  90682. /**
  90683. * Clone the current animation group and returns a copy
  90684. * @param newName defines the name of the new group
  90685. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90686. * @returns the new aniamtion group
  90687. */
  90688. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90689. /**
  90690. * Returns a new AnimationGroup object parsed from the source provided.
  90691. * @param parsedAnimationGroup defines the source
  90692. * @param scene defines the scene that will receive the animationGroup
  90693. * @returns a new AnimationGroup
  90694. */
  90695. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90696. /**
  90697. * Returns the string "AnimationGroup"
  90698. * @returns "AnimationGroup"
  90699. */
  90700. getClassName(): string;
  90701. /**
  90702. * Creates a detailled string about the object
  90703. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90704. * @returns a string representing the object
  90705. */
  90706. toString(fullDetails?: boolean): string;
  90707. }
  90708. }
  90709. declare module BABYLON {
  90710. /**
  90711. * Define an interface for all classes that will hold resources
  90712. */
  90713. export interface IDisposable {
  90714. /**
  90715. * Releases all held resources
  90716. */
  90717. dispose(): void;
  90718. }
  90719. /** Interface defining initialization parameters for Scene class */
  90720. export interface SceneOptions {
  90721. /**
  90722. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90723. * It will improve performance when the number of geometries becomes important.
  90724. */
  90725. useGeometryUniqueIdsMap?: boolean;
  90726. /**
  90727. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90728. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90729. */
  90730. useMaterialMeshMap?: boolean;
  90731. /**
  90732. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90733. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90734. */
  90735. useClonedMeshhMap?: boolean;
  90736. }
  90737. /**
  90738. * Represents a scene to be rendered by the engine.
  90739. * @see http://doc.babylonjs.com/features/scene
  90740. */
  90741. export class Scene extends AbstractScene implements IAnimatable {
  90742. private static _uniqueIdCounter;
  90743. /** The fog is deactivated */
  90744. static readonly FOGMODE_NONE: number;
  90745. /** The fog density is following an exponential function */
  90746. static readonly FOGMODE_EXP: number;
  90747. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90748. static readonly FOGMODE_EXP2: number;
  90749. /** The fog density is following a linear function. */
  90750. static readonly FOGMODE_LINEAR: number;
  90751. /**
  90752. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90754. */
  90755. static MinDeltaTime: number;
  90756. /**
  90757. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90759. */
  90760. static MaxDeltaTime: number;
  90761. /**
  90762. * Factory used to create the default material.
  90763. * @param name The name of the material to create
  90764. * @param scene The scene to create the material for
  90765. * @returns The default material
  90766. */
  90767. static DefaultMaterialFactory(scene: Scene): Material;
  90768. /**
  90769. * Factory used to create the a collision coordinator.
  90770. * @returns The collision coordinator
  90771. */
  90772. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90773. /** @hidden */
  90774. readonly _isScene: boolean;
  90775. /**
  90776. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  90777. */
  90778. autoClear: boolean;
  90779. /**
  90780. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  90781. */
  90782. autoClearDepthAndStencil: boolean;
  90783. /**
  90784. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  90785. */
  90786. clearColor: Color4;
  90787. /**
  90788. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  90789. */
  90790. ambientColor: Color3;
  90791. /**
  90792. * This is use to store the default BRDF lookup for PBR materials in your scene.
  90793. * It should only be one of the following (if not the default embedded one):
  90794. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  90795. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  90796. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  90797. * The material properties need to be setup according to the type of texture in use.
  90798. */
  90799. environmentBRDFTexture: BaseTexture;
  90800. /** @hidden */
  90801. protected _environmentTexture: Nullable<BaseTexture>;
  90802. /**
  90803. * Texture used in all pbr material as the reflection texture.
  90804. * As in the majority of the scene they are the same (exception for multi room and so on),
  90805. * this is easier to reference from here than from all the materials.
  90806. */
  90807. /**
  90808. * Texture used in all pbr material as the reflection texture.
  90809. * As in the majority of the scene they are the same (exception for multi room and so on),
  90810. * this is easier to set here than in all the materials.
  90811. */
  90812. environmentTexture: Nullable<BaseTexture>;
  90813. /** @hidden */
  90814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90815. /**
  90816. * Default image processing configuration used either in the rendering
  90817. * Forward main pass or through the imageProcessingPostProcess if present.
  90818. * As in the majority of the scene they are the same (exception for multi camera),
  90819. * this is easier to reference from here than from all the materials and post process.
  90820. *
  90821. * No setter as we it is a shared configuration, you can set the values instead.
  90822. */
  90823. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90824. private _forceWireframe;
  90825. /**
  90826. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90827. */
  90828. forceWireframe: boolean;
  90829. private _forcePointsCloud;
  90830. /**
  90831. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90832. */
  90833. forcePointsCloud: boolean;
  90834. /**
  90835. * Gets or sets the active clipplane 1
  90836. */
  90837. clipPlane: Nullable<Plane>;
  90838. /**
  90839. * Gets or sets the active clipplane 2
  90840. */
  90841. clipPlane2: Nullable<Plane>;
  90842. /**
  90843. * Gets or sets the active clipplane 3
  90844. */
  90845. clipPlane3: Nullable<Plane>;
  90846. /**
  90847. * Gets or sets the active clipplane 4
  90848. */
  90849. clipPlane4: Nullable<Plane>;
  90850. /**
  90851. * Gets or sets a boolean indicating if animations are enabled
  90852. */
  90853. animationsEnabled: boolean;
  90854. private _animationPropertiesOverride;
  90855. /**
  90856. * Gets or sets the animation properties override
  90857. */
  90858. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90859. /**
  90860. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90861. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90862. */
  90863. useConstantAnimationDeltaTime: boolean;
  90864. /**
  90865. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90866. * Please note that it requires to run a ray cast through the scene on every frame
  90867. */
  90868. constantlyUpdateMeshUnderPointer: boolean;
  90869. /**
  90870. * Defines the HTML cursor to use when hovering over interactive elements
  90871. */
  90872. hoverCursor: string;
  90873. /**
  90874. * Defines the HTML default cursor to use (empty by default)
  90875. */
  90876. defaultCursor: string;
  90877. /**
  90878. * This is used to call preventDefault() on pointer down
  90879. * in order to block unwanted artifacts like system double clicks
  90880. */
  90881. preventDefaultOnPointerDown: boolean;
  90882. /**
  90883. * This is used to call preventDefault() on pointer up
  90884. * in order to block unwanted artifacts like system double clicks
  90885. */
  90886. preventDefaultOnPointerUp: boolean;
  90887. /**
  90888. * Gets or sets user defined metadata
  90889. */
  90890. metadata: any;
  90891. /**
  90892. * For internal use only. Please do not use.
  90893. */
  90894. reservedDataStore: any;
  90895. /**
  90896. * Gets the name of the plugin used to load this scene (null by default)
  90897. */
  90898. loadingPluginName: string;
  90899. /**
  90900. * Use this array to add regular expressions used to disable offline support for specific urls
  90901. */
  90902. disableOfflineSupportExceptionRules: RegExp[];
  90903. /**
  90904. * An event triggered when the scene is disposed.
  90905. */
  90906. onDisposeObservable: Observable<Scene>;
  90907. private _onDisposeObserver;
  90908. /** Sets a function to be executed when this scene is disposed. */
  90909. onDispose: () => void;
  90910. /**
  90911. * An event triggered before rendering the scene (right after animations and physics)
  90912. */
  90913. onBeforeRenderObservable: Observable<Scene>;
  90914. private _onBeforeRenderObserver;
  90915. /** Sets a function to be executed before rendering this scene */
  90916. beforeRender: Nullable<() => void>;
  90917. /**
  90918. * An event triggered after rendering the scene
  90919. */
  90920. onAfterRenderObservable: Observable<Scene>;
  90921. private _onAfterRenderObserver;
  90922. /** Sets a function to be executed after rendering this scene */
  90923. afterRender: Nullable<() => void>;
  90924. /**
  90925. * An event triggered before animating the scene
  90926. */
  90927. onBeforeAnimationsObservable: Observable<Scene>;
  90928. /**
  90929. * An event triggered after animations processing
  90930. */
  90931. onAfterAnimationsObservable: Observable<Scene>;
  90932. /**
  90933. * An event triggered before draw calls are ready to be sent
  90934. */
  90935. onBeforeDrawPhaseObservable: Observable<Scene>;
  90936. /**
  90937. * An event triggered after draw calls have been sent
  90938. */
  90939. onAfterDrawPhaseObservable: Observable<Scene>;
  90940. /**
  90941. * An event triggered when the scene is ready
  90942. */
  90943. onReadyObservable: Observable<Scene>;
  90944. /**
  90945. * An event triggered before rendering a camera
  90946. */
  90947. onBeforeCameraRenderObservable: Observable<Camera>;
  90948. private _onBeforeCameraRenderObserver;
  90949. /** Sets a function to be executed before rendering a camera*/
  90950. beforeCameraRender: () => void;
  90951. /**
  90952. * An event triggered after rendering a camera
  90953. */
  90954. onAfterCameraRenderObservable: Observable<Camera>;
  90955. private _onAfterCameraRenderObserver;
  90956. /** Sets a function to be executed after rendering a camera*/
  90957. afterCameraRender: () => void;
  90958. /**
  90959. * An event triggered when active meshes evaluation is about to start
  90960. */
  90961. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90962. /**
  90963. * An event triggered when active meshes evaluation is done
  90964. */
  90965. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90966. /**
  90967. * An event triggered when particles rendering is about to start
  90968. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90969. */
  90970. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90971. /**
  90972. * An event triggered when particles rendering is done
  90973. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90974. */
  90975. onAfterParticlesRenderingObservable: Observable<Scene>;
  90976. /**
  90977. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90978. */
  90979. onDataLoadedObservable: Observable<Scene>;
  90980. /**
  90981. * An event triggered when a camera is created
  90982. */
  90983. onNewCameraAddedObservable: Observable<Camera>;
  90984. /**
  90985. * An event triggered when a camera is removed
  90986. */
  90987. onCameraRemovedObservable: Observable<Camera>;
  90988. /**
  90989. * An event triggered when a light is created
  90990. */
  90991. onNewLightAddedObservable: Observable<Light>;
  90992. /**
  90993. * An event triggered when a light is removed
  90994. */
  90995. onLightRemovedObservable: Observable<Light>;
  90996. /**
  90997. * An event triggered when a geometry is created
  90998. */
  90999. onNewGeometryAddedObservable: Observable<Geometry>;
  91000. /**
  91001. * An event triggered when a geometry is removed
  91002. */
  91003. onGeometryRemovedObservable: Observable<Geometry>;
  91004. /**
  91005. * An event triggered when a transform node is created
  91006. */
  91007. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91008. /**
  91009. * An event triggered when a transform node is removed
  91010. */
  91011. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91012. /**
  91013. * An event triggered when a mesh is created
  91014. */
  91015. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91016. /**
  91017. * An event triggered when a mesh is removed
  91018. */
  91019. onMeshRemovedObservable: Observable<AbstractMesh>;
  91020. /**
  91021. * An event triggered when a skeleton is created
  91022. */
  91023. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91024. /**
  91025. * An event triggered when a skeleton is removed
  91026. */
  91027. onSkeletonRemovedObservable: Observable<Skeleton>;
  91028. /**
  91029. * An event triggered when a material is created
  91030. */
  91031. onNewMaterialAddedObservable: Observable<Material>;
  91032. /**
  91033. * An event triggered when a material is removed
  91034. */
  91035. onMaterialRemovedObservable: Observable<Material>;
  91036. /**
  91037. * An event triggered when a texture is created
  91038. */
  91039. onNewTextureAddedObservable: Observable<BaseTexture>;
  91040. /**
  91041. * An event triggered when a texture is removed
  91042. */
  91043. onTextureRemovedObservable: Observable<BaseTexture>;
  91044. /**
  91045. * An event triggered when render targets are about to be rendered
  91046. * Can happen multiple times per frame.
  91047. */
  91048. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91049. /**
  91050. * An event triggered when render targets were rendered.
  91051. * Can happen multiple times per frame.
  91052. */
  91053. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91054. /**
  91055. * An event triggered before calculating deterministic simulation step
  91056. */
  91057. onBeforeStepObservable: Observable<Scene>;
  91058. /**
  91059. * An event triggered after calculating deterministic simulation step
  91060. */
  91061. onAfterStepObservable: Observable<Scene>;
  91062. /**
  91063. * An event triggered when the activeCamera property is updated
  91064. */
  91065. onActiveCameraChanged: Observable<Scene>;
  91066. /**
  91067. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91068. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91069. * 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)
  91070. */
  91071. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91072. /**
  91073. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91074. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91075. * 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)
  91076. */
  91077. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91078. /**
  91079. * This Observable will when a mesh has been imported into the scene.
  91080. */
  91081. onMeshImportedObservable: Observable<AbstractMesh>;
  91082. /**
  91083. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91084. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91085. */
  91086. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91087. /** @hidden */
  91088. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91089. /**
  91090. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91091. */
  91092. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91093. /**
  91094. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91095. */
  91096. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91097. /**
  91098. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91099. */
  91100. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91101. private _onPointerMove;
  91102. private _onPointerDown;
  91103. private _onPointerUp;
  91104. /** Callback called when a pointer move is detected */
  91105. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91106. /** Callback called when a pointer down is detected */
  91107. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91108. /** Callback called when a pointer up is detected */
  91109. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91110. /** Callback called when a pointer pick is detected */
  91111. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91112. /**
  91113. * 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).
  91114. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91115. */
  91116. onPrePointerObservable: Observable<PointerInfoPre>;
  91117. /**
  91118. * Observable event triggered each time an input event is received from the rendering canvas
  91119. */
  91120. onPointerObservable: Observable<PointerInfo>;
  91121. /**
  91122. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91123. */
  91124. readonly unTranslatedPointer: Vector2;
  91125. /** The distance in pixel that you have to move to prevent some events */
  91126. static DragMovementThreshold: number;
  91127. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91128. static LongPressDelay: number;
  91129. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91130. static DoubleClickDelay: number;
  91131. /** If you need to check double click without raising a single click at first click, enable this flag */
  91132. static ExclusiveDoubleClickMode: boolean;
  91133. private _initClickEvent;
  91134. private _initActionManager;
  91135. private _delayedSimpleClick;
  91136. private _delayedSimpleClickTimeout;
  91137. private _previousDelayedSimpleClickTimeout;
  91138. private _meshPickProceed;
  91139. private _previousButtonPressed;
  91140. private _currentPickResult;
  91141. private _previousPickResult;
  91142. private _totalPointersPressed;
  91143. private _doubleClickOccured;
  91144. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91145. cameraToUseForPointers: Nullable<Camera>;
  91146. private _pointerX;
  91147. private _pointerY;
  91148. private _unTranslatedPointerX;
  91149. private _unTranslatedPointerY;
  91150. private _startingPointerPosition;
  91151. private _previousStartingPointerPosition;
  91152. private _startingPointerTime;
  91153. private _previousStartingPointerTime;
  91154. private _pointerCaptures;
  91155. private _timeAccumulator;
  91156. private _currentStepId;
  91157. private _currentInternalStep;
  91158. /** @hidden */
  91159. _mirroredCameraPosition: Nullable<Vector3>;
  91160. /**
  91161. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91162. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91163. */
  91164. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91165. /**
  91166. * Observable event triggered each time an keyboard event is received from the hosting window
  91167. */
  91168. onKeyboardObservable: Observable<KeyboardInfo>;
  91169. private _onKeyDown;
  91170. private _onKeyUp;
  91171. private _onCanvasFocusObserver;
  91172. private _onCanvasBlurObserver;
  91173. private _useRightHandedSystem;
  91174. /**
  91175. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91176. */
  91177. useRightHandedSystem: boolean;
  91178. /**
  91179. * Sets the step Id used by deterministic lock step
  91180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91181. * @param newStepId defines the step Id
  91182. */
  91183. setStepId(newStepId: number): void;
  91184. /**
  91185. * Gets the step Id used by deterministic lock step
  91186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91187. * @returns the step Id
  91188. */
  91189. getStepId(): number;
  91190. /**
  91191. * Gets the internal step used by deterministic lock step
  91192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91193. * @returns the internal step
  91194. */
  91195. getInternalStep(): number;
  91196. private _fogEnabled;
  91197. /**
  91198. * Gets or sets a boolean indicating if fog is enabled on this scene
  91199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91200. * (Default is true)
  91201. */
  91202. fogEnabled: boolean;
  91203. private _fogMode;
  91204. /**
  91205. * Gets or sets the fog mode to use
  91206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91207. * | mode | value |
  91208. * | --- | --- |
  91209. * | FOGMODE_NONE | 0 |
  91210. * | FOGMODE_EXP | 1 |
  91211. * | FOGMODE_EXP2 | 2 |
  91212. * | FOGMODE_LINEAR | 3 |
  91213. */
  91214. fogMode: number;
  91215. /**
  91216. * Gets or sets the fog color to use
  91217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91218. * (Default is Color3(0.2, 0.2, 0.3))
  91219. */
  91220. fogColor: Color3;
  91221. /**
  91222. * Gets or sets the fog density to use
  91223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91224. * (Default is 0.1)
  91225. */
  91226. fogDensity: number;
  91227. /**
  91228. * Gets or sets the fog start distance to use
  91229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91230. * (Default is 0)
  91231. */
  91232. fogStart: number;
  91233. /**
  91234. * Gets or sets the fog end distance to use
  91235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91236. * (Default is 1000)
  91237. */
  91238. fogEnd: number;
  91239. private _shadowsEnabled;
  91240. /**
  91241. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91242. */
  91243. shadowsEnabled: boolean;
  91244. private _lightsEnabled;
  91245. /**
  91246. * Gets or sets a boolean indicating if lights are enabled on this scene
  91247. */
  91248. lightsEnabled: boolean;
  91249. /** All of the active cameras added to this scene. */
  91250. activeCameras: Camera[];
  91251. /** @hidden */
  91252. _activeCamera: Nullable<Camera>;
  91253. /** Gets or sets the current active camera */
  91254. activeCamera: Nullable<Camera>;
  91255. private _defaultMaterial;
  91256. /** The default material used on meshes when no material is affected */
  91257. /** The default material used on meshes when no material is affected */
  91258. defaultMaterial: Material;
  91259. private _texturesEnabled;
  91260. /**
  91261. * Gets or sets a boolean indicating if textures are enabled on this scene
  91262. */
  91263. texturesEnabled: boolean;
  91264. /**
  91265. * Gets or sets a boolean indicating if particles are enabled on this scene
  91266. */
  91267. particlesEnabled: boolean;
  91268. /**
  91269. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91270. */
  91271. spritesEnabled: boolean;
  91272. private _skeletonsEnabled;
  91273. /**
  91274. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91275. */
  91276. skeletonsEnabled: boolean;
  91277. /**
  91278. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91279. */
  91280. lensFlaresEnabled: boolean;
  91281. /**
  91282. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91283. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91284. */
  91285. collisionsEnabled: boolean;
  91286. private _collisionCoordinator;
  91287. /** @hidden */
  91288. readonly collisionCoordinator: ICollisionCoordinator;
  91289. /**
  91290. * Defines the gravity applied to this scene (used only for collisions)
  91291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91292. */
  91293. gravity: Vector3;
  91294. /**
  91295. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91296. */
  91297. postProcessesEnabled: boolean;
  91298. /**
  91299. * The list of postprocesses added to the scene
  91300. */
  91301. postProcesses: PostProcess[];
  91302. /**
  91303. * Gets the current postprocess manager
  91304. */
  91305. postProcessManager: PostProcessManager;
  91306. /**
  91307. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91308. */
  91309. renderTargetsEnabled: boolean;
  91310. /**
  91311. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91312. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91313. */
  91314. dumpNextRenderTargets: boolean;
  91315. /**
  91316. * The list of user defined render targets added to the scene
  91317. */
  91318. customRenderTargets: RenderTargetTexture[];
  91319. /**
  91320. * Defines if texture loading must be delayed
  91321. * If true, textures will only be loaded when they need to be rendered
  91322. */
  91323. useDelayedTextureLoading: boolean;
  91324. /**
  91325. * Gets the list of meshes imported to the scene through SceneLoader
  91326. */
  91327. importedMeshesFiles: String[];
  91328. /**
  91329. * Gets or sets a boolean indicating if probes are enabled on this scene
  91330. */
  91331. probesEnabled: boolean;
  91332. /**
  91333. * Gets or sets the current offline provider to use to store scene data
  91334. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91335. */
  91336. offlineProvider: IOfflineProvider;
  91337. /**
  91338. * Gets or sets the action manager associated with the scene
  91339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91340. */
  91341. actionManager: AbstractActionManager;
  91342. private _meshesForIntersections;
  91343. /**
  91344. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91345. */
  91346. proceduralTexturesEnabled: boolean;
  91347. private _engine;
  91348. private _totalVertices;
  91349. /** @hidden */
  91350. _activeIndices: PerfCounter;
  91351. /** @hidden */
  91352. _activeParticles: PerfCounter;
  91353. /** @hidden */
  91354. _activeBones: PerfCounter;
  91355. private _animationRatio;
  91356. /** @hidden */
  91357. _animationTimeLast: number;
  91358. /** @hidden */
  91359. _animationTime: number;
  91360. /**
  91361. * Gets or sets a general scale for animation speed
  91362. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91363. */
  91364. animationTimeScale: number;
  91365. /** @hidden */
  91366. _cachedMaterial: Nullable<Material>;
  91367. /** @hidden */
  91368. _cachedEffect: Nullable<Effect>;
  91369. /** @hidden */
  91370. _cachedVisibility: Nullable<number>;
  91371. private _renderId;
  91372. private _frameId;
  91373. private _executeWhenReadyTimeoutId;
  91374. private _intermediateRendering;
  91375. private _viewUpdateFlag;
  91376. private _projectionUpdateFlag;
  91377. /** @hidden */
  91378. _toBeDisposed: Nullable<IDisposable>[];
  91379. private _activeRequests;
  91380. /** @hidden */
  91381. _pendingData: any[];
  91382. private _isDisposed;
  91383. /**
  91384. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91385. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91386. */
  91387. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91388. private _activeMeshes;
  91389. private _processedMaterials;
  91390. private _renderTargets;
  91391. /** @hidden */
  91392. _activeParticleSystems: SmartArray<IParticleSystem>;
  91393. private _activeSkeletons;
  91394. private _softwareSkinnedMeshes;
  91395. private _renderingManager;
  91396. /** @hidden */
  91397. _activeAnimatables: Animatable[];
  91398. private _transformMatrix;
  91399. private _sceneUbo;
  91400. /** @hidden */
  91401. _viewMatrix: Matrix;
  91402. private _projectionMatrix;
  91403. private _wheelEventName;
  91404. /** @hidden */
  91405. _forcedViewPosition: Nullable<Vector3>;
  91406. /** @hidden */
  91407. _frustumPlanes: Plane[];
  91408. /**
  91409. * Gets the list of frustum planes (built from the active camera)
  91410. */
  91411. readonly frustumPlanes: Plane[];
  91412. /**
  91413. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91414. * This is useful if there are more lights that the maximum simulteanous authorized
  91415. */
  91416. requireLightSorting: boolean;
  91417. /** @hidden */
  91418. readonly useMaterialMeshMap: boolean;
  91419. /** @hidden */
  91420. readonly useClonedMeshhMap: boolean;
  91421. private _pointerOverMesh;
  91422. private _pickedDownMesh;
  91423. private _pickedUpMesh;
  91424. private _externalData;
  91425. private _uid;
  91426. /**
  91427. * @hidden
  91428. * Backing store of defined scene components.
  91429. */
  91430. _components: ISceneComponent[];
  91431. /**
  91432. * @hidden
  91433. * Backing store of defined scene components.
  91434. */
  91435. _serializableComponents: ISceneSerializableComponent[];
  91436. /**
  91437. * List of components to register on the next registration step.
  91438. */
  91439. private _transientComponents;
  91440. /**
  91441. * Registers the transient components if needed.
  91442. */
  91443. private _registerTransientComponents;
  91444. /**
  91445. * @hidden
  91446. * Add a component to the scene.
  91447. * Note that the ccomponent could be registered on th next frame if this is called after
  91448. * the register component stage.
  91449. * @param component Defines the component to add to the scene
  91450. */
  91451. _addComponent(component: ISceneComponent): void;
  91452. /**
  91453. * @hidden
  91454. * Gets a component from the scene.
  91455. * @param name defines the name of the component to retrieve
  91456. * @returns the component or null if not present
  91457. */
  91458. _getComponent(name: string): Nullable<ISceneComponent>;
  91459. /**
  91460. * @hidden
  91461. * Defines the actions happening before camera updates.
  91462. */
  91463. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91464. /**
  91465. * @hidden
  91466. * Defines the actions happening before clear the canvas.
  91467. */
  91468. _beforeClearStage: Stage<SimpleStageAction>;
  91469. /**
  91470. * @hidden
  91471. * Defines the actions when collecting render targets for the frame.
  91472. */
  91473. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91474. /**
  91475. * @hidden
  91476. * Defines the actions happening for one camera in the frame.
  91477. */
  91478. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91479. /**
  91480. * @hidden
  91481. * Defines the actions happening during the per mesh ready checks.
  91482. */
  91483. _isReadyForMeshStage: Stage<MeshStageAction>;
  91484. /**
  91485. * @hidden
  91486. * Defines the actions happening before evaluate active mesh checks.
  91487. */
  91488. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91489. /**
  91490. * @hidden
  91491. * Defines the actions happening during the evaluate sub mesh checks.
  91492. */
  91493. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91494. /**
  91495. * @hidden
  91496. * Defines the actions happening during the active mesh stage.
  91497. */
  91498. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91499. /**
  91500. * @hidden
  91501. * Defines the actions happening during the per camera render target step.
  91502. */
  91503. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91504. /**
  91505. * @hidden
  91506. * Defines the actions happening just before the active camera is drawing.
  91507. */
  91508. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91509. /**
  91510. * @hidden
  91511. * Defines the actions happening just before a render target is drawing.
  91512. */
  91513. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91514. /**
  91515. * @hidden
  91516. * Defines the actions happening just before a rendering group is drawing.
  91517. */
  91518. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91519. /**
  91520. * @hidden
  91521. * Defines the actions happening just before a mesh is drawing.
  91522. */
  91523. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91524. /**
  91525. * @hidden
  91526. * Defines the actions happening just after a mesh has been drawn.
  91527. */
  91528. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91529. /**
  91530. * @hidden
  91531. * Defines the actions happening just after a rendering group has been drawn.
  91532. */
  91533. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91534. /**
  91535. * @hidden
  91536. * Defines the actions happening just after the active camera has been drawn.
  91537. */
  91538. _afterCameraDrawStage: Stage<CameraStageAction>;
  91539. /**
  91540. * @hidden
  91541. * Defines the actions happening just after a render target has been drawn.
  91542. */
  91543. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91544. /**
  91545. * @hidden
  91546. * Defines the actions happening just after rendering all cameras and computing intersections.
  91547. */
  91548. _afterRenderStage: Stage<SimpleStageAction>;
  91549. /**
  91550. * @hidden
  91551. * Defines the actions happening when a pointer move event happens.
  91552. */
  91553. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91554. /**
  91555. * @hidden
  91556. * Defines the actions happening when a pointer down event happens.
  91557. */
  91558. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91559. /**
  91560. * @hidden
  91561. * Defines the actions happening when a pointer up event happens.
  91562. */
  91563. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91564. /**
  91565. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91566. */
  91567. private geometriesByUniqueId;
  91568. /**
  91569. * Creates a new Scene
  91570. * @param engine defines the engine to use to render this scene
  91571. * @param options defines the scene options
  91572. */
  91573. constructor(engine: Engine, options?: SceneOptions);
  91574. /**
  91575. * Gets a string idenfifying the name of the class
  91576. * @returns "Scene" string
  91577. */
  91578. getClassName(): string;
  91579. private _defaultMeshCandidates;
  91580. /**
  91581. * @hidden
  91582. */
  91583. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91584. private _defaultSubMeshCandidates;
  91585. /**
  91586. * @hidden
  91587. */
  91588. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91589. /**
  91590. * Sets the default candidate providers for the scene.
  91591. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91592. * and getCollidingSubMeshCandidates to their default function
  91593. */
  91594. setDefaultCandidateProviders(): void;
  91595. /**
  91596. * Gets the mesh that is currently under the pointer
  91597. */
  91598. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91599. /**
  91600. * Gets or sets the current on-screen X position of the pointer
  91601. */
  91602. pointerX: number;
  91603. /**
  91604. * Gets or sets the current on-screen Y position of the pointer
  91605. */
  91606. pointerY: number;
  91607. /**
  91608. * Gets the cached material (ie. the latest rendered one)
  91609. * @returns the cached material
  91610. */
  91611. getCachedMaterial(): Nullable<Material>;
  91612. /**
  91613. * Gets the cached effect (ie. the latest rendered one)
  91614. * @returns the cached effect
  91615. */
  91616. getCachedEffect(): Nullable<Effect>;
  91617. /**
  91618. * Gets the cached visibility state (ie. the latest rendered one)
  91619. * @returns the cached visibility state
  91620. */
  91621. getCachedVisibility(): Nullable<number>;
  91622. /**
  91623. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91624. * @param material defines the current material
  91625. * @param effect defines the current effect
  91626. * @param visibility defines the current visibility state
  91627. * @returns true if one parameter is not cached
  91628. */
  91629. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91630. /**
  91631. * Gets the engine associated with the scene
  91632. * @returns an Engine
  91633. */
  91634. getEngine(): Engine;
  91635. /**
  91636. * Gets the total number of vertices rendered per frame
  91637. * @returns the total number of vertices rendered per frame
  91638. */
  91639. getTotalVertices(): number;
  91640. /**
  91641. * Gets the performance counter for total vertices
  91642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91643. */
  91644. readonly totalVerticesPerfCounter: PerfCounter;
  91645. /**
  91646. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91647. * @returns the total number of active indices rendered per frame
  91648. */
  91649. getActiveIndices(): number;
  91650. /**
  91651. * Gets the performance counter for active indices
  91652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91653. */
  91654. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91655. /**
  91656. * Gets the total number of active particles rendered per frame
  91657. * @returns the total number of active particles rendered per frame
  91658. */
  91659. getActiveParticles(): number;
  91660. /**
  91661. * Gets the performance counter for active particles
  91662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91663. */
  91664. readonly activeParticlesPerfCounter: PerfCounter;
  91665. /**
  91666. * Gets the total number of active bones rendered per frame
  91667. * @returns the total number of active bones rendered per frame
  91668. */
  91669. getActiveBones(): number;
  91670. /**
  91671. * Gets the performance counter for active bones
  91672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91673. */
  91674. readonly activeBonesPerfCounter: PerfCounter;
  91675. /**
  91676. * Gets the array of active meshes
  91677. * @returns an array of AbstractMesh
  91678. */
  91679. getActiveMeshes(): SmartArray<AbstractMesh>;
  91680. /**
  91681. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91682. * @returns a number
  91683. */
  91684. getAnimationRatio(): number;
  91685. /**
  91686. * Gets an unique Id for the current render phase
  91687. * @returns a number
  91688. */
  91689. getRenderId(): number;
  91690. /**
  91691. * Gets an unique Id for the current frame
  91692. * @returns a number
  91693. */
  91694. getFrameId(): number;
  91695. /** Call this function if you want to manually increment the render Id*/
  91696. incrementRenderId(): void;
  91697. private _updatePointerPosition;
  91698. private _createUbo;
  91699. private _setRayOnPointerInfo;
  91700. /**
  91701. * Use this method to simulate a pointer move on a mesh
  91702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91705. * @returns the current scene
  91706. */
  91707. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91708. private _processPointerMove;
  91709. private _checkPrePointerObservable;
  91710. /**
  91711. * Use this method to simulate a pointer down on a mesh
  91712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91715. * @returns the current scene
  91716. */
  91717. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91718. private _processPointerDown;
  91719. /**
  91720. * Use this method to simulate a pointer up on a mesh
  91721. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91722. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91723. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91724. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91725. * @returns the current scene
  91726. */
  91727. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91728. private _processPointerUp;
  91729. /**
  91730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91732. * @returns true if the pointer was captured
  91733. */
  91734. isPointerCaptured(pointerId?: number): boolean;
  91735. /** @hidden */
  91736. _isPointerSwiping(): boolean;
  91737. /**
  91738. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91739. * @param attachUp defines if you want to attach events to pointerup
  91740. * @param attachDown defines if you want to attach events to pointerdown
  91741. * @param attachMove defines if you want to attach events to pointermove
  91742. */
  91743. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91744. /** Detaches all event handlers*/
  91745. detachControl(): void;
  91746. /**
  91747. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91748. * Delay loaded resources are not taking in account
  91749. * @return true if all required resources are ready
  91750. */
  91751. isReady(): boolean;
  91752. /** Resets all cached information relative to material (including effect and visibility) */
  91753. resetCachedMaterial(): void;
  91754. /**
  91755. * Registers a function to be called before every frame render
  91756. * @param func defines the function to register
  91757. */
  91758. registerBeforeRender(func: () => void): void;
  91759. /**
  91760. * Unregisters a function called before every frame render
  91761. * @param func defines the function to unregister
  91762. */
  91763. unregisterBeforeRender(func: () => void): void;
  91764. /**
  91765. * Registers a function to be called after every frame render
  91766. * @param func defines the function to register
  91767. */
  91768. registerAfterRender(func: () => void): void;
  91769. /**
  91770. * Unregisters a function called after every frame render
  91771. * @param func defines the function to unregister
  91772. */
  91773. unregisterAfterRender(func: () => void): void;
  91774. private _executeOnceBeforeRender;
  91775. /**
  91776. * The provided function will run before render once and will be disposed afterwards.
  91777. * A timeout delay can be provided so that the function will be executed in N ms.
  91778. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  91779. * @param func The function to be executed.
  91780. * @param timeout optional delay in ms
  91781. */
  91782. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  91783. /** @hidden */
  91784. _addPendingData(data: any): void;
  91785. /** @hidden */
  91786. _removePendingData(data: any): void;
  91787. /**
  91788. * Returns the number of items waiting to be loaded
  91789. * @returns the number of items waiting to be loaded
  91790. */
  91791. getWaitingItemsCount(): number;
  91792. /**
  91793. * Returns a boolean indicating if the scene is still loading data
  91794. */
  91795. readonly isLoading: boolean;
  91796. /**
  91797. * Registers a function to be executed when the scene is ready
  91798. * @param {Function} func - the function to be executed
  91799. */
  91800. executeWhenReady(func: () => void): void;
  91801. /**
  91802. * Returns a promise that resolves when the scene is ready
  91803. * @returns A promise that resolves when the scene is ready
  91804. */
  91805. whenReadyAsync(): Promise<void>;
  91806. /** @hidden */
  91807. _checkIsReady(): void;
  91808. /**
  91809. * Gets all animatable attached to the scene
  91810. */
  91811. readonly animatables: Animatable[];
  91812. /**
  91813. * Resets the last animation time frame.
  91814. * Useful to override when animations start running when loading a scene for the first time.
  91815. */
  91816. resetLastAnimationTimeFrame(): void;
  91817. /**
  91818. * Gets the current view matrix
  91819. * @returns a Matrix
  91820. */
  91821. getViewMatrix(): Matrix;
  91822. /**
  91823. * Gets the current projection matrix
  91824. * @returns a Matrix
  91825. */
  91826. getProjectionMatrix(): Matrix;
  91827. /**
  91828. * Gets the current transform matrix
  91829. * @returns a Matrix made of View * Projection
  91830. */
  91831. getTransformMatrix(): Matrix;
  91832. /**
  91833. * Sets the current transform matrix
  91834. * @param viewL defines the View matrix to use
  91835. * @param projectionL defines the Projection matrix to use
  91836. * @param viewR defines the right View matrix to use (if provided)
  91837. * @param projectionR defines the right Projection matrix to use (if provided)
  91838. */
  91839. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  91840. /**
  91841. * Gets the uniform buffer used to store scene data
  91842. * @returns a UniformBuffer
  91843. */
  91844. getSceneUniformBuffer(): UniformBuffer;
  91845. /**
  91846. * Gets an unique (relatively to the current scene) Id
  91847. * @returns an unique number for the scene
  91848. */
  91849. getUniqueId(): number;
  91850. /**
  91851. * Add a mesh to the list of scene's meshes
  91852. * @param newMesh defines the mesh to add
  91853. * @param recursive if all child meshes should also be added to the scene
  91854. */
  91855. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91856. /**
  91857. * Remove a mesh for the list of scene's meshes
  91858. * @param toRemove defines the mesh to remove
  91859. * @param recursive if all child meshes should also be removed from the scene
  91860. * @returns the index where the mesh was in the mesh list
  91861. */
  91862. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91863. /**
  91864. * Add a transform node to the list of scene's transform nodes
  91865. * @param newTransformNode defines the transform node to add
  91866. */
  91867. addTransformNode(newTransformNode: TransformNode): void;
  91868. /**
  91869. * Remove a transform node for the list of scene's transform nodes
  91870. * @param toRemove defines the transform node to remove
  91871. * @returns the index where the transform node was in the transform node list
  91872. */
  91873. removeTransformNode(toRemove: TransformNode): number;
  91874. /**
  91875. * Remove a skeleton for the list of scene's skeletons
  91876. * @param toRemove defines the skeleton to remove
  91877. * @returns the index where the skeleton was in the skeleton list
  91878. */
  91879. removeSkeleton(toRemove: Skeleton): number;
  91880. /**
  91881. * Remove a morph target for the list of scene's morph targets
  91882. * @param toRemove defines the morph target to remove
  91883. * @returns the index where the morph target was in the morph target list
  91884. */
  91885. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91886. /**
  91887. * Remove a light for the list of scene's lights
  91888. * @param toRemove defines the light to remove
  91889. * @returns the index where the light was in the light list
  91890. */
  91891. removeLight(toRemove: Light): number;
  91892. /**
  91893. * Remove a camera for the list of scene's cameras
  91894. * @param toRemove defines the camera to remove
  91895. * @returns the index where the camera was in the camera list
  91896. */
  91897. removeCamera(toRemove: Camera): number;
  91898. /**
  91899. * Remove a particle system for the list of scene's particle systems
  91900. * @param toRemove defines the particle system to remove
  91901. * @returns the index where the particle system was in the particle system list
  91902. */
  91903. removeParticleSystem(toRemove: IParticleSystem): number;
  91904. /**
  91905. * Remove a animation for the list of scene's animations
  91906. * @param toRemove defines the animation to remove
  91907. * @returns the index where the animation was in the animation list
  91908. */
  91909. removeAnimation(toRemove: Animation): number;
  91910. /**
  91911. * Removes the given animation group from this scene.
  91912. * @param toRemove The animation group to remove
  91913. * @returns The index of the removed animation group
  91914. */
  91915. removeAnimationGroup(toRemove: AnimationGroup): number;
  91916. /**
  91917. * Removes the given multi-material from this scene.
  91918. * @param toRemove The multi-material to remove
  91919. * @returns The index of the removed multi-material
  91920. */
  91921. removeMultiMaterial(toRemove: MultiMaterial): number;
  91922. /**
  91923. * Removes the given material from this scene.
  91924. * @param toRemove The material to remove
  91925. * @returns The index of the removed material
  91926. */
  91927. removeMaterial(toRemove: Material): number;
  91928. /**
  91929. * Removes the given action manager from this scene.
  91930. * @param toRemove The action manager to remove
  91931. * @returns The index of the removed action manager
  91932. */
  91933. removeActionManager(toRemove: AbstractActionManager): number;
  91934. /**
  91935. * Removes the given texture from this scene.
  91936. * @param toRemove The texture to remove
  91937. * @returns The index of the removed texture
  91938. */
  91939. removeTexture(toRemove: BaseTexture): number;
  91940. /**
  91941. * Adds the given light to this scene
  91942. * @param newLight The light to add
  91943. */
  91944. addLight(newLight: Light): void;
  91945. /**
  91946. * Sorts the list list based on light priorities
  91947. */
  91948. sortLightsByPriority(): void;
  91949. /**
  91950. * Adds the given camera to this scene
  91951. * @param newCamera The camera to add
  91952. */
  91953. addCamera(newCamera: Camera): void;
  91954. /**
  91955. * Adds the given skeleton to this scene
  91956. * @param newSkeleton The skeleton to add
  91957. */
  91958. addSkeleton(newSkeleton: Skeleton): void;
  91959. /**
  91960. * Adds the given particle system to this scene
  91961. * @param newParticleSystem The particle system to add
  91962. */
  91963. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91964. /**
  91965. * Adds the given animation to this scene
  91966. * @param newAnimation The animation to add
  91967. */
  91968. addAnimation(newAnimation: Animation): void;
  91969. /**
  91970. * Adds the given animation group to this scene.
  91971. * @param newAnimationGroup The animation group to add
  91972. */
  91973. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91974. /**
  91975. * Adds the given multi-material to this scene
  91976. * @param newMultiMaterial The multi-material to add
  91977. */
  91978. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91979. /**
  91980. * Adds the given material to this scene
  91981. * @param newMaterial The material to add
  91982. */
  91983. addMaterial(newMaterial: Material): void;
  91984. /**
  91985. * Adds the given morph target to this scene
  91986. * @param newMorphTargetManager The morph target to add
  91987. */
  91988. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91989. /**
  91990. * Adds the given geometry to this scene
  91991. * @param newGeometry The geometry to add
  91992. */
  91993. addGeometry(newGeometry: Geometry): void;
  91994. /**
  91995. * Adds the given action manager to this scene
  91996. * @param newActionManager The action manager to add
  91997. */
  91998. addActionManager(newActionManager: AbstractActionManager): void;
  91999. /**
  92000. * Adds the given texture to this scene.
  92001. * @param newTexture The texture to add
  92002. */
  92003. addTexture(newTexture: BaseTexture): void;
  92004. /**
  92005. * Switch active camera
  92006. * @param newCamera defines the new active camera
  92007. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92008. */
  92009. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92010. /**
  92011. * sets the active camera of the scene using its ID
  92012. * @param id defines the camera's ID
  92013. * @return the new active camera or null if none found.
  92014. */
  92015. setActiveCameraByID(id: string): Nullable<Camera>;
  92016. /**
  92017. * sets the active camera of the scene using its name
  92018. * @param name defines the camera's name
  92019. * @returns the new active camera or null if none found.
  92020. */
  92021. setActiveCameraByName(name: string): Nullable<Camera>;
  92022. /**
  92023. * get an animation group using its name
  92024. * @param name defines the material's name
  92025. * @return the animation group or null if none found.
  92026. */
  92027. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92028. /**
  92029. * Get a material using its unique id
  92030. * @param uniqueId defines the material's unique id
  92031. * @return the material or null if none found.
  92032. */
  92033. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92034. /**
  92035. * get a material using its id
  92036. * @param id defines the material's ID
  92037. * @return the material or null if none found.
  92038. */
  92039. getMaterialByID(id: string): Nullable<Material>;
  92040. /**
  92041. * Gets a material using its name
  92042. * @param name defines the material's name
  92043. * @return the material or null if none found.
  92044. */
  92045. getMaterialByName(name: string): Nullable<Material>;
  92046. /**
  92047. * Gets a camera using its id
  92048. * @param id defines the id to look for
  92049. * @returns the camera or null if not found
  92050. */
  92051. getCameraByID(id: string): Nullable<Camera>;
  92052. /**
  92053. * Gets a camera using its unique id
  92054. * @param uniqueId defines the unique id to look for
  92055. * @returns the camera or null if not found
  92056. */
  92057. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92058. /**
  92059. * Gets a camera using its name
  92060. * @param name defines the camera's name
  92061. * @return the camera or null if none found.
  92062. */
  92063. getCameraByName(name: string): Nullable<Camera>;
  92064. /**
  92065. * Gets a bone using its id
  92066. * @param id defines the bone's id
  92067. * @return the bone or null if not found
  92068. */
  92069. getBoneByID(id: string): Nullable<Bone>;
  92070. /**
  92071. * Gets a bone using its id
  92072. * @param name defines the bone's name
  92073. * @return the bone or null if not found
  92074. */
  92075. getBoneByName(name: string): Nullable<Bone>;
  92076. /**
  92077. * Gets a light node using its name
  92078. * @param name defines the the light's name
  92079. * @return the light or null if none found.
  92080. */
  92081. getLightByName(name: string): Nullable<Light>;
  92082. /**
  92083. * Gets a light node using its id
  92084. * @param id defines the light's id
  92085. * @return the light or null if none found.
  92086. */
  92087. getLightByID(id: string): Nullable<Light>;
  92088. /**
  92089. * Gets a light node using its scene-generated unique ID
  92090. * @param uniqueId defines the light's unique id
  92091. * @return the light or null if none found.
  92092. */
  92093. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92094. /**
  92095. * Gets a particle system by id
  92096. * @param id defines the particle system id
  92097. * @return the corresponding system or null if none found
  92098. */
  92099. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92100. /**
  92101. * Gets a geometry using its ID
  92102. * @param id defines the geometry's id
  92103. * @return the geometry or null if none found.
  92104. */
  92105. getGeometryByID(id: string): Nullable<Geometry>;
  92106. private _getGeometryByUniqueID;
  92107. /**
  92108. * Add a new geometry to this scene
  92109. * @param geometry defines the geometry to be added to the scene.
  92110. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92111. * @return a boolean defining if the geometry was added or not
  92112. */
  92113. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92114. /**
  92115. * Removes an existing geometry
  92116. * @param geometry defines the geometry to be removed from the scene
  92117. * @return a boolean defining if the geometry was removed or not
  92118. */
  92119. removeGeometry(geometry: Geometry): boolean;
  92120. /**
  92121. * Gets the list of geometries attached to the scene
  92122. * @returns an array of Geometry
  92123. */
  92124. getGeometries(): Geometry[];
  92125. /**
  92126. * Gets the first added mesh found of a given ID
  92127. * @param id defines the id to search for
  92128. * @return the mesh found or null if not found at all
  92129. */
  92130. getMeshByID(id: string): Nullable<AbstractMesh>;
  92131. /**
  92132. * Gets a list of meshes using their id
  92133. * @param id defines the id to search for
  92134. * @returns a list of meshes
  92135. */
  92136. getMeshesByID(id: string): Array<AbstractMesh>;
  92137. /**
  92138. * Gets the first added transform node found of a given ID
  92139. * @param id defines the id to search for
  92140. * @return the found transform node or null if not found at all.
  92141. */
  92142. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92143. /**
  92144. * Gets a transform node with its auto-generated unique id
  92145. * @param uniqueId efines the unique id to search for
  92146. * @return the found transform node or null if not found at all.
  92147. */
  92148. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92149. /**
  92150. * Gets a list of transform nodes using their id
  92151. * @param id defines the id to search for
  92152. * @returns a list of transform nodes
  92153. */
  92154. getTransformNodesByID(id: string): Array<TransformNode>;
  92155. /**
  92156. * Gets a mesh with its auto-generated unique id
  92157. * @param uniqueId defines the unique id to search for
  92158. * @return the found mesh or null if not found at all.
  92159. */
  92160. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92161. /**
  92162. * Gets a the last added mesh using a given id
  92163. * @param id defines the id to search for
  92164. * @return the found mesh or null if not found at all.
  92165. */
  92166. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92167. /**
  92168. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92169. * @param id defines the id to search for
  92170. * @return the found node or null if not found at all
  92171. */
  92172. getLastEntryByID(id: string): Nullable<Node>;
  92173. /**
  92174. * Gets a node (Mesh, Camera, Light) using a given id
  92175. * @param id defines the id to search for
  92176. * @return the found node or null if not found at all
  92177. */
  92178. getNodeByID(id: string): Nullable<Node>;
  92179. /**
  92180. * Gets a node (Mesh, Camera, Light) using a given name
  92181. * @param name defines the name to search for
  92182. * @return the found node or null if not found at all.
  92183. */
  92184. getNodeByName(name: string): Nullable<Node>;
  92185. /**
  92186. * Gets a mesh using a given name
  92187. * @param name defines the name to search for
  92188. * @return the found mesh or null if not found at all.
  92189. */
  92190. getMeshByName(name: string): Nullable<AbstractMesh>;
  92191. /**
  92192. * Gets a transform node using a given name
  92193. * @param name defines the name to search for
  92194. * @return the found transform node or null if not found at all.
  92195. */
  92196. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92197. /**
  92198. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92199. * @param id defines the id to search for
  92200. * @return the found skeleton or null if not found at all.
  92201. */
  92202. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92203. /**
  92204. * Gets a skeleton using a given auto generated unique id
  92205. * @param uniqueId defines the unique id to search for
  92206. * @return the found skeleton or null if not found at all.
  92207. */
  92208. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92209. /**
  92210. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92211. * @param id defines the id to search for
  92212. * @return the found skeleton or null if not found at all.
  92213. */
  92214. getSkeletonById(id: string): Nullable<Skeleton>;
  92215. /**
  92216. * Gets a skeleton using a given name
  92217. * @param name defines the name to search for
  92218. * @return the found skeleton or null if not found at all.
  92219. */
  92220. getSkeletonByName(name: string): Nullable<Skeleton>;
  92221. /**
  92222. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92223. * @param id defines the id to search for
  92224. * @return the found morph target manager or null if not found at all.
  92225. */
  92226. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92227. /**
  92228. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92229. * @param id defines the id to search for
  92230. * @return the found morph target or null if not found at all.
  92231. */
  92232. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92233. /**
  92234. * Gets a boolean indicating if the given mesh is active
  92235. * @param mesh defines the mesh to look for
  92236. * @returns true if the mesh is in the active list
  92237. */
  92238. isActiveMesh(mesh: AbstractMesh): boolean;
  92239. /**
  92240. * Return a unique id as a string which can serve as an identifier for the scene
  92241. */
  92242. readonly uid: string;
  92243. /**
  92244. * Add an externaly attached data from its key.
  92245. * This method call will fail and return false, if such key already exists.
  92246. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92247. * @param key the unique key that identifies the data
  92248. * @param data the data object to associate to the key for this Engine instance
  92249. * @return true if no such key were already present and the data was added successfully, false otherwise
  92250. */
  92251. addExternalData<T>(key: string, data: T): boolean;
  92252. /**
  92253. * Get an externaly attached data from its key
  92254. * @param key the unique key that identifies the data
  92255. * @return the associated data, if present (can be null), or undefined if not present
  92256. */
  92257. getExternalData<T>(key: string): Nullable<T>;
  92258. /**
  92259. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92260. * @param key the unique key that identifies the data
  92261. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92262. * @return the associated data, can be null if the factory returned null.
  92263. */
  92264. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92265. /**
  92266. * Remove an externaly attached data from the Engine instance
  92267. * @param key the unique key that identifies the data
  92268. * @return true if the data was successfully removed, false if it doesn't exist
  92269. */
  92270. removeExternalData(key: string): boolean;
  92271. private _evaluateSubMesh;
  92272. /**
  92273. * Clear the processed materials smart array preventing retention point in material dispose.
  92274. */
  92275. freeProcessedMaterials(): void;
  92276. private _preventFreeActiveMeshesAndRenderingGroups;
  92277. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92278. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92279. * when disposing several meshes in a row or a hierarchy of meshes.
  92280. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92281. */
  92282. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92283. /**
  92284. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92285. */
  92286. freeActiveMeshes(): void;
  92287. /**
  92288. * Clear the info related to rendering groups preventing retention points during dispose.
  92289. */
  92290. freeRenderingGroups(): void;
  92291. /** @hidden */
  92292. _isInIntermediateRendering(): boolean;
  92293. /**
  92294. * Lambda returning the list of potentially active meshes.
  92295. */
  92296. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92297. /**
  92298. * Lambda returning the list of potentially active sub meshes.
  92299. */
  92300. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92301. /**
  92302. * Lambda returning the list of potentially intersecting sub meshes.
  92303. */
  92304. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92305. /**
  92306. * Lambda returning the list of potentially colliding sub meshes.
  92307. */
  92308. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92309. private _activeMeshesFrozen;
  92310. /**
  92311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92312. * @returns the current scene
  92313. */
  92314. freezeActiveMeshes(): Scene;
  92315. /**
  92316. * Use this function to restart evaluating active meshes on every frame
  92317. * @returns the current scene
  92318. */
  92319. unfreezeActiveMeshes(): Scene;
  92320. private _evaluateActiveMeshes;
  92321. private _activeMesh;
  92322. /**
  92323. * Update the transform matrix to update from the current active camera
  92324. * @param force defines a boolean used to force the update even if cache is up to date
  92325. */
  92326. updateTransformMatrix(force?: boolean): void;
  92327. private _bindFrameBuffer;
  92328. /** @hidden */
  92329. _allowPostProcessClearColor: boolean;
  92330. /** @hidden */
  92331. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92332. private _processSubCameras;
  92333. private _checkIntersections;
  92334. /** @hidden */
  92335. _advancePhysicsEngineStep(step: number): void;
  92336. /**
  92337. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92338. */
  92339. getDeterministicFrameTime: () => number;
  92340. /** @hidden */
  92341. _animate(): void;
  92342. /**
  92343. * Render the scene
  92344. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92345. */
  92346. render(updateCameras?: boolean): void;
  92347. /**
  92348. * Freeze all materials
  92349. * A frozen material will not be updatable but should be faster to render
  92350. */
  92351. freezeMaterials(): void;
  92352. /**
  92353. * Unfreeze all materials
  92354. * A frozen material will not be updatable but should be faster to render
  92355. */
  92356. unfreezeMaterials(): void;
  92357. /**
  92358. * Releases all held ressources
  92359. */
  92360. dispose(): void;
  92361. /**
  92362. * Gets if the scene is already disposed
  92363. */
  92364. readonly isDisposed: boolean;
  92365. /**
  92366. * Call this function to reduce memory footprint of the scene.
  92367. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92368. */
  92369. clearCachedVertexData(): void;
  92370. /**
  92371. * This function will remove the local cached buffer data from texture.
  92372. * It will save memory but will prevent the texture from being rebuilt
  92373. */
  92374. cleanCachedTextureBuffer(): void;
  92375. /**
  92376. * Get the world extend vectors with an optional filter
  92377. *
  92378. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92379. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92380. */
  92381. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92382. min: Vector3;
  92383. max: Vector3;
  92384. };
  92385. /**
  92386. * Creates a ray that can be used to pick in the scene
  92387. * @param x defines the x coordinate of the origin (on-screen)
  92388. * @param y defines the y coordinate of the origin (on-screen)
  92389. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92390. * @param camera defines the camera to use for the picking
  92391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92392. * @returns a Ray
  92393. */
  92394. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92395. /**
  92396. * Creates a ray that can be used to pick in the scene
  92397. * @param x defines the x coordinate of the origin (on-screen)
  92398. * @param y defines the y coordinate of the origin (on-screen)
  92399. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92400. * @param result defines the ray where to store the picking ray
  92401. * @param camera defines the camera to use for the picking
  92402. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92403. * @returns the current scene
  92404. */
  92405. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92406. /**
  92407. * Creates a ray that can be used to pick in the scene
  92408. * @param x defines the x coordinate of the origin (on-screen)
  92409. * @param y defines the y coordinate of the origin (on-screen)
  92410. * @param camera defines the camera to use for the picking
  92411. * @returns a Ray
  92412. */
  92413. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92414. /**
  92415. * Creates a ray that can be used to pick in the scene
  92416. * @param x defines the x coordinate of the origin (on-screen)
  92417. * @param y defines the y coordinate of the origin (on-screen)
  92418. * @param result defines the ray where to store the picking ray
  92419. * @param camera defines the camera to use for the picking
  92420. * @returns the current scene
  92421. */
  92422. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92423. /** Launch a ray to try to pick a mesh in the scene
  92424. * @param x position on screen
  92425. * @param y position on screen
  92426. * @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
  92427. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92428. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92430. * @returns a PickingInfo
  92431. */
  92432. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92433. /** Use the given ray to pick a mesh in the scene
  92434. * @param ray The ray to use to pick meshes
  92435. * @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
  92436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92438. * @returns a PickingInfo
  92439. */
  92440. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92441. /**
  92442. * Launch a ray to try to pick a mesh in the scene
  92443. * @param x X position on screen
  92444. * @param y Y position on screen
  92445. * @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
  92446. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92447. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92448. * @returns an array of PickingInfo
  92449. */
  92450. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92451. /**
  92452. * Launch a ray to try to pick a mesh in the scene
  92453. * @param ray Ray to use
  92454. * @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
  92455. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92456. * @returns an array of PickingInfo
  92457. */
  92458. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92459. /**
  92460. * Force the value of meshUnderPointer
  92461. * @param mesh defines the mesh to use
  92462. */
  92463. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92464. /**
  92465. * Gets the mesh under the pointer
  92466. * @returns a Mesh or null if no mesh is under the pointer
  92467. */
  92468. getPointerOverMesh(): Nullable<AbstractMesh>;
  92469. /** @hidden */
  92470. _rebuildGeometries(): void;
  92471. /** @hidden */
  92472. _rebuildTextures(): void;
  92473. private _getByTags;
  92474. /**
  92475. * Get a list of meshes by tags
  92476. * @param tagsQuery defines the tags query to use
  92477. * @param forEach defines a predicate used to filter results
  92478. * @returns an array of Mesh
  92479. */
  92480. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92481. /**
  92482. * Get a list of cameras by tags
  92483. * @param tagsQuery defines the tags query to use
  92484. * @param forEach defines a predicate used to filter results
  92485. * @returns an array of Camera
  92486. */
  92487. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92488. /**
  92489. * Get a list of lights by tags
  92490. * @param tagsQuery defines the tags query to use
  92491. * @param forEach defines a predicate used to filter results
  92492. * @returns an array of Light
  92493. */
  92494. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92495. /**
  92496. * Get a list of materials by tags
  92497. * @param tagsQuery defines the tags query to use
  92498. * @param forEach defines a predicate used to filter results
  92499. * @returns an array of Material
  92500. */
  92501. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92502. /**
  92503. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92504. * This allowed control for front to back rendering or reversly depending of the special needs.
  92505. *
  92506. * @param renderingGroupId The rendering group id corresponding to its index
  92507. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92508. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92509. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92510. */
  92511. 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;
  92512. /**
  92513. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92514. *
  92515. * @param renderingGroupId The rendering group id corresponding to its index
  92516. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92517. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92518. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92519. */
  92520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92521. /**
  92522. * Gets the current auto clear configuration for one rendering group of the rendering
  92523. * manager.
  92524. * @param index the rendering group index to get the information for
  92525. * @returns The auto clear setup for the requested rendering group
  92526. */
  92527. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92528. private _blockMaterialDirtyMechanism;
  92529. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92530. blockMaterialDirtyMechanism: boolean;
  92531. /**
  92532. * Will flag all materials as dirty to trigger new shader compilation
  92533. * @param flag defines the flag used to specify which material part must be marked as dirty
  92534. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92535. */
  92536. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92537. /** @hidden */
  92538. _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;
  92539. /** @hidden */
  92540. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92541. }
  92542. }
  92543. declare module BABYLON {
  92544. /**
  92545. * Set of assets to keep when moving a scene into an asset container.
  92546. */
  92547. export class KeepAssets extends AbstractScene {
  92548. }
  92549. /**
  92550. * Container with a set of assets that can be added or removed from a scene.
  92551. */
  92552. export class AssetContainer extends AbstractScene {
  92553. /**
  92554. * The scene the AssetContainer belongs to.
  92555. */
  92556. scene: Scene;
  92557. /**
  92558. * Instantiates an AssetContainer.
  92559. * @param scene The scene the AssetContainer belongs to.
  92560. */
  92561. constructor(scene: Scene);
  92562. /**
  92563. * Adds all the assets from the container to the scene.
  92564. */
  92565. addAllToScene(): void;
  92566. /**
  92567. * Removes all the assets in the container from the scene
  92568. */
  92569. removeAllFromScene(): void;
  92570. /**
  92571. * Disposes all the assets in the container
  92572. */
  92573. dispose(): void;
  92574. private _moveAssets;
  92575. /**
  92576. * Removes all the assets contained in the scene and adds them to the container.
  92577. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92578. */
  92579. moveAllFromScene(keepAssets?: KeepAssets): void;
  92580. /**
  92581. * 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.
  92582. * @returns the root mesh
  92583. */
  92584. createRootMesh(): Mesh;
  92585. }
  92586. }
  92587. declare module BABYLON {
  92588. /**
  92589. * Defines how the parser contract is defined.
  92590. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92591. */
  92592. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92593. /**
  92594. * Defines how the individual parser contract is defined.
  92595. * These parser can parse an individual asset
  92596. */
  92597. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92598. /**
  92599. * Base class of the scene acting as a container for the different elements composing a scene.
  92600. * This class is dynamically extended by the different components of the scene increasing
  92601. * flexibility and reducing coupling
  92602. */
  92603. export abstract class AbstractScene {
  92604. /**
  92605. * Stores the list of available parsers in the application.
  92606. */
  92607. private static _BabylonFileParsers;
  92608. /**
  92609. * Stores the list of available individual parsers in the application.
  92610. */
  92611. private static _IndividualBabylonFileParsers;
  92612. /**
  92613. * Adds a parser in the list of available ones
  92614. * @param name Defines the name of the parser
  92615. * @param parser Defines the parser to add
  92616. */
  92617. static AddParser(name: string, parser: BabylonFileParser): void;
  92618. /**
  92619. * Gets a general parser from the list of avaialble ones
  92620. * @param name Defines the name of the parser
  92621. * @returns the requested parser or null
  92622. */
  92623. static GetParser(name: string): Nullable<BabylonFileParser>;
  92624. /**
  92625. * Adds n individual parser in the list of available ones
  92626. * @param name Defines the name of the parser
  92627. * @param parser Defines the parser to add
  92628. */
  92629. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92630. /**
  92631. * Gets an individual parser from the list of avaialble ones
  92632. * @param name Defines the name of the parser
  92633. * @returns the requested parser or null
  92634. */
  92635. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92636. /**
  92637. * Parser json data and populate both a scene and its associated container object
  92638. * @param jsonData Defines the data to parse
  92639. * @param scene Defines the scene to parse the data for
  92640. * @param container Defines the container attached to the parsing sequence
  92641. * @param rootUrl Defines the root url of the data
  92642. */
  92643. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92644. /**
  92645. * Gets the list of root nodes (ie. nodes with no parent)
  92646. */
  92647. rootNodes: Node[];
  92648. /** All of the cameras added to this scene
  92649. * @see http://doc.babylonjs.com/babylon101/cameras
  92650. */
  92651. cameras: Camera[];
  92652. /**
  92653. * All of the lights added to this scene
  92654. * @see http://doc.babylonjs.com/babylon101/lights
  92655. */
  92656. lights: Light[];
  92657. /**
  92658. * All of the (abstract) meshes added to this scene
  92659. */
  92660. meshes: AbstractMesh[];
  92661. /**
  92662. * The list of skeletons added to the scene
  92663. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92664. */
  92665. skeletons: Skeleton[];
  92666. /**
  92667. * All of the particle systems added to this scene
  92668. * @see http://doc.babylonjs.com/babylon101/particles
  92669. */
  92670. particleSystems: IParticleSystem[];
  92671. /**
  92672. * Gets a list of Animations associated with the scene
  92673. */
  92674. animations: Animation[];
  92675. /**
  92676. * All of the animation groups added to this scene
  92677. * @see http://doc.babylonjs.com/how_to/group
  92678. */
  92679. animationGroups: AnimationGroup[];
  92680. /**
  92681. * All of the multi-materials added to this scene
  92682. * @see http://doc.babylonjs.com/how_to/multi_materials
  92683. */
  92684. multiMaterials: MultiMaterial[];
  92685. /**
  92686. * All of the materials added to this scene
  92687. * In the context of a Scene, it is not supposed to be modified manually.
  92688. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92689. * Note also that the order of the Material wihin the array is not significant and might change.
  92690. * @see http://doc.babylonjs.com/babylon101/materials
  92691. */
  92692. materials: Material[];
  92693. /**
  92694. * The list of morph target managers added to the scene
  92695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92696. */
  92697. morphTargetManagers: MorphTargetManager[];
  92698. /**
  92699. * The list of geometries used in the scene.
  92700. */
  92701. geometries: Geometry[];
  92702. /**
  92703. * All of the tranform nodes added to this scene
  92704. * In the context of a Scene, it is not supposed to be modified manually.
  92705. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92706. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92707. * @see http://doc.babylonjs.com/how_to/transformnode
  92708. */
  92709. transformNodes: TransformNode[];
  92710. /**
  92711. * ActionManagers available on the scene.
  92712. */
  92713. actionManagers: AbstractActionManager[];
  92714. /**
  92715. * Textures to keep.
  92716. */
  92717. textures: BaseTexture[];
  92718. /**
  92719. * Environment texture for the scene
  92720. */
  92721. environmentTexture: Nullable<BaseTexture>;
  92722. }
  92723. }
  92724. declare module BABYLON {
  92725. /**
  92726. * Defines a sound that can be played in the application.
  92727. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92729. */
  92730. export class Sound {
  92731. /**
  92732. * The name of the sound in the scene.
  92733. */
  92734. name: string;
  92735. /**
  92736. * Does the sound autoplay once loaded.
  92737. */
  92738. autoplay: boolean;
  92739. /**
  92740. * Does the sound loop after it finishes playing once.
  92741. */
  92742. loop: boolean;
  92743. /**
  92744. * Does the sound use a custom attenuation curve to simulate the falloff
  92745. * happening when the source gets further away from the camera.
  92746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92747. */
  92748. useCustomAttenuation: boolean;
  92749. /**
  92750. * The sound track id this sound belongs to.
  92751. */
  92752. soundTrackId: number;
  92753. /**
  92754. * Is this sound currently played.
  92755. */
  92756. isPlaying: boolean;
  92757. /**
  92758. * Is this sound currently paused.
  92759. */
  92760. isPaused: boolean;
  92761. /**
  92762. * Does this sound enables spatial sound.
  92763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92764. */
  92765. spatialSound: boolean;
  92766. /**
  92767. * Define the reference distance the sound should be heard perfectly.
  92768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92769. */
  92770. refDistance: number;
  92771. /**
  92772. * Define the roll off factor of spatial sounds.
  92773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92774. */
  92775. rolloffFactor: number;
  92776. /**
  92777. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  92778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92779. */
  92780. maxDistance: number;
  92781. /**
  92782. * Define the distance attenuation model the sound will follow.
  92783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92784. */
  92785. distanceModel: string;
  92786. /**
  92787. * @hidden
  92788. * Back Compat
  92789. **/
  92790. onended: () => any;
  92791. /**
  92792. * Observable event when the current playing sound finishes.
  92793. */
  92794. onEndedObservable: Observable<Sound>;
  92795. private _panningModel;
  92796. private _playbackRate;
  92797. private _streaming;
  92798. private _startTime;
  92799. private _startOffset;
  92800. private _position;
  92801. /** @hidden */
  92802. _positionInEmitterSpace: boolean;
  92803. private _localDirection;
  92804. private _volume;
  92805. private _isReadyToPlay;
  92806. private _isDirectional;
  92807. private _readyToPlayCallback;
  92808. private _audioBuffer;
  92809. private _soundSource;
  92810. private _streamingSource;
  92811. private _soundPanner;
  92812. private _soundGain;
  92813. private _inputAudioNode;
  92814. private _outputAudioNode;
  92815. private _coneInnerAngle;
  92816. private _coneOuterAngle;
  92817. private _coneOuterGain;
  92818. private _scene;
  92819. private _connectedTransformNode;
  92820. private _customAttenuationFunction;
  92821. private _registerFunc;
  92822. private _isOutputConnected;
  92823. private _htmlAudioElement;
  92824. private _urlType;
  92825. /** @hidden */
  92826. static _SceneComponentInitialization: (scene: Scene) => void;
  92827. /**
  92828. * Create a sound and attach it to a scene
  92829. * @param name Name of your sound
  92830. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92831. * @param scene defines the scene the sound belongs to
  92832. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92833. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92834. */
  92835. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92836. /**
  92837. * Release the sound and its associated resources
  92838. */
  92839. dispose(): void;
  92840. /**
  92841. * Gets if the sounds is ready to be played or not.
  92842. * @returns true if ready, otherwise false
  92843. */
  92844. isReady(): boolean;
  92845. private _soundLoaded;
  92846. /**
  92847. * Sets the data of the sound from an audiobuffer
  92848. * @param audioBuffer The audioBuffer containing the data
  92849. */
  92850. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92851. /**
  92852. * Updates the current sounds options such as maxdistance, loop...
  92853. * @param options A JSON object containing values named as the object properties
  92854. */
  92855. updateOptions(options: any): void;
  92856. private _createSpatialParameters;
  92857. private _updateSpatialParameters;
  92858. /**
  92859. * Switch the panning model to HRTF:
  92860. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92862. */
  92863. switchPanningModelToHRTF(): void;
  92864. /**
  92865. * Switch the panning model to Equal Power:
  92866. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92868. */
  92869. switchPanningModelToEqualPower(): void;
  92870. private _switchPanningModel;
  92871. /**
  92872. * Connect this sound to a sound track audio node like gain...
  92873. * @param soundTrackAudioNode the sound track audio node to connect to
  92874. */
  92875. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92876. /**
  92877. * Transform this sound into a directional source
  92878. * @param coneInnerAngle Size of the inner cone in degree
  92879. * @param coneOuterAngle Size of the outer cone in degree
  92880. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92881. */
  92882. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92883. /**
  92884. * Gets or sets the inner angle for the directional cone.
  92885. */
  92886. /**
  92887. * Gets or sets the inner angle for the directional cone.
  92888. */
  92889. directionalConeInnerAngle: number;
  92890. /**
  92891. * Gets or sets the outer angle for the directional cone.
  92892. */
  92893. /**
  92894. * Gets or sets the outer angle for the directional cone.
  92895. */
  92896. directionalConeOuterAngle: number;
  92897. /**
  92898. * Sets the position of the emitter if spatial sound is enabled
  92899. * @param newPosition Defines the new posisiton
  92900. */
  92901. setPosition(newPosition: Vector3): void;
  92902. /**
  92903. * Sets the local direction of the emitter if spatial sound is enabled
  92904. * @param newLocalDirection Defines the new local direction
  92905. */
  92906. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92907. private _updateDirection;
  92908. /** @hidden */
  92909. updateDistanceFromListener(): void;
  92910. /**
  92911. * Sets a new custom attenuation function for the sound.
  92912. * @param callback Defines the function used for the attenuation
  92913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92914. */
  92915. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92916. /**
  92917. * Play the sound
  92918. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92919. * @param offset (optional) Start the sound setting it at a specific time
  92920. */
  92921. play(time?: number, offset?: number): void;
  92922. private _onended;
  92923. /**
  92924. * Stop the sound
  92925. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92926. */
  92927. stop(time?: number): void;
  92928. /**
  92929. * Put the sound in pause
  92930. */
  92931. pause(): void;
  92932. /**
  92933. * Sets a dedicated volume for this sounds
  92934. * @param newVolume Define the new volume of the sound
  92935. * @param time Define in how long the sound should be at this value
  92936. */
  92937. setVolume(newVolume: number, time?: number): void;
  92938. /**
  92939. * Set the sound play back rate
  92940. * @param newPlaybackRate Define the playback rate the sound should be played at
  92941. */
  92942. setPlaybackRate(newPlaybackRate: number): void;
  92943. /**
  92944. * Gets the volume of the sound.
  92945. * @returns the volume of the sound
  92946. */
  92947. getVolume(): number;
  92948. /**
  92949. * Attach the sound to a dedicated mesh
  92950. * @param transformNode The transform node to connect the sound with
  92951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92952. */
  92953. attachToMesh(transformNode: TransformNode): void;
  92954. /**
  92955. * Detach the sound from the previously attached mesh
  92956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92957. */
  92958. detachFromMesh(): void;
  92959. private _onRegisterAfterWorldMatrixUpdate;
  92960. /**
  92961. * Clone the current sound in the scene.
  92962. * @returns the new sound clone
  92963. */
  92964. clone(): Nullable<Sound>;
  92965. /**
  92966. * Gets the current underlying audio buffer containing the data
  92967. * @returns the audio buffer
  92968. */
  92969. getAudioBuffer(): Nullable<AudioBuffer>;
  92970. /**
  92971. * Serializes the Sound in a JSON representation
  92972. * @returns the JSON representation of the sound
  92973. */
  92974. serialize(): any;
  92975. /**
  92976. * Parse a JSON representation of a sound to innstantiate in a given scene
  92977. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92978. * @param scene Define the scene the new parsed sound should be created in
  92979. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92980. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92981. * @returns the newly parsed sound
  92982. */
  92983. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92984. }
  92985. }
  92986. declare module BABYLON {
  92987. /**
  92988. * This defines an action helpful to play a defined sound on a triggered action.
  92989. */
  92990. export class PlaySoundAction extends Action {
  92991. private _sound;
  92992. /**
  92993. * Instantiate the action
  92994. * @param triggerOptions defines the trigger options
  92995. * @param sound defines the sound to play
  92996. * @param condition defines the trigger related conditions
  92997. */
  92998. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92999. /** @hidden */
  93000. _prepare(): void;
  93001. /**
  93002. * Execute the action and play the sound.
  93003. */
  93004. execute(): void;
  93005. /**
  93006. * Serializes the actions and its related information.
  93007. * @param parent defines the object to serialize in
  93008. * @returns the serialized object
  93009. */
  93010. serialize(parent: any): any;
  93011. }
  93012. /**
  93013. * This defines an action helpful to stop a defined sound on a triggered action.
  93014. */
  93015. export class StopSoundAction extends Action {
  93016. private _sound;
  93017. /**
  93018. * Instantiate the action
  93019. * @param triggerOptions defines the trigger options
  93020. * @param sound defines the sound to stop
  93021. * @param condition defines the trigger related conditions
  93022. */
  93023. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93024. /** @hidden */
  93025. _prepare(): void;
  93026. /**
  93027. * Execute the action and stop the sound.
  93028. */
  93029. execute(): void;
  93030. /**
  93031. * Serializes the actions and its related information.
  93032. * @param parent defines the object to serialize in
  93033. * @returns the serialized object
  93034. */
  93035. serialize(parent: any): any;
  93036. }
  93037. }
  93038. declare module BABYLON {
  93039. /**
  93040. * This defines an action responsible to change the value of a property
  93041. * by interpolating between its current value and the newly set one once triggered.
  93042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93043. */
  93044. export class InterpolateValueAction extends Action {
  93045. /**
  93046. * Defines the path of the property where the value should be interpolated
  93047. */
  93048. propertyPath: string;
  93049. /**
  93050. * Defines the target value at the end of the interpolation.
  93051. */
  93052. value: any;
  93053. /**
  93054. * Defines the time it will take for the property to interpolate to the value.
  93055. */
  93056. duration: number;
  93057. /**
  93058. * Defines if the other scene animations should be stopped when the action has been triggered
  93059. */
  93060. stopOtherAnimations?: boolean;
  93061. /**
  93062. * Defines a callback raised once the interpolation animation has been done.
  93063. */
  93064. onInterpolationDone?: () => void;
  93065. /**
  93066. * Observable triggered once the interpolation animation has been done.
  93067. */
  93068. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93069. private _target;
  93070. private _effectiveTarget;
  93071. private _property;
  93072. /**
  93073. * Instantiate the action
  93074. * @param triggerOptions defines the trigger options
  93075. * @param target defines the object containing the value to interpolate
  93076. * @param propertyPath defines the path to the property in the target object
  93077. * @param value defines the target value at the end of the interpolation
  93078. * @param duration deines the time it will take for the property to interpolate to the value.
  93079. * @param condition defines the trigger related conditions
  93080. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93081. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93082. */
  93083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93084. /** @hidden */
  93085. _prepare(): void;
  93086. /**
  93087. * Execute the action starts the value interpolation.
  93088. */
  93089. execute(): void;
  93090. /**
  93091. * Serializes the actions and its related information.
  93092. * @param parent defines the object to serialize in
  93093. * @returns the serialized object
  93094. */
  93095. serialize(parent: any): any;
  93096. }
  93097. }
  93098. declare module BABYLON {
  93099. /**
  93100. * Options allowed during the creation of a sound track.
  93101. */
  93102. export interface ISoundTrackOptions {
  93103. /**
  93104. * The volume the sound track should take during creation
  93105. */
  93106. volume?: number;
  93107. /**
  93108. * Define if the sound track is the main sound track of the scene
  93109. */
  93110. mainTrack?: boolean;
  93111. }
  93112. /**
  93113. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93114. * It will be also used in a future release to apply effects on a specific track.
  93115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93116. */
  93117. export class SoundTrack {
  93118. /**
  93119. * The unique identifier of the sound track in the scene.
  93120. */
  93121. id: number;
  93122. /**
  93123. * The list of sounds included in the sound track.
  93124. */
  93125. soundCollection: Array<Sound>;
  93126. private _outputAudioNode;
  93127. private _scene;
  93128. private _isMainTrack;
  93129. private _connectedAnalyser;
  93130. private _options;
  93131. private _isInitialized;
  93132. /**
  93133. * Creates a new sound track.
  93134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93135. * @param scene Define the scene the sound track belongs to
  93136. * @param options
  93137. */
  93138. constructor(scene: Scene, options?: ISoundTrackOptions);
  93139. private _initializeSoundTrackAudioGraph;
  93140. /**
  93141. * Release the sound track and its associated resources
  93142. */
  93143. dispose(): void;
  93144. /**
  93145. * Adds a sound to this sound track
  93146. * @param sound define the cound to add
  93147. * @ignoreNaming
  93148. */
  93149. AddSound(sound: Sound): void;
  93150. /**
  93151. * Removes a sound to this sound track
  93152. * @param sound define the cound to remove
  93153. * @ignoreNaming
  93154. */
  93155. RemoveSound(sound: Sound): void;
  93156. /**
  93157. * Set a global volume for the full sound track.
  93158. * @param newVolume Define the new volume of the sound track
  93159. */
  93160. setVolume(newVolume: number): void;
  93161. /**
  93162. * Switch the panning model to HRTF:
  93163. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93165. */
  93166. switchPanningModelToHRTF(): void;
  93167. /**
  93168. * Switch the panning model to Equal Power:
  93169. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93171. */
  93172. switchPanningModelToEqualPower(): void;
  93173. /**
  93174. * Connect the sound track to an audio analyser allowing some amazing
  93175. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93177. * @param analyser The analyser to connect to the engine
  93178. */
  93179. connectToAnalyser(analyser: Analyser): void;
  93180. }
  93181. }
  93182. declare module BABYLON {
  93183. interface AbstractScene {
  93184. /**
  93185. * The list of sounds used in the scene.
  93186. */
  93187. sounds: Nullable<Array<Sound>>;
  93188. }
  93189. interface Scene {
  93190. /**
  93191. * @hidden
  93192. * Backing field
  93193. */
  93194. _mainSoundTrack: SoundTrack;
  93195. /**
  93196. * The main sound track played by the scene.
  93197. * It cotains your primary collection of sounds.
  93198. */
  93199. mainSoundTrack: SoundTrack;
  93200. /**
  93201. * The list of sound tracks added to the scene
  93202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93203. */
  93204. soundTracks: Nullable<Array<SoundTrack>>;
  93205. /**
  93206. * Gets a sound using a given name
  93207. * @param name defines the name to search for
  93208. * @return the found sound or null if not found at all.
  93209. */
  93210. getSoundByName(name: string): Nullable<Sound>;
  93211. /**
  93212. * Gets or sets if audio support is enabled
  93213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93214. */
  93215. audioEnabled: boolean;
  93216. /**
  93217. * Gets or sets if audio will be output to headphones
  93218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93219. */
  93220. headphone: boolean;
  93221. }
  93222. /**
  93223. * Defines the sound scene component responsible to manage any sounds
  93224. * in a given scene.
  93225. */
  93226. export class AudioSceneComponent implements ISceneSerializableComponent {
  93227. /**
  93228. * The component name helpfull to identify the component in the list of scene components.
  93229. */
  93230. readonly name: string;
  93231. /**
  93232. * The scene the component belongs to.
  93233. */
  93234. scene: Scene;
  93235. private _audioEnabled;
  93236. /**
  93237. * Gets whether audio is enabled or not.
  93238. * Please use related enable/disable method to switch state.
  93239. */
  93240. readonly audioEnabled: boolean;
  93241. private _headphone;
  93242. /**
  93243. * Gets whether audio is outputing to headphone or not.
  93244. * Please use the according Switch methods to change output.
  93245. */
  93246. readonly headphone: boolean;
  93247. /**
  93248. * Creates a new instance of the component for the given scene
  93249. * @param scene Defines the scene to register the component in
  93250. */
  93251. constructor(scene: Scene);
  93252. /**
  93253. * Registers the component in a given scene
  93254. */
  93255. register(): void;
  93256. /**
  93257. * Rebuilds the elements related to this component in case of
  93258. * context lost for instance.
  93259. */
  93260. rebuild(): void;
  93261. /**
  93262. * Serializes the component data to the specified json object
  93263. * @param serializationObject The object to serialize to
  93264. */
  93265. serialize(serializationObject: any): void;
  93266. /**
  93267. * Adds all the element from the container to the scene
  93268. * @param container the container holding the elements
  93269. */
  93270. addFromContainer(container: AbstractScene): void;
  93271. /**
  93272. * Removes all the elements in the container from the scene
  93273. * @param container contains the elements to remove
  93274. * @param dispose if the removed element should be disposed (default: false)
  93275. */
  93276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93277. /**
  93278. * Disposes the component and the associated ressources.
  93279. */
  93280. dispose(): void;
  93281. /**
  93282. * Disables audio in the associated scene.
  93283. */
  93284. disableAudio(): void;
  93285. /**
  93286. * Enables audio in the associated scene.
  93287. */
  93288. enableAudio(): void;
  93289. /**
  93290. * Switch audio to headphone output.
  93291. */
  93292. switchAudioModeForHeadphones(): void;
  93293. /**
  93294. * Switch audio to normal speakers.
  93295. */
  93296. switchAudioModeForNormalSpeakers(): void;
  93297. private _afterRender;
  93298. }
  93299. }
  93300. declare module BABYLON {
  93301. /**
  93302. * Wraps one or more Sound objects and selects one with random weight for playback.
  93303. */
  93304. export class WeightedSound {
  93305. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93306. loop: boolean;
  93307. private _coneInnerAngle;
  93308. private _coneOuterAngle;
  93309. private _volume;
  93310. /** A Sound is currently playing. */
  93311. isPlaying: boolean;
  93312. /** A Sound is currently paused. */
  93313. isPaused: boolean;
  93314. private _sounds;
  93315. private _weights;
  93316. private _currentIndex?;
  93317. /**
  93318. * Creates a new WeightedSound from the list of sounds given.
  93319. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93320. * @param sounds Array of Sounds that will be selected from.
  93321. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93322. */
  93323. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93324. /**
  93325. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93326. */
  93327. /**
  93328. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93329. */
  93330. directionalConeInnerAngle: number;
  93331. /**
  93332. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93333. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93334. */
  93335. /**
  93336. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93337. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93338. */
  93339. directionalConeOuterAngle: number;
  93340. /**
  93341. * Playback volume.
  93342. */
  93343. /**
  93344. * Playback volume.
  93345. */
  93346. volume: number;
  93347. private _onended;
  93348. /**
  93349. * Suspend playback
  93350. */
  93351. pause(): void;
  93352. /**
  93353. * Stop playback
  93354. */
  93355. stop(): void;
  93356. /**
  93357. * Start playback.
  93358. * @param startOffset Position the clip head at a specific time in seconds.
  93359. */
  93360. play(startOffset?: number): void;
  93361. }
  93362. }
  93363. declare module BABYLON {
  93364. /**
  93365. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93367. */
  93368. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93369. /**
  93370. * Gets the name of the behavior.
  93371. */
  93372. readonly name: string;
  93373. /**
  93374. * The easing function used by animations
  93375. */
  93376. static EasingFunction: BackEase;
  93377. /**
  93378. * The easing mode used by animations
  93379. */
  93380. static EasingMode: number;
  93381. /**
  93382. * The duration of the animation, in milliseconds
  93383. */
  93384. transitionDuration: number;
  93385. /**
  93386. * Length of the distance animated by the transition when lower radius is reached
  93387. */
  93388. lowerRadiusTransitionRange: number;
  93389. /**
  93390. * Length of the distance animated by the transition when upper radius is reached
  93391. */
  93392. upperRadiusTransitionRange: number;
  93393. private _autoTransitionRange;
  93394. /**
  93395. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93396. */
  93397. /**
  93398. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93399. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93400. */
  93401. autoTransitionRange: boolean;
  93402. private _attachedCamera;
  93403. private _onAfterCheckInputsObserver;
  93404. private _onMeshTargetChangedObserver;
  93405. /**
  93406. * Initializes the behavior.
  93407. */
  93408. init(): void;
  93409. /**
  93410. * Attaches the behavior to its arc rotate camera.
  93411. * @param camera Defines the camera to attach the behavior to
  93412. */
  93413. attach(camera: ArcRotateCamera): void;
  93414. /**
  93415. * Detaches the behavior from its current arc rotate camera.
  93416. */
  93417. detach(): void;
  93418. private _radiusIsAnimating;
  93419. private _radiusBounceTransition;
  93420. private _animatables;
  93421. private _cachedWheelPrecision;
  93422. /**
  93423. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93424. * @param radiusLimit The limit to check against.
  93425. * @return Bool to indicate if at limit.
  93426. */
  93427. private _isRadiusAtLimit;
  93428. /**
  93429. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93430. * @param radiusDelta The delta by which to animate to. Can be negative.
  93431. */
  93432. private _applyBoundRadiusAnimation;
  93433. /**
  93434. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93435. */
  93436. protected _clearAnimationLocks(): void;
  93437. /**
  93438. * Stops and removes all animations that have been applied to the camera
  93439. */
  93440. stopAllAnimations(): void;
  93441. }
  93442. }
  93443. declare module BABYLON {
  93444. /**
  93445. * 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.
  93446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93447. */
  93448. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93449. /**
  93450. * Gets the name of the behavior.
  93451. */
  93452. readonly name: string;
  93453. private _mode;
  93454. private _radiusScale;
  93455. private _positionScale;
  93456. private _defaultElevation;
  93457. private _elevationReturnTime;
  93458. private _elevationReturnWaitTime;
  93459. private _zoomStopsAnimation;
  93460. private _framingTime;
  93461. /**
  93462. * The easing function used by animations
  93463. */
  93464. static EasingFunction: ExponentialEase;
  93465. /**
  93466. * The easing mode used by animations
  93467. */
  93468. static EasingMode: number;
  93469. /**
  93470. * Sets the current mode used by the behavior
  93471. */
  93472. /**
  93473. * Gets current mode used by the behavior.
  93474. */
  93475. mode: number;
  93476. /**
  93477. * Sets the scale applied to the radius (1 by default)
  93478. */
  93479. /**
  93480. * Gets the scale applied to the radius
  93481. */
  93482. radiusScale: number;
  93483. /**
  93484. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93485. */
  93486. /**
  93487. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93488. */
  93489. positionScale: number;
  93490. /**
  93491. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93492. * behaviour is triggered, in radians.
  93493. */
  93494. /**
  93495. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93496. * behaviour is triggered, in radians.
  93497. */
  93498. defaultElevation: number;
  93499. /**
  93500. * Sets the time (in milliseconds) taken to return to the default beta position.
  93501. * Negative value indicates camera should not return to default.
  93502. */
  93503. /**
  93504. * Gets the time (in milliseconds) taken to return to the default beta position.
  93505. * Negative value indicates camera should not return to default.
  93506. */
  93507. elevationReturnTime: number;
  93508. /**
  93509. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93510. */
  93511. /**
  93512. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93513. */
  93514. elevationReturnWaitTime: number;
  93515. /**
  93516. * Sets the flag that indicates if user zooming should stop animation.
  93517. */
  93518. /**
  93519. * Gets the flag that indicates if user zooming should stop animation.
  93520. */
  93521. zoomStopsAnimation: boolean;
  93522. /**
  93523. * Sets the transition time when framing the mesh, in milliseconds
  93524. */
  93525. /**
  93526. * Gets the transition time when framing the mesh, in milliseconds
  93527. */
  93528. framingTime: number;
  93529. /**
  93530. * Define if the behavior should automatically change the configured
  93531. * camera limits and sensibilities.
  93532. */
  93533. autoCorrectCameraLimitsAndSensibility: boolean;
  93534. private _onPrePointerObservableObserver;
  93535. private _onAfterCheckInputsObserver;
  93536. private _onMeshTargetChangedObserver;
  93537. private _attachedCamera;
  93538. private _isPointerDown;
  93539. private _lastInteractionTime;
  93540. /**
  93541. * Initializes the behavior.
  93542. */
  93543. init(): void;
  93544. /**
  93545. * Attaches the behavior to its arc rotate camera.
  93546. * @param camera Defines the camera to attach the behavior to
  93547. */
  93548. attach(camera: ArcRotateCamera): void;
  93549. /**
  93550. * Detaches the behavior from its current arc rotate camera.
  93551. */
  93552. detach(): void;
  93553. private _animatables;
  93554. private _betaIsAnimating;
  93555. private _betaTransition;
  93556. private _radiusTransition;
  93557. private _vectorTransition;
  93558. /**
  93559. * Targets the given mesh and updates zoom level accordingly.
  93560. * @param mesh The mesh to target.
  93561. * @param radius Optional. If a cached radius position already exists, overrides default.
  93562. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93563. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93564. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93565. */
  93566. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93567. /**
  93568. * Targets the given mesh with its children and updates zoom level accordingly.
  93569. * @param mesh The mesh to target.
  93570. * @param radius Optional. If a cached radius position already exists, overrides default.
  93571. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93572. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93573. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93574. */
  93575. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93576. /**
  93577. * Targets the given meshes with their children and updates zoom level accordingly.
  93578. * @param meshes The mesh to target.
  93579. * @param radius Optional. If a cached radius position already exists, overrides default.
  93580. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93581. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93582. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93583. */
  93584. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93585. /**
  93586. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93587. * @param minimumWorld Determines the smaller position of the bounding box extend
  93588. * @param maximumWorld Determines the bigger position of the bounding box extend
  93589. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93590. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93591. */
  93592. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93593. /**
  93594. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93595. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93596. * frustum width.
  93597. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93598. * to fully enclose the mesh in the viewing frustum.
  93599. */
  93600. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93601. /**
  93602. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93603. * is automatically returned to its default position (expected to be above ground plane).
  93604. */
  93605. private _maintainCameraAboveGround;
  93606. /**
  93607. * Returns the frustum slope based on the canvas ratio and camera FOV
  93608. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93609. */
  93610. private _getFrustumSlope;
  93611. /**
  93612. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93613. */
  93614. private _clearAnimationLocks;
  93615. /**
  93616. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93617. */
  93618. private _applyUserInteraction;
  93619. /**
  93620. * Stops and removes all animations that have been applied to the camera
  93621. */
  93622. stopAllAnimations(): void;
  93623. /**
  93624. * Gets a value indicating if the user is moving the camera
  93625. */
  93626. readonly isUserIsMoving: boolean;
  93627. /**
  93628. * The camera can move all the way towards the mesh.
  93629. */
  93630. static IgnoreBoundsSizeMode: number;
  93631. /**
  93632. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93633. */
  93634. static FitFrustumSidesMode: number;
  93635. }
  93636. }
  93637. declare module BABYLON {
  93638. /**
  93639. * Base class for Camera Pointer Inputs.
  93640. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93641. * for example usage.
  93642. */
  93643. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93644. /**
  93645. * Defines the camera the input is attached to.
  93646. */
  93647. abstract camera: Camera;
  93648. /**
  93649. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93650. */
  93651. protected _altKey: boolean;
  93652. protected _ctrlKey: boolean;
  93653. protected _metaKey: boolean;
  93654. protected _shiftKey: boolean;
  93655. /**
  93656. * Which mouse buttons were pressed at time of last mouse event.
  93657. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93658. */
  93659. protected _buttonsPressed: number;
  93660. /**
  93661. * Defines the buttons associated with the input to handle camera move.
  93662. */
  93663. buttons: number[];
  93664. /**
  93665. * Attach the input controls to a specific dom element to get the input from.
  93666. * @param element Defines the element the controls should be listened from
  93667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93668. */
  93669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93670. /**
  93671. * Detach the current controls from the specified dom element.
  93672. * @param element Defines the element to stop listening the inputs from
  93673. */
  93674. detachControl(element: Nullable<HTMLElement>): void;
  93675. /**
  93676. * Gets the class name of the current input.
  93677. * @returns the class name
  93678. */
  93679. getClassName(): string;
  93680. /**
  93681. * Get the friendly name associated with the input class.
  93682. * @returns the input friendly name
  93683. */
  93684. getSimpleName(): string;
  93685. /**
  93686. * Called on pointer POINTERDOUBLETAP event.
  93687. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93688. */
  93689. protected onDoubleTap(type: string): void;
  93690. /**
  93691. * Called on pointer POINTERMOVE event if only a single touch is active.
  93692. * Override this method to provide functionality.
  93693. */
  93694. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93695. /**
  93696. * Called on pointer POINTERMOVE event if multiple touches are active.
  93697. * Override this method to provide functionality.
  93698. */
  93699. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93700. /**
  93701. * Called on JS contextmenu event.
  93702. * Override this method to provide functionality.
  93703. */
  93704. protected onContextMenu(evt: PointerEvent): void;
  93705. /**
  93706. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93707. * press.
  93708. * Override this method to provide functionality.
  93709. */
  93710. protected onButtonDown(evt: PointerEvent): void;
  93711. /**
  93712. * Called each time a new POINTERUP event occurs. Ie, for each button
  93713. * release.
  93714. * Override this method to provide functionality.
  93715. */
  93716. protected onButtonUp(evt: PointerEvent): void;
  93717. /**
  93718. * Called when window becomes inactive.
  93719. * Override this method to provide functionality.
  93720. */
  93721. protected onLostFocus(): void;
  93722. private _pointerInput;
  93723. private _observer;
  93724. private _onLostFocus;
  93725. private pointA;
  93726. private pointB;
  93727. }
  93728. }
  93729. declare module BABYLON {
  93730. /**
  93731. * Manage the pointers inputs to control an arc rotate camera.
  93732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93733. */
  93734. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93735. /**
  93736. * Defines the camera the input is attached to.
  93737. */
  93738. camera: ArcRotateCamera;
  93739. /**
  93740. * Gets the class name of the current input.
  93741. * @returns the class name
  93742. */
  93743. getClassName(): string;
  93744. /**
  93745. * Defines the buttons associated with the input to handle camera move.
  93746. */
  93747. buttons: number[];
  93748. /**
  93749. * Defines the pointer angular sensibility along the X axis or how fast is
  93750. * the camera rotating.
  93751. */
  93752. angularSensibilityX: number;
  93753. /**
  93754. * Defines the pointer angular sensibility along the Y axis or how fast is
  93755. * the camera rotating.
  93756. */
  93757. angularSensibilityY: number;
  93758. /**
  93759. * Defines the pointer pinch precision or how fast is the camera zooming.
  93760. */
  93761. pinchPrecision: number;
  93762. /**
  93763. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93764. * from 0.
  93765. * It defines the percentage of current camera.radius to use as delta when
  93766. * pinch zoom is used.
  93767. */
  93768. pinchDeltaPercentage: number;
  93769. /**
  93770. * Defines the pointer panning sensibility or how fast is the camera moving.
  93771. */
  93772. panningSensibility: number;
  93773. /**
  93774. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93775. */
  93776. multiTouchPanning: boolean;
  93777. /**
  93778. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  93779. * zoom (pinch) through multitouch.
  93780. */
  93781. multiTouchPanAndZoom: boolean;
  93782. /**
  93783. * Revers pinch action direction.
  93784. */
  93785. pinchInwards: boolean;
  93786. private _isPanClick;
  93787. private _twoFingerActivityCount;
  93788. private _isPinching;
  93789. /**
  93790. * Called on pointer POINTERMOVE event if only a single touch is active.
  93791. */
  93792. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93793. /**
  93794. * Called on pointer POINTERDOUBLETAP event.
  93795. */
  93796. protected onDoubleTap(type: string): void;
  93797. /**
  93798. * Called on pointer POINTERMOVE event if multiple touches are active.
  93799. */
  93800. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93801. /**
  93802. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93803. * press.
  93804. */
  93805. protected onButtonDown(evt: PointerEvent): void;
  93806. /**
  93807. * Called each time a new POINTERUP event occurs. Ie, for each button
  93808. * release.
  93809. */
  93810. protected onButtonUp(evt: PointerEvent): void;
  93811. /**
  93812. * Called when window becomes inactive.
  93813. */
  93814. protected onLostFocus(): void;
  93815. }
  93816. }
  93817. declare module BABYLON {
  93818. /**
  93819. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93821. */
  93822. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93823. /**
  93824. * Defines the camera the input is attached to.
  93825. */
  93826. camera: ArcRotateCamera;
  93827. /**
  93828. * Defines the list of key codes associated with the up action (increase alpha)
  93829. */
  93830. keysUp: number[];
  93831. /**
  93832. * Defines the list of key codes associated with the down action (decrease alpha)
  93833. */
  93834. keysDown: number[];
  93835. /**
  93836. * Defines the list of key codes associated with the left action (increase beta)
  93837. */
  93838. keysLeft: number[];
  93839. /**
  93840. * Defines the list of key codes associated with the right action (decrease beta)
  93841. */
  93842. keysRight: number[];
  93843. /**
  93844. * Defines the list of key codes associated with the reset action.
  93845. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93846. */
  93847. keysReset: number[];
  93848. /**
  93849. * Defines the panning sensibility of the inputs.
  93850. * (How fast is the camera paning)
  93851. */
  93852. panningSensibility: number;
  93853. /**
  93854. * Defines the zooming sensibility of the inputs.
  93855. * (How fast is the camera zooming)
  93856. */
  93857. zoomingSensibility: number;
  93858. /**
  93859. * Defines wether maintaining the alt key down switch the movement mode from
  93860. * orientation to zoom.
  93861. */
  93862. useAltToZoom: boolean;
  93863. /**
  93864. * Rotation speed of the camera
  93865. */
  93866. angularSpeed: number;
  93867. private _keys;
  93868. private _ctrlPressed;
  93869. private _altPressed;
  93870. private _onCanvasBlurObserver;
  93871. private _onKeyboardObserver;
  93872. private _engine;
  93873. private _scene;
  93874. /**
  93875. * Attach the input controls to a specific dom element to get the input from.
  93876. * @param element Defines the element the controls should be listened from
  93877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93878. */
  93879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93880. /**
  93881. * Detach the current controls from the specified dom element.
  93882. * @param element Defines the element to stop listening the inputs from
  93883. */
  93884. detachControl(element: Nullable<HTMLElement>): void;
  93885. /**
  93886. * Update the current camera state depending on the inputs that have been used this frame.
  93887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93888. */
  93889. checkInputs(): void;
  93890. /**
  93891. * Gets the class name of the current intput.
  93892. * @returns the class name
  93893. */
  93894. getClassName(): string;
  93895. /**
  93896. * Get the friendly name associated with the input class.
  93897. * @returns the input friendly name
  93898. */
  93899. getSimpleName(): string;
  93900. }
  93901. }
  93902. declare module BABYLON {
  93903. /**
  93904. * Manage the mouse wheel inputs to control an arc rotate camera.
  93905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93906. */
  93907. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93908. /**
  93909. * Defines the camera the input is attached to.
  93910. */
  93911. camera: ArcRotateCamera;
  93912. /**
  93913. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93914. */
  93915. wheelPrecision: number;
  93916. /**
  93917. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93918. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93919. */
  93920. wheelDeltaPercentage: number;
  93921. private _wheel;
  93922. private _observer;
  93923. /**
  93924. * Attach the input controls to a specific dom element to get the input from.
  93925. * @param element Defines the element the controls should be listened from
  93926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93927. */
  93928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93929. /**
  93930. * Detach the current controls from the specified dom element.
  93931. * @param element Defines the element to stop listening the inputs from
  93932. */
  93933. detachControl(element: Nullable<HTMLElement>): void;
  93934. /**
  93935. * Gets the class name of the current intput.
  93936. * @returns the class name
  93937. */
  93938. getClassName(): string;
  93939. /**
  93940. * Get the friendly name associated with the input class.
  93941. * @returns the input friendly name
  93942. */
  93943. getSimpleName(): string;
  93944. }
  93945. }
  93946. declare module BABYLON {
  93947. /**
  93948. * Default Inputs manager for the ArcRotateCamera.
  93949. * It groups all the default supported inputs for ease of use.
  93950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93951. */
  93952. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93953. /**
  93954. * Instantiates a new ArcRotateCameraInputsManager.
  93955. * @param camera Defines the camera the inputs belong to
  93956. */
  93957. constructor(camera: ArcRotateCamera);
  93958. /**
  93959. * Add mouse wheel input support to the input manager.
  93960. * @returns the current input manager
  93961. */
  93962. addMouseWheel(): ArcRotateCameraInputsManager;
  93963. /**
  93964. * Add pointers input support to the input manager.
  93965. * @returns the current input manager
  93966. */
  93967. addPointers(): ArcRotateCameraInputsManager;
  93968. /**
  93969. * Add keyboard input support to the input manager.
  93970. * @returns the current input manager
  93971. */
  93972. addKeyboard(): ArcRotateCameraInputsManager;
  93973. }
  93974. }
  93975. declare module BABYLON {
  93976. /**
  93977. * This represents an orbital type of camera.
  93978. *
  93979. * 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.
  93980. * 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.
  93981. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93982. */
  93983. export class ArcRotateCamera extends TargetCamera {
  93984. /**
  93985. * Defines the rotation angle of the camera along the longitudinal axis.
  93986. */
  93987. alpha: number;
  93988. /**
  93989. * Defines the rotation angle of the camera along the latitudinal axis.
  93990. */
  93991. beta: number;
  93992. /**
  93993. * Defines the radius of the camera from it s target point.
  93994. */
  93995. radius: number;
  93996. protected _target: Vector3;
  93997. protected _targetHost: Nullable<AbstractMesh>;
  93998. /**
  93999. * Defines the target point of the camera.
  94000. * The camera looks towards it form the radius distance.
  94001. */
  94002. target: Vector3;
  94003. /**
  94004. * Define the current local position of the camera in the scene
  94005. */
  94006. position: Vector3;
  94007. /**
  94008. * Current inertia value on the longitudinal axis.
  94009. * The bigger this number the longer it will take for the camera to stop.
  94010. */
  94011. inertialAlphaOffset: number;
  94012. /**
  94013. * Current inertia value on the latitudinal axis.
  94014. * The bigger this number the longer it will take for the camera to stop.
  94015. */
  94016. inertialBetaOffset: number;
  94017. /**
  94018. * Current inertia value on the radius axis.
  94019. * The bigger this number the longer it will take for the camera to stop.
  94020. */
  94021. inertialRadiusOffset: number;
  94022. /**
  94023. * Minimum allowed angle on the longitudinal axis.
  94024. * This can help limiting how the Camera is able to move in the scene.
  94025. */
  94026. lowerAlphaLimit: Nullable<number>;
  94027. /**
  94028. * Maximum allowed angle on the longitudinal axis.
  94029. * This can help limiting how the Camera is able to move in the scene.
  94030. */
  94031. upperAlphaLimit: Nullable<number>;
  94032. /**
  94033. * Minimum allowed angle on the latitudinal axis.
  94034. * This can help limiting how the Camera is able to move in the scene.
  94035. */
  94036. lowerBetaLimit: number;
  94037. /**
  94038. * Maximum allowed angle on the latitudinal axis.
  94039. * This can help limiting how the Camera is able to move in the scene.
  94040. */
  94041. upperBetaLimit: number;
  94042. /**
  94043. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94044. * This can help limiting how the Camera is able to move in the scene.
  94045. */
  94046. lowerRadiusLimit: Nullable<number>;
  94047. /**
  94048. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94049. * This can help limiting how the Camera is able to move in the scene.
  94050. */
  94051. upperRadiusLimit: Nullable<number>;
  94052. /**
  94053. * Defines the current inertia value used during panning of the camera along the X axis.
  94054. */
  94055. inertialPanningX: number;
  94056. /**
  94057. * Defines the current inertia value used during panning of the camera along the Y axis.
  94058. */
  94059. inertialPanningY: number;
  94060. /**
  94061. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94062. * Basically if your fingers moves away from more than this distance you will be considered
  94063. * in pinch mode.
  94064. */
  94065. pinchToPanMaxDistance: number;
  94066. /**
  94067. * Defines the maximum distance the camera can pan.
  94068. * This could help keeping the cammera always in your scene.
  94069. */
  94070. panningDistanceLimit: Nullable<number>;
  94071. /**
  94072. * Defines the target of the camera before paning.
  94073. */
  94074. panningOriginTarget: Vector3;
  94075. /**
  94076. * Defines the value of the inertia used during panning.
  94077. * 0 would mean stop inertia and one would mean no decelleration at all.
  94078. */
  94079. panningInertia: number;
  94080. /**
  94081. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94082. */
  94083. angularSensibilityX: number;
  94084. /**
  94085. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94086. */
  94087. angularSensibilityY: number;
  94088. /**
  94089. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94090. */
  94091. pinchPrecision: number;
  94092. /**
  94093. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94094. * It will be used instead of pinchDeltaPrecision if different from 0.
  94095. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94096. */
  94097. pinchDeltaPercentage: number;
  94098. /**
  94099. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94100. */
  94101. panningSensibility: number;
  94102. /**
  94103. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94104. */
  94105. keysUp: number[];
  94106. /**
  94107. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94108. */
  94109. keysDown: number[];
  94110. /**
  94111. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94112. */
  94113. keysLeft: number[];
  94114. /**
  94115. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94116. */
  94117. keysRight: number[];
  94118. /**
  94119. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94120. */
  94121. wheelPrecision: number;
  94122. /**
  94123. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94124. * It will be used instead of pinchDeltaPrecision if different from 0.
  94125. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94126. */
  94127. wheelDeltaPercentage: number;
  94128. /**
  94129. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94130. */
  94131. zoomOnFactor: number;
  94132. /**
  94133. * Defines a screen offset for the camera position.
  94134. */
  94135. targetScreenOffset: Vector2;
  94136. /**
  94137. * Allows the camera to be completely reversed.
  94138. * If false the camera can not arrive upside down.
  94139. */
  94140. allowUpsideDown: boolean;
  94141. /**
  94142. * Define if double tap/click is used to restore the previously saved state of the camera.
  94143. */
  94144. useInputToRestoreState: boolean;
  94145. /** @hidden */
  94146. _viewMatrix: Matrix;
  94147. /** @hidden */
  94148. _useCtrlForPanning: boolean;
  94149. /** @hidden */
  94150. _panningMouseButton: number;
  94151. /**
  94152. * Defines the input associated to the camera.
  94153. */
  94154. inputs: ArcRotateCameraInputsManager;
  94155. /** @hidden */
  94156. _reset: () => void;
  94157. /**
  94158. * Defines the allowed panning axis.
  94159. */
  94160. panningAxis: Vector3;
  94161. protected _localDirection: Vector3;
  94162. protected _transformedDirection: Vector3;
  94163. private _bouncingBehavior;
  94164. /**
  94165. * Gets the bouncing behavior of the camera if it has been enabled.
  94166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94167. */
  94168. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94169. /**
  94170. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94171. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94172. */
  94173. useBouncingBehavior: boolean;
  94174. private _framingBehavior;
  94175. /**
  94176. * Gets the framing behavior of the camera if it has been enabled.
  94177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94178. */
  94179. readonly framingBehavior: Nullable<FramingBehavior>;
  94180. /**
  94181. * Defines if the framing behavior of the camera is enabled on the camera.
  94182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94183. */
  94184. useFramingBehavior: boolean;
  94185. private _autoRotationBehavior;
  94186. /**
  94187. * Gets the auto rotation behavior of the camera if it has been enabled.
  94188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94189. */
  94190. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94191. /**
  94192. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94193. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94194. */
  94195. useAutoRotationBehavior: boolean;
  94196. /**
  94197. * Observable triggered when the mesh target has been changed on the camera.
  94198. */
  94199. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94200. /**
  94201. * Event raised when the camera is colliding with a mesh.
  94202. */
  94203. onCollide: (collidedMesh: AbstractMesh) => void;
  94204. /**
  94205. * Defines whether the camera should check collision with the objects oh the scene.
  94206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94207. */
  94208. checkCollisions: boolean;
  94209. /**
  94210. * Defines the collision radius of the camera.
  94211. * This simulates a sphere around the camera.
  94212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94213. */
  94214. collisionRadius: Vector3;
  94215. protected _collider: Collider;
  94216. protected _previousPosition: Vector3;
  94217. protected _collisionVelocity: Vector3;
  94218. protected _newPosition: Vector3;
  94219. protected _previousAlpha: number;
  94220. protected _previousBeta: number;
  94221. protected _previousRadius: number;
  94222. protected _collisionTriggered: boolean;
  94223. protected _targetBoundingCenter: Nullable<Vector3>;
  94224. private _computationVector;
  94225. private _tempAxisVector;
  94226. private _tempAxisRotationMatrix;
  94227. /**
  94228. * Instantiates a new ArcRotateCamera in a given scene
  94229. * @param name Defines the name of the camera
  94230. * @param alpha Defines the camera rotation along the logitudinal axis
  94231. * @param beta Defines the camera rotation along the latitudinal axis
  94232. * @param radius Defines the camera distance from its target
  94233. * @param target Defines the camera target
  94234. * @param scene Defines the scene the camera belongs to
  94235. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94236. */
  94237. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94238. /** @hidden */
  94239. _initCache(): void;
  94240. /** @hidden */
  94241. _updateCache(ignoreParentClass?: boolean): void;
  94242. protected _getTargetPosition(): Vector3;
  94243. private _storedAlpha;
  94244. private _storedBeta;
  94245. private _storedRadius;
  94246. private _storedTarget;
  94247. /**
  94248. * Stores the current state of the camera (alpha, beta, radius and target)
  94249. * @returns the camera itself
  94250. */
  94251. storeState(): Camera;
  94252. /**
  94253. * @hidden
  94254. * Restored camera state. You must call storeState() first
  94255. */
  94256. _restoreStateValues(): boolean;
  94257. /** @hidden */
  94258. _isSynchronizedViewMatrix(): boolean;
  94259. /**
  94260. * Attached controls to the current camera.
  94261. * @param element Defines the element the controls should be listened from
  94262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94263. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94264. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94265. */
  94266. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94267. /**
  94268. * Detach the current controls from the camera.
  94269. * The camera will stop reacting to inputs.
  94270. * @param element Defines the element to stop listening the inputs from
  94271. */
  94272. detachControl(element: HTMLElement): void;
  94273. /** @hidden */
  94274. _checkInputs(): void;
  94275. protected _checkLimits(): void;
  94276. /**
  94277. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94278. */
  94279. rebuildAnglesAndRadius(): void;
  94280. /**
  94281. * Use a position to define the current camera related information like aplha, beta and radius
  94282. * @param position Defines the position to set the camera at
  94283. */
  94284. setPosition(position: Vector3): void;
  94285. /**
  94286. * Defines the target the camera should look at.
  94287. * This will automatically adapt alpha beta and radius to fit within the new target.
  94288. * @param target Defines the new target as a Vector or a mesh
  94289. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94290. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94291. */
  94292. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94293. /** @hidden */
  94294. _getViewMatrix(): Matrix;
  94295. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94296. /**
  94297. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94298. * @param meshes Defines the mesh to zoom on
  94299. * @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)
  94300. */
  94301. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94302. /**
  94303. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94304. * The target will be changed but the radius
  94305. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94306. * @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)
  94307. */
  94308. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94309. min: Vector3;
  94310. max: Vector3;
  94311. distance: number;
  94312. }, doNotUpdateMaxZ?: boolean): void;
  94313. /**
  94314. * @override
  94315. * Override Camera.createRigCamera
  94316. */
  94317. createRigCamera(name: string, cameraIndex: number): Camera;
  94318. /**
  94319. * @hidden
  94320. * @override
  94321. * Override Camera._updateRigCameras
  94322. */
  94323. _updateRigCameras(): void;
  94324. /**
  94325. * Destroy the camera and release the current resources hold by it.
  94326. */
  94327. dispose(): void;
  94328. /**
  94329. * Gets the current object class name.
  94330. * @return the class name
  94331. */
  94332. getClassName(): string;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94339. */
  94340. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94341. /**
  94342. * Gets the name of the behavior.
  94343. */
  94344. readonly name: string;
  94345. private _zoomStopsAnimation;
  94346. private _idleRotationSpeed;
  94347. private _idleRotationWaitTime;
  94348. private _idleRotationSpinupTime;
  94349. /**
  94350. * Sets the flag that indicates if user zooming should stop animation.
  94351. */
  94352. /**
  94353. * Gets the flag that indicates if user zooming should stop animation.
  94354. */
  94355. zoomStopsAnimation: boolean;
  94356. /**
  94357. * Sets the default speed at which the camera rotates around the model.
  94358. */
  94359. /**
  94360. * Gets the default speed at which the camera rotates around the model.
  94361. */
  94362. idleRotationSpeed: number;
  94363. /**
  94364. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94365. */
  94366. /**
  94367. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94368. */
  94369. idleRotationWaitTime: number;
  94370. /**
  94371. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94372. */
  94373. /**
  94374. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94375. */
  94376. idleRotationSpinupTime: number;
  94377. /**
  94378. * Gets a value indicating if the camera is currently rotating because of this behavior
  94379. */
  94380. readonly rotationInProgress: boolean;
  94381. private _onPrePointerObservableObserver;
  94382. private _onAfterCheckInputsObserver;
  94383. private _attachedCamera;
  94384. private _isPointerDown;
  94385. private _lastFrameTime;
  94386. private _lastInteractionTime;
  94387. private _cameraRotationSpeed;
  94388. /**
  94389. * Initializes the behavior.
  94390. */
  94391. init(): void;
  94392. /**
  94393. * Attaches the behavior to its arc rotate camera.
  94394. * @param camera Defines the camera to attach the behavior to
  94395. */
  94396. attach(camera: ArcRotateCamera): void;
  94397. /**
  94398. * Detaches the behavior from its current arc rotate camera.
  94399. */
  94400. detach(): void;
  94401. /**
  94402. * Returns true if user is scrolling.
  94403. * @return true if user is scrolling.
  94404. */
  94405. private _userIsZooming;
  94406. private _lastFrameRadius;
  94407. private _shouldAnimationStopForInteraction;
  94408. /**
  94409. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94410. */
  94411. private _applyUserInteraction;
  94412. private _userIsMoving;
  94413. }
  94414. }
  94415. declare module BABYLON {
  94416. /**
  94417. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94418. */
  94419. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94420. private ui;
  94421. /**
  94422. * The name of the behavior
  94423. */
  94424. name: string;
  94425. /**
  94426. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94427. */
  94428. distanceAwayFromFace: number;
  94429. /**
  94430. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94431. */
  94432. distanceAwayFromBottomOfFace: number;
  94433. private _faceVectors;
  94434. private _target;
  94435. private _scene;
  94436. private _onRenderObserver;
  94437. private _tmpMatrix;
  94438. private _tmpVector;
  94439. /**
  94440. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94441. * @param ui The transform node that should be attched to the mesh
  94442. */
  94443. constructor(ui: TransformNode);
  94444. /**
  94445. * Initializes the behavior
  94446. */
  94447. init(): void;
  94448. private _closestFace;
  94449. private _zeroVector;
  94450. private _lookAtTmpMatrix;
  94451. private _lookAtToRef;
  94452. /**
  94453. * Attaches the AttachToBoxBehavior to the passed in mesh
  94454. * @param target The mesh that the specified node will be attached to
  94455. */
  94456. attach(target: Mesh): void;
  94457. /**
  94458. * Detaches the behavior from the mesh
  94459. */
  94460. detach(): void;
  94461. }
  94462. }
  94463. declare module BABYLON {
  94464. /**
  94465. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94466. */
  94467. export class FadeInOutBehavior implements Behavior<Mesh> {
  94468. /**
  94469. * Time in milliseconds to delay before fading in (Default: 0)
  94470. */
  94471. delay: number;
  94472. /**
  94473. * Time in milliseconds for the mesh to fade in (Default: 300)
  94474. */
  94475. fadeInTime: number;
  94476. private _millisecondsPerFrame;
  94477. private _hovered;
  94478. private _hoverValue;
  94479. private _ownerNode;
  94480. /**
  94481. * Instatiates the FadeInOutBehavior
  94482. */
  94483. constructor();
  94484. /**
  94485. * The name of the behavior
  94486. */
  94487. readonly name: string;
  94488. /**
  94489. * Initializes the behavior
  94490. */
  94491. init(): void;
  94492. /**
  94493. * Attaches the fade behavior on the passed in mesh
  94494. * @param ownerNode The mesh that will be faded in/out once attached
  94495. */
  94496. attach(ownerNode: Mesh): void;
  94497. /**
  94498. * Detaches the behavior from the mesh
  94499. */
  94500. detach(): void;
  94501. /**
  94502. * Triggers the mesh to begin fading in or out
  94503. * @param value if the object should fade in or out (true to fade in)
  94504. */
  94505. fadeIn(value: boolean): void;
  94506. private _update;
  94507. private _setAllVisibility;
  94508. }
  94509. }
  94510. declare module BABYLON {
  94511. /**
  94512. * Class containing a set of static utilities functions for managing Pivots
  94513. * @hidden
  94514. */
  94515. export class PivotTools {
  94516. private static _PivotCached;
  94517. private static _OldPivotPoint;
  94518. private static _PivotTranslation;
  94519. private static _PivotTmpVector;
  94520. /** @hidden */
  94521. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94522. /** @hidden */
  94523. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94524. }
  94525. }
  94526. declare module BABYLON {
  94527. /**
  94528. * Class containing static functions to help procedurally build meshes
  94529. */
  94530. export class PlaneBuilder {
  94531. /**
  94532. * Creates a plane mesh
  94533. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94534. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94535. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94539. * @param name defines the name of the mesh
  94540. * @param options defines the options used to create the mesh
  94541. * @param scene defines the hosting scene
  94542. * @returns the plane mesh
  94543. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94544. */
  94545. static CreatePlane(name: string, options: {
  94546. size?: number;
  94547. width?: number;
  94548. height?: number;
  94549. sideOrientation?: number;
  94550. frontUVs?: Vector4;
  94551. backUVs?: Vector4;
  94552. updatable?: boolean;
  94553. sourcePlane?: Plane;
  94554. }, scene: Scene): Mesh;
  94555. }
  94556. }
  94557. declare module BABYLON {
  94558. /**
  94559. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94560. */
  94561. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94562. private static _AnyMouseID;
  94563. private _attachedNode;
  94564. private _dragPlane;
  94565. private _scene;
  94566. private _pointerObserver;
  94567. private _beforeRenderObserver;
  94568. private static _planeScene;
  94569. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94570. /**
  94571. * 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)
  94572. */
  94573. maxDragAngle: number;
  94574. /**
  94575. * @hidden
  94576. */
  94577. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94578. /**
  94579. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94580. */
  94581. currentDraggingPointerID: number;
  94582. /**
  94583. * The last position where the pointer hit the drag plane in world space
  94584. */
  94585. lastDragPosition: Vector3;
  94586. /**
  94587. * If the behavior is currently in a dragging state
  94588. */
  94589. dragging: boolean;
  94590. /**
  94591. * 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)
  94592. */
  94593. dragDeltaRatio: number;
  94594. /**
  94595. * If the drag plane orientation should be updated during the dragging (Default: true)
  94596. */
  94597. updateDragPlane: boolean;
  94598. private _debugMode;
  94599. private _moving;
  94600. /**
  94601. * Fires each time the attached mesh is dragged with the pointer
  94602. * * delta between last drag position and current drag position in world space
  94603. * * dragDistance along the drag axis
  94604. * * dragPlaneNormal normal of the current drag plane used during the drag
  94605. * * dragPlanePoint in world space where the drag intersects the drag plane
  94606. */
  94607. onDragObservable: Observable<{
  94608. delta: Vector3;
  94609. dragPlanePoint: Vector3;
  94610. dragPlaneNormal: Vector3;
  94611. dragDistance: number;
  94612. pointerId: number;
  94613. }>;
  94614. /**
  94615. * Fires each time a drag begins (eg. mouse down on mesh)
  94616. */
  94617. onDragStartObservable: Observable<{
  94618. dragPlanePoint: Vector3;
  94619. pointerId: number;
  94620. }>;
  94621. /**
  94622. * Fires each time a drag ends (eg. mouse release after drag)
  94623. */
  94624. onDragEndObservable: Observable<{
  94625. dragPlanePoint: Vector3;
  94626. pointerId: number;
  94627. }>;
  94628. /**
  94629. * If the attached mesh should be moved when dragged
  94630. */
  94631. moveAttached: boolean;
  94632. /**
  94633. * If the drag behavior will react to drag events (Default: true)
  94634. */
  94635. enabled: boolean;
  94636. /**
  94637. * If camera controls should be detached during the drag
  94638. */
  94639. detachCameraControls: boolean;
  94640. /**
  94641. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94642. */
  94643. useObjectOrienationForDragging: boolean;
  94644. private _options;
  94645. /**
  94646. * Creates a pointer drag behavior that can be attached to a mesh
  94647. * @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)
  94648. */
  94649. constructor(options?: {
  94650. dragAxis?: Vector3;
  94651. dragPlaneNormal?: Vector3;
  94652. });
  94653. /**
  94654. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94655. */
  94656. validateDrag: (targetPosition: Vector3) => boolean;
  94657. /**
  94658. * The name of the behavior
  94659. */
  94660. readonly name: string;
  94661. /**
  94662. * Initializes the behavior
  94663. */
  94664. init(): void;
  94665. private _tmpVector;
  94666. private _alternatePickedPoint;
  94667. private _worldDragAxis;
  94668. private _targetPosition;
  94669. private _attachedElement;
  94670. /**
  94671. * Attaches the drag behavior the passed in mesh
  94672. * @param ownerNode The mesh that will be dragged around once attached
  94673. */
  94674. attach(ownerNode: AbstractMesh): void;
  94675. /**
  94676. * Force relase the drag action by code.
  94677. */
  94678. releaseDrag(): void;
  94679. private _startDragRay;
  94680. private _lastPointerRay;
  94681. /**
  94682. * Simulates the start of a pointer drag event on the behavior
  94683. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94684. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94685. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94686. */
  94687. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94688. private _startDrag;
  94689. private _dragDelta;
  94690. private _moveDrag;
  94691. private _pickWithRayOnDragPlane;
  94692. private _pointA;
  94693. private _pointB;
  94694. private _pointC;
  94695. private _lineA;
  94696. private _lineB;
  94697. private _localAxis;
  94698. private _lookAt;
  94699. private _updateDragPlanePosition;
  94700. /**
  94701. * Detaches the behavior from the mesh
  94702. */
  94703. detach(): void;
  94704. }
  94705. }
  94706. declare module BABYLON {
  94707. /**
  94708. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94709. */
  94710. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94711. private _dragBehaviorA;
  94712. private _dragBehaviorB;
  94713. private _startDistance;
  94714. private _initialScale;
  94715. private _targetScale;
  94716. private _ownerNode;
  94717. private _sceneRenderObserver;
  94718. /**
  94719. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94720. */
  94721. constructor();
  94722. /**
  94723. * The name of the behavior
  94724. */
  94725. readonly name: string;
  94726. /**
  94727. * Initializes the behavior
  94728. */
  94729. init(): void;
  94730. private _getCurrentDistance;
  94731. /**
  94732. * Attaches the scale behavior the passed in mesh
  94733. * @param ownerNode The mesh that will be scaled around once attached
  94734. */
  94735. attach(ownerNode: Mesh): void;
  94736. /**
  94737. * Detaches the behavior from the mesh
  94738. */
  94739. detach(): void;
  94740. }
  94741. }
  94742. declare module BABYLON {
  94743. /**
  94744. * 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
  94745. */
  94746. export class SixDofDragBehavior implements Behavior<Mesh> {
  94747. private static _virtualScene;
  94748. private _ownerNode;
  94749. private _sceneRenderObserver;
  94750. private _scene;
  94751. private _targetPosition;
  94752. private _virtualOriginMesh;
  94753. private _virtualDragMesh;
  94754. private _pointerObserver;
  94755. private _moving;
  94756. private _startingOrientation;
  94757. /**
  94758. * 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)
  94759. */
  94760. private zDragFactor;
  94761. /**
  94762. * If the object should rotate to face the drag origin
  94763. */
  94764. rotateDraggedObject: boolean;
  94765. /**
  94766. * If the behavior is currently in a dragging state
  94767. */
  94768. dragging: boolean;
  94769. /**
  94770. * 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)
  94771. */
  94772. dragDeltaRatio: number;
  94773. /**
  94774. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94775. */
  94776. currentDraggingPointerID: number;
  94777. /**
  94778. * If camera controls should be detached during the drag
  94779. */
  94780. detachCameraControls: boolean;
  94781. /**
  94782. * Fires each time a drag starts
  94783. */
  94784. onDragStartObservable: Observable<{}>;
  94785. /**
  94786. * Fires each time a drag ends (eg. mouse release after drag)
  94787. */
  94788. onDragEndObservable: Observable<{}>;
  94789. /**
  94790. * 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
  94791. */
  94792. constructor();
  94793. /**
  94794. * The name of the behavior
  94795. */
  94796. readonly name: string;
  94797. /**
  94798. * Initializes the behavior
  94799. */
  94800. init(): void;
  94801. /**
  94802. * Attaches the scale behavior the passed in mesh
  94803. * @param ownerNode The mesh that will be scaled around once attached
  94804. */
  94805. attach(ownerNode: Mesh): void;
  94806. /**
  94807. * Detaches the behavior from the mesh
  94808. */
  94809. detach(): void;
  94810. }
  94811. }
  94812. declare module BABYLON {
  94813. /**
  94814. * Class used to apply inverse kinematics to bones
  94815. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94816. */
  94817. export class BoneIKController {
  94818. private static _tmpVecs;
  94819. private static _tmpQuat;
  94820. private static _tmpMats;
  94821. /**
  94822. * Gets or sets the target mesh
  94823. */
  94824. targetMesh: AbstractMesh;
  94825. /** Gets or sets the mesh used as pole */
  94826. poleTargetMesh: AbstractMesh;
  94827. /**
  94828. * Gets or sets the bone used as pole
  94829. */
  94830. poleTargetBone: Nullable<Bone>;
  94831. /**
  94832. * Gets or sets the target position
  94833. */
  94834. targetPosition: Vector3;
  94835. /**
  94836. * Gets or sets the pole target position
  94837. */
  94838. poleTargetPosition: Vector3;
  94839. /**
  94840. * Gets or sets the pole target local offset
  94841. */
  94842. poleTargetLocalOffset: Vector3;
  94843. /**
  94844. * Gets or sets the pole angle
  94845. */
  94846. poleAngle: number;
  94847. /**
  94848. * Gets or sets the mesh associated with the controller
  94849. */
  94850. mesh: AbstractMesh;
  94851. /**
  94852. * 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)
  94853. */
  94854. slerpAmount: number;
  94855. private _bone1Quat;
  94856. private _bone1Mat;
  94857. private _bone2Ang;
  94858. private _bone1;
  94859. private _bone2;
  94860. private _bone1Length;
  94861. private _bone2Length;
  94862. private _maxAngle;
  94863. private _maxReach;
  94864. private _rightHandedSystem;
  94865. private _bendAxis;
  94866. private _slerping;
  94867. private _adjustRoll;
  94868. /**
  94869. * Gets or sets maximum allowed angle
  94870. */
  94871. maxAngle: number;
  94872. /**
  94873. * Creates a new BoneIKController
  94874. * @param mesh defines the mesh to control
  94875. * @param bone defines the bone to control
  94876. * @param options defines options to set up the controller
  94877. */
  94878. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94879. targetMesh?: AbstractMesh;
  94880. poleTargetMesh?: AbstractMesh;
  94881. poleTargetBone?: Bone;
  94882. poleTargetLocalOffset?: Vector3;
  94883. poleAngle?: number;
  94884. bendAxis?: Vector3;
  94885. maxAngle?: number;
  94886. slerpAmount?: number;
  94887. });
  94888. private _setMaxAngle;
  94889. /**
  94890. * Force the controller to update the bones
  94891. */
  94892. update(): void;
  94893. }
  94894. }
  94895. declare module BABYLON {
  94896. /**
  94897. * Class used to make a bone look toward a point in space
  94898. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94899. */
  94900. export class BoneLookController {
  94901. private static _tmpVecs;
  94902. private static _tmpQuat;
  94903. private static _tmpMats;
  94904. /**
  94905. * The target Vector3 that the bone will look at
  94906. */
  94907. target: Vector3;
  94908. /**
  94909. * The mesh that the bone is attached to
  94910. */
  94911. mesh: AbstractMesh;
  94912. /**
  94913. * The bone that will be looking to the target
  94914. */
  94915. bone: Bone;
  94916. /**
  94917. * The up axis of the coordinate system that is used when the bone is rotated
  94918. */
  94919. upAxis: Vector3;
  94920. /**
  94921. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94922. */
  94923. upAxisSpace: Space;
  94924. /**
  94925. * Used to make an adjustment to the yaw of the bone
  94926. */
  94927. adjustYaw: number;
  94928. /**
  94929. * Used to make an adjustment to the pitch of the bone
  94930. */
  94931. adjustPitch: number;
  94932. /**
  94933. * Used to make an adjustment to the roll of the bone
  94934. */
  94935. adjustRoll: number;
  94936. /**
  94937. * 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)
  94938. */
  94939. slerpAmount: number;
  94940. private _minYaw;
  94941. private _maxYaw;
  94942. private _minPitch;
  94943. private _maxPitch;
  94944. private _minYawSin;
  94945. private _minYawCos;
  94946. private _maxYawSin;
  94947. private _maxYawCos;
  94948. private _midYawConstraint;
  94949. private _minPitchTan;
  94950. private _maxPitchTan;
  94951. private _boneQuat;
  94952. private _slerping;
  94953. private _transformYawPitch;
  94954. private _transformYawPitchInv;
  94955. private _firstFrameSkipped;
  94956. private _yawRange;
  94957. private _fowardAxis;
  94958. /**
  94959. * Gets or sets the minimum yaw angle that the bone can look to
  94960. */
  94961. minYaw: number;
  94962. /**
  94963. * Gets or sets the maximum yaw angle that the bone can look to
  94964. */
  94965. maxYaw: number;
  94966. /**
  94967. * Gets or sets the minimum pitch angle that the bone can look to
  94968. */
  94969. minPitch: number;
  94970. /**
  94971. * Gets or sets the maximum pitch angle that the bone can look to
  94972. */
  94973. maxPitch: number;
  94974. /**
  94975. * Create a BoneLookController
  94976. * @param mesh the mesh that the bone belongs to
  94977. * @param bone the bone that will be looking to the target
  94978. * @param target the target Vector3 to look at
  94979. * @param options optional settings:
  94980. * * maxYaw: the maximum angle the bone will yaw to
  94981. * * minYaw: the minimum angle the bone will yaw to
  94982. * * maxPitch: the maximum angle the bone will pitch to
  94983. * * minPitch: the minimum angle the bone will yaw to
  94984. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94985. * * upAxis: the up axis of the coordinate system
  94986. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94987. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94988. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94989. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94990. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94991. * * adjustRoll: used to make an adjustment to the roll of the bone
  94992. **/
  94993. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94994. maxYaw?: number;
  94995. minYaw?: number;
  94996. maxPitch?: number;
  94997. minPitch?: number;
  94998. slerpAmount?: number;
  94999. upAxis?: Vector3;
  95000. upAxisSpace?: Space;
  95001. yawAxis?: Vector3;
  95002. pitchAxis?: Vector3;
  95003. adjustYaw?: number;
  95004. adjustPitch?: number;
  95005. adjustRoll?: number;
  95006. });
  95007. /**
  95008. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95009. */
  95010. update(): void;
  95011. private _getAngleDiff;
  95012. private _getAngleBetween;
  95013. private _isAngleBetween;
  95014. }
  95015. }
  95016. declare module BABYLON {
  95017. /**
  95018. * Manage the gamepad inputs to control an arc rotate camera.
  95019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95020. */
  95021. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95022. /**
  95023. * Defines the camera the input is attached to.
  95024. */
  95025. camera: ArcRotateCamera;
  95026. /**
  95027. * Defines the gamepad the input is gathering event from.
  95028. */
  95029. gamepad: Nullable<Gamepad>;
  95030. /**
  95031. * Defines the gamepad rotation sensiblity.
  95032. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95033. */
  95034. gamepadRotationSensibility: number;
  95035. /**
  95036. * Defines the gamepad move sensiblity.
  95037. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95038. */
  95039. gamepadMoveSensibility: number;
  95040. private _onGamepadConnectedObserver;
  95041. private _onGamepadDisconnectedObserver;
  95042. /**
  95043. * Attach the input controls to a specific dom element to get the input from.
  95044. * @param element Defines the element the controls should be listened from
  95045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95046. */
  95047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95048. /**
  95049. * Detach the current controls from the specified dom element.
  95050. * @param element Defines the element to stop listening the inputs from
  95051. */
  95052. detachControl(element: Nullable<HTMLElement>): void;
  95053. /**
  95054. * Update the current camera state depending on the inputs that have been used this frame.
  95055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95056. */
  95057. checkInputs(): void;
  95058. /**
  95059. * Gets the class name of the current intput.
  95060. * @returns the class name
  95061. */
  95062. getClassName(): string;
  95063. /**
  95064. * Get the friendly name associated with the input class.
  95065. * @returns the input friendly name
  95066. */
  95067. getSimpleName(): string;
  95068. }
  95069. }
  95070. declare module BABYLON {
  95071. interface ArcRotateCameraInputsManager {
  95072. /**
  95073. * Add orientation input support to the input manager.
  95074. * @returns the current input manager
  95075. */
  95076. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95077. }
  95078. /**
  95079. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95081. */
  95082. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95083. /**
  95084. * Defines the camera the input is attached to.
  95085. */
  95086. camera: ArcRotateCamera;
  95087. /**
  95088. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95089. */
  95090. alphaCorrection: number;
  95091. /**
  95092. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95093. */
  95094. gammaCorrection: number;
  95095. private _alpha;
  95096. private _gamma;
  95097. private _dirty;
  95098. private _deviceOrientationHandler;
  95099. /**
  95100. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95101. */
  95102. constructor();
  95103. /**
  95104. * Attach the input controls to a specific dom element to get the input from.
  95105. * @param element Defines the element the controls should be listened from
  95106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95107. */
  95108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95109. /** @hidden */
  95110. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95111. /**
  95112. * Update the current camera state depending on the inputs that have been used this frame.
  95113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95114. */
  95115. checkInputs(): void;
  95116. /**
  95117. * Detach the current controls from the specified dom element.
  95118. * @param element Defines the element to stop listening the inputs from
  95119. */
  95120. detachControl(element: Nullable<HTMLElement>): void;
  95121. /**
  95122. * Gets the class name of the current intput.
  95123. * @returns the class name
  95124. */
  95125. getClassName(): string;
  95126. /**
  95127. * Get the friendly name associated with the input class.
  95128. * @returns the input friendly name
  95129. */
  95130. getSimpleName(): string;
  95131. }
  95132. }
  95133. declare module BABYLON {
  95134. /**
  95135. * Listen to mouse events to control the camera.
  95136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95137. */
  95138. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95139. /**
  95140. * Defines the camera the input is attached to.
  95141. */
  95142. camera: FlyCamera;
  95143. /**
  95144. * Defines if touch is enabled. (Default is true.)
  95145. */
  95146. touchEnabled: boolean;
  95147. /**
  95148. * Defines the buttons associated with the input to handle camera rotation.
  95149. */
  95150. buttons: number[];
  95151. /**
  95152. * Assign buttons for Yaw control.
  95153. */
  95154. buttonsYaw: number[];
  95155. /**
  95156. * Assign buttons for Pitch control.
  95157. */
  95158. buttonsPitch: number[];
  95159. /**
  95160. * Assign buttons for Roll control.
  95161. */
  95162. buttonsRoll: number[];
  95163. /**
  95164. * Detect if any button is being pressed while mouse is moved.
  95165. * -1 = Mouse locked.
  95166. * 0 = Left button.
  95167. * 1 = Middle Button.
  95168. * 2 = Right Button.
  95169. */
  95170. activeButton: number;
  95171. /**
  95172. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95173. * Higher values reduce its sensitivity.
  95174. */
  95175. angularSensibility: number;
  95176. private _mousemoveCallback;
  95177. private _observer;
  95178. private _rollObserver;
  95179. private previousPosition;
  95180. private noPreventDefault;
  95181. private element;
  95182. /**
  95183. * Listen to mouse events to control the camera.
  95184. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95186. */
  95187. constructor(touchEnabled?: boolean);
  95188. /**
  95189. * Attach the mouse control to the HTML DOM element.
  95190. * @param element Defines the element that listens to the input events.
  95191. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95192. */
  95193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95194. /**
  95195. * Detach the current controls from the specified dom element.
  95196. * @param element Defines the element to stop listening the inputs from
  95197. */
  95198. detachControl(element: Nullable<HTMLElement>): void;
  95199. /**
  95200. * Gets the class name of the current input.
  95201. * @returns the class name.
  95202. */
  95203. getClassName(): string;
  95204. /**
  95205. * Get the friendly name associated with the input class.
  95206. * @returns the input's friendly name.
  95207. */
  95208. getSimpleName(): string;
  95209. private _pointerInput;
  95210. private _onMouseMove;
  95211. /**
  95212. * Rotate camera by mouse offset.
  95213. */
  95214. private rotateCamera;
  95215. }
  95216. }
  95217. declare module BABYLON {
  95218. /**
  95219. * Default Inputs manager for the FlyCamera.
  95220. * It groups all the default supported inputs for ease of use.
  95221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95222. */
  95223. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95224. /**
  95225. * Instantiates a new FlyCameraInputsManager.
  95226. * @param camera Defines the camera the inputs belong to.
  95227. */
  95228. constructor(camera: FlyCamera);
  95229. /**
  95230. * Add keyboard input support to the input manager.
  95231. * @returns the new FlyCameraKeyboardMoveInput().
  95232. */
  95233. addKeyboard(): FlyCameraInputsManager;
  95234. /**
  95235. * Add mouse input support to the input manager.
  95236. * @param touchEnabled Enable touch screen support.
  95237. * @returns the new FlyCameraMouseInput().
  95238. */
  95239. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95240. }
  95241. }
  95242. declare module BABYLON {
  95243. /**
  95244. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95245. * such as in a 3D Space Shooter or a Flight Simulator.
  95246. */
  95247. export class FlyCamera extends TargetCamera {
  95248. /**
  95249. * Define the collision ellipsoid of the camera.
  95250. * This is helpful for simulating a camera body, like a player's body.
  95251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95252. */
  95253. ellipsoid: Vector3;
  95254. /**
  95255. * Define an offset for the position of the ellipsoid around the camera.
  95256. * This can be helpful if the camera is attached away from the player's body center,
  95257. * such as at its head.
  95258. */
  95259. ellipsoidOffset: Vector3;
  95260. /**
  95261. * Enable or disable collisions of the camera with the rest of the scene objects.
  95262. */
  95263. checkCollisions: boolean;
  95264. /**
  95265. * Enable or disable gravity on the camera.
  95266. */
  95267. applyGravity: boolean;
  95268. /**
  95269. * Define the current direction the camera is moving to.
  95270. */
  95271. cameraDirection: Vector3;
  95272. /**
  95273. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95274. * This overrides and empties cameraRotation.
  95275. */
  95276. rotationQuaternion: Quaternion;
  95277. /**
  95278. * Track Roll to maintain the wanted Rolling when looking around.
  95279. */
  95280. _trackRoll: number;
  95281. /**
  95282. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95283. */
  95284. rollCorrect: number;
  95285. /**
  95286. * Mimic a banked turn, Rolling the camera when Yawing.
  95287. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95288. */
  95289. bankedTurn: boolean;
  95290. /**
  95291. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95292. */
  95293. bankedTurnLimit: number;
  95294. /**
  95295. * Value of 0 disables the banked Roll.
  95296. * Value of 1 is equal to the Yaw angle in radians.
  95297. */
  95298. bankedTurnMultiplier: number;
  95299. /**
  95300. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95301. */
  95302. inputs: FlyCameraInputsManager;
  95303. /**
  95304. * Gets the input sensibility for mouse input.
  95305. * Higher values reduce sensitivity.
  95306. */
  95307. /**
  95308. * Sets the input sensibility for a mouse input.
  95309. * Higher values reduce sensitivity.
  95310. */
  95311. angularSensibility: number;
  95312. /**
  95313. * Get the keys for camera movement forward.
  95314. */
  95315. /**
  95316. * Set the keys for camera movement forward.
  95317. */
  95318. keysForward: number[];
  95319. /**
  95320. * Get the keys for camera movement backward.
  95321. */
  95322. keysBackward: number[];
  95323. /**
  95324. * Get the keys for camera movement up.
  95325. */
  95326. /**
  95327. * Set the keys for camera movement up.
  95328. */
  95329. keysUp: number[];
  95330. /**
  95331. * Get the keys for camera movement down.
  95332. */
  95333. /**
  95334. * Set the keys for camera movement down.
  95335. */
  95336. keysDown: number[];
  95337. /**
  95338. * Get the keys for camera movement left.
  95339. */
  95340. /**
  95341. * Set the keys for camera movement left.
  95342. */
  95343. keysLeft: number[];
  95344. /**
  95345. * Set the keys for camera movement right.
  95346. */
  95347. /**
  95348. * Set the keys for camera movement right.
  95349. */
  95350. keysRight: number[];
  95351. /**
  95352. * Event raised when the camera collides with a mesh in the scene.
  95353. */
  95354. onCollide: (collidedMesh: AbstractMesh) => void;
  95355. private _collider;
  95356. private _needMoveForGravity;
  95357. private _oldPosition;
  95358. private _diffPosition;
  95359. private _newPosition;
  95360. /** @hidden */
  95361. _localDirection: Vector3;
  95362. /** @hidden */
  95363. _transformedDirection: Vector3;
  95364. /**
  95365. * Instantiates a FlyCamera.
  95366. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95367. * such as in a 3D Space Shooter or a Flight Simulator.
  95368. * @param name Define the name of the camera in the scene.
  95369. * @param position Define the starting position of the camera in the scene.
  95370. * @param scene Define the scene the camera belongs to.
  95371. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95372. */
  95373. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95374. /**
  95375. * Attach a control to the HTML DOM element.
  95376. * @param element Defines the element that listens to the input events.
  95377. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95378. */
  95379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95380. /**
  95381. * Detach a control from the HTML DOM element.
  95382. * The camera will stop reacting to that input.
  95383. * @param element Defines the element that listens to the input events.
  95384. */
  95385. detachControl(element: HTMLElement): void;
  95386. private _collisionMask;
  95387. /**
  95388. * Get the mask that the camera ignores in collision events.
  95389. */
  95390. /**
  95391. * Set the mask that the camera ignores in collision events.
  95392. */
  95393. collisionMask: number;
  95394. /** @hidden */
  95395. _collideWithWorld(displacement: Vector3): void;
  95396. /** @hidden */
  95397. private _onCollisionPositionChange;
  95398. /** @hidden */
  95399. _checkInputs(): void;
  95400. /** @hidden */
  95401. _decideIfNeedsToMove(): boolean;
  95402. /** @hidden */
  95403. _updatePosition(): void;
  95404. /**
  95405. * Restore the Roll to its target value at the rate specified.
  95406. * @param rate - Higher means slower restoring.
  95407. * @hidden
  95408. */
  95409. restoreRoll(rate: number): void;
  95410. /**
  95411. * Destroy the camera and release the current resources held by it.
  95412. */
  95413. dispose(): void;
  95414. /**
  95415. * Get the current object class name.
  95416. * @returns the class name.
  95417. */
  95418. getClassName(): string;
  95419. }
  95420. }
  95421. declare module BABYLON {
  95422. /**
  95423. * Listen to keyboard events to control the camera.
  95424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95425. */
  95426. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95427. /**
  95428. * Defines the camera the input is attached to.
  95429. */
  95430. camera: FlyCamera;
  95431. /**
  95432. * The list of keyboard keys used to control the forward move of the camera.
  95433. */
  95434. keysForward: number[];
  95435. /**
  95436. * The list of keyboard keys used to control the backward move of the camera.
  95437. */
  95438. keysBackward: number[];
  95439. /**
  95440. * The list of keyboard keys used to control the forward move of the camera.
  95441. */
  95442. keysUp: number[];
  95443. /**
  95444. * The list of keyboard keys used to control the backward move of the camera.
  95445. */
  95446. keysDown: number[];
  95447. /**
  95448. * The list of keyboard keys used to control the right strafe move of the camera.
  95449. */
  95450. keysRight: number[];
  95451. /**
  95452. * The list of keyboard keys used to control the left strafe move of the camera.
  95453. */
  95454. keysLeft: number[];
  95455. private _keys;
  95456. private _onCanvasBlurObserver;
  95457. private _onKeyboardObserver;
  95458. private _engine;
  95459. private _scene;
  95460. /**
  95461. * Attach the input controls to a specific dom element to get the input from.
  95462. * @param element Defines the element the controls should be listened from
  95463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95464. */
  95465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95466. /**
  95467. * Detach the current controls from the specified dom element.
  95468. * @param element Defines the element to stop listening the inputs from
  95469. */
  95470. detachControl(element: Nullable<HTMLElement>): void;
  95471. /**
  95472. * Gets the class name of the current intput.
  95473. * @returns the class name
  95474. */
  95475. getClassName(): string;
  95476. /** @hidden */
  95477. _onLostFocus(e: FocusEvent): void;
  95478. /**
  95479. * Get the friendly name associated with the input class.
  95480. * @returns the input friendly name
  95481. */
  95482. getSimpleName(): string;
  95483. /**
  95484. * Update the current camera state depending on the inputs that have been used this frame.
  95485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95486. */
  95487. checkInputs(): void;
  95488. }
  95489. }
  95490. declare module BABYLON {
  95491. /**
  95492. * Manage the mouse wheel inputs to control a follow camera.
  95493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95494. */
  95495. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95496. /**
  95497. * Defines the camera the input is attached to.
  95498. */
  95499. camera: FollowCamera;
  95500. /**
  95501. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95502. */
  95503. axisControlRadius: boolean;
  95504. /**
  95505. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95506. */
  95507. axisControlHeight: boolean;
  95508. /**
  95509. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95510. */
  95511. axisControlRotation: boolean;
  95512. /**
  95513. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95514. * relation to mouseWheel events.
  95515. */
  95516. wheelPrecision: number;
  95517. /**
  95518. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95519. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95520. */
  95521. wheelDeltaPercentage: number;
  95522. private _wheel;
  95523. private _observer;
  95524. /**
  95525. * Attach the input controls to a specific dom element to get the input from.
  95526. * @param element Defines the element the controls should be listened from
  95527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95528. */
  95529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95530. /**
  95531. * Detach the current controls from the specified dom element.
  95532. * @param element Defines the element to stop listening the inputs from
  95533. */
  95534. detachControl(element: Nullable<HTMLElement>): void;
  95535. /**
  95536. * Gets the class name of the current intput.
  95537. * @returns the class name
  95538. */
  95539. getClassName(): string;
  95540. /**
  95541. * Get the friendly name associated with the input class.
  95542. * @returns the input friendly name
  95543. */
  95544. getSimpleName(): string;
  95545. }
  95546. }
  95547. declare module BABYLON {
  95548. /**
  95549. * Manage the pointers inputs to control an follow camera.
  95550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95551. */
  95552. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95553. /**
  95554. * Defines the camera the input is attached to.
  95555. */
  95556. camera: FollowCamera;
  95557. /**
  95558. * Gets the class name of the current input.
  95559. * @returns the class name
  95560. */
  95561. getClassName(): string;
  95562. /**
  95563. * Defines the pointer angular sensibility along the X axis or how fast is
  95564. * the camera rotating.
  95565. * A negative number will reverse the axis direction.
  95566. */
  95567. angularSensibilityX: number;
  95568. /**
  95569. * Defines the pointer angular sensibility along the Y axis or how fast is
  95570. * the camera rotating.
  95571. * A negative number will reverse the axis direction.
  95572. */
  95573. angularSensibilityY: number;
  95574. /**
  95575. * Defines the pointer pinch precision or how fast is the camera zooming.
  95576. * A negative number will reverse the axis direction.
  95577. */
  95578. pinchPrecision: number;
  95579. /**
  95580. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95581. * from 0.
  95582. * It defines the percentage of current camera.radius to use as delta when
  95583. * pinch zoom is used.
  95584. */
  95585. pinchDeltaPercentage: number;
  95586. /**
  95587. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95588. */
  95589. axisXControlRadius: boolean;
  95590. /**
  95591. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95592. */
  95593. axisXControlHeight: boolean;
  95594. /**
  95595. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95596. */
  95597. axisXControlRotation: boolean;
  95598. /**
  95599. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95600. */
  95601. axisYControlRadius: boolean;
  95602. /**
  95603. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95604. */
  95605. axisYControlHeight: boolean;
  95606. /**
  95607. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95608. */
  95609. axisYControlRotation: boolean;
  95610. /**
  95611. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95612. */
  95613. axisPinchControlRadius: boolean;
  95614. /**
  95615. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95616. */
  95617. axisPinchControlHeight: boolean;
  95618. /**
  95619. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95620. */
  95621. axisPinchControlRotation: boolean;
  95622. /**
  95623. * Log error messages if basic misconfiguration has occurred.
  95624. */
  95625. warningEnable: boolean;
  95626. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95627. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95628. private _warningCounter;
  95629. private _warning;
  95630. }
  95631. }
  95632. declare module BABYLON {
  95633. /**
  95634. * Default Inputs manager for the FollowCamera.
  95635. * It groups all the default supported inputs for ease of use.
  95636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95637. */
  95638. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95639. /**
  95640. * Instantiates a new FollowCameraInputsManager.
  95641. * @param camera Defines the camera the inputs belong to
  95642. */
  95643. constructor(camera: FollowCamera);
  95644. /**
  95645. * Add keyboard input support to the input manager.
  95646. * @returns the current input manager
  95647. */
  95648. addKeyboard(): FollowCameraInputsManager;
  95649. /**
  95650. * Add mouse wheel input support to the input manager.
  95651. * @returns the current input manager
  95652. */
  95653. addMouseWheel(): FollowCameraInputsManager;
  95654. /**
  95655. * Add pointers input support to the input manager.
  95656. * @returns the current input manager
  95657. */
  95658. addPointers(): FollowCameraInputsManager;
  95659. /**
  95660. * Add orientation input support to the input manager.
  95661. * @returns the current input manager
  95662. */
  95663. addVRDeviceOrientation(): FollowCameraInputsManager;
  95664. }
  95665. }
  95666. declare module BABYLON {
  95667. /**
  95668. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95669. * an arc rotate version arcFollowCamera are available.
  95670. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95671. */
  95672. export class FollowCamera extends TargetCamera {
  95673. /**
  95674. * Distance the follow camera should follow an object at
  95675. */
  95676. radius: number;
  95677. /**
  95678. * Minimum allowed distance of the camera to the axis of rotation
  95679. * (The camera can not get closer).
  95680. * This can help limiting how the Camera is able to move in the scene.
  95681. */
  95682. lowerRadiusLimit: Nullable<number>;
  95683. /**
  95684. * Maximum allowed distance of the camera to the axis of rotation
  95685. * (The camera can not get further).
  95686. * This can help limiting how the Camera is able to move in the scene.
  95687. */
  95688. upperRadiusLimit: Nullable<number>;
  95689. /**
  95690. * Define a rotation offset between the camera and the object it follows
  95691. */
  95692. rotationOffset: number;
  95693. /**
  95694. * Minimum allowed angle to camera position relative to target object.
  95695. * This can help limiting how the Camera is able to move in the scene.
  95696. */
  95697. lowerRotationOffsetLimit: Nullable<number>;
  95698. /**
  95699. * Maximum allowed angle to camera position relative to target object.
  95700. * This can help limiting how the Camera is able to move in the scene.
  95701. */
  95702. upperRotationOffsetLimit: Nullable<number>;
  95703. /**
  95704. * Define a height offset between the camera and the object it follows.
  95705. * It can help following an object from the top (like a car chaing a plane)
  95706. */
  95707. heightOffset: number;
  95708. /**
  95709. * Minimum allowed height of camera position relative to target object.
  95710. * This can help limiting how the Camera is able to move in the scene.
  95711. */
  95712. lowerHeightOffsetLimit: Nullable<number>;
  95713. /**
  95714. * Maximum allowed height of camera position relative to target object.
  95715. * This can help limiting how the Camera is able to move in the scene.
  95716. */
  95717. upperHeightOffsetLimit: Nullable<number>;
  95718. /**
  95719. * Define how fast the camera can accelerate to follow it s target.
  95720. */
  95721. cameraAcceleration: number;
  95722. /**
  95723. * Define the speed limit of the camera following an object.
  95724. */
  95725. maxCameraSpeed: number;
  95726. /**
  95727. * Define the target of the camera.
  95728. */
  95729. lockedTarget: Nullable<AbstractMesh>;
  95730. /**
  95731. * Defines the input associated with the camera.
  95732. */
  95733. inputs: FollowCameraInputsManager;
  95734. /**
  95735. * Instantiates the follow camera.
  95736. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95737. * @param name Define the name of the camera in the scene
  95738. * @param position Define the position of the camera
  95739. * @param scene Define the scene the camera belong to
  95740. * @param lockedTarget Define the target of the camera
  95741. */
  95742. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95743. private _follow;
  95744. /**
  95745. * Attached controls to the current camera.
  95746. * @param element Defines the element the controls should be listened from
  95747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95748. */
  95749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95750. /**
  95751. * Detach the current controls from the camera.
  95752. * The camera will stop reacting to inputs.
  95753. * @param element Defines the element to stop listening the inputs from
  95754. */
  95755. detachControl(element: HTMLElement): void;
  95756. /** @hidden */
  95757. _checkInputs(): void;
  95758. private _checkLimits;
  95759. /**
  95760. * Gets the camera class name.
  95761. * @returns the class name
  95762. */
  95763. getClassName(): string;
  95764. }
  95765. /**
  95766. * Arc Rotate version of the follow camera.
  95767. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  95768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95769. */
  95770. export class ArcFollowCamera extends TargetCamera {
  95771. /** The longitudinal angle of the camera */
  95772. alpha: number;
  95773. /** The latitudinal angle of the camera */
  95774. beta: number;
  95775. /** The radius of the camera from its target */
  95776. radius: number;
  95777. /** Define the camera target (the messh it should follow) */
  95778. target: Nullable<AbstractMesh>;
  95779. private _cartesianCoordinates;
  95780. /**
  95781. * Instantiates a new ArcFollowCamera
  95782. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95783. * @param name Define the name of the camera
  95784. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  95785. * @param beta Define the rotation angle of the camera around the elevation axis
  95786. * @param radius Define the radius of the camera from its target point
  95787. * @param target Define the target of the camera
  95788. * @param scene Define the scene the camera belongs to
  95789. */
  95790. constructor(name: string,
  95791. /** The longitudinal angle of the camera */
  95792. alpha: number,
  95793. /** The latitudinal angle of the camera */
  95794. beta: number,
  95795. /** The radius of the camera from its target */
  95796. radius: number,
  95797. /** Define the camera target (the messh it should follow) */
  95798. target: Nullable<AbstractMesh>, scene: Scene);
  95799. private _follow;
  95800. /** @hidden */
  95801. _checkInputs(): void;
  95802. /**
  95803. * Returns the class name of the object.
  95804. * It is mostly used internally for serialization purposes.
  95805. */
  95806. getClassName(): string;
  95807. }
  95808. }
  95809. declare module BABYLON {
  95810. /**
  95811. * Manage the keyboard inputs to control the movement of a follow camera.
  95812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95813. */
  95814. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95815. /**
  95816. * Defines the camera the input is attached to.
  95817. */
  95818. camera: FollowCamera;
  95819. /**
  95820. * Defines the list of key codes associated with the up action (increase heightOffset)
  95821. */
  95822. keysHeightOffsetIncr: number[];
  95823. /**
  95824. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95825. */
  95826. keysHeightOffsetDecr: number[];
  95827. /**
  95828. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95829. */
  95830. keysHeightOffsetModifierAlt: boolean;
  95831. /**
  95832. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95833. */
  95834. keysHeightOffsetModifierCtrl: boolean;
  95835. /**
  95836. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95837. */
  95838. keysHeightOffsetModifierShift: boolean;
  95839. /**
  95840. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95841. */
  95842. keysRotationOffsetIncr: number[];
  95843. /**
  95844. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95845. */
  95846. keysRotationOffsetDecr: number[];
  95847. /**
  95848. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95849. */
  95850. keysRotationOffsetModifierAlt: boolean;
  95851. /**
  95852. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95853. */
  95854. keysRotationOffsetModifierCtrl: boolean;
  95855. /**
  95856. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95857. */
  95858. keysRotationOffsetModifierShift: boolean;
  95859. /**
  95860. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95861. */
  95862. keysRadiusIncr: number[];
  95863. /**
  95864. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95865. */
  95866. keysRadiusDecr: number[];
  95867. /**
  95868. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95869. */
  95870. keysRadiusModifierAlt: boolean;
  95871. /**
  95872. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95873. */
  95874. keysRadiusModifierCtrl: boolean;
  95875. /**
  95876. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95877. */
  95878. keysRadiusModifierShift: boolean;
  95879. /**
  95880. * Defines the rate of change of heightOffset.
  95881. */
  95882. heightSensibility: number;
  95883. /**
  95884. * Defines the rate of change of rotationOffset.
  95885. */
  95886. rotationSensibility: number;
  95887. /**
  95888. * Defines the rate of change of radius.
  95889. */
  95890. radiusSensibility: number;
  95891. private _keys;
  95892. private _ctrlPressed;
  95893. private _altPressed;
  95894. private _shiftPressed;
  95895. private _onCanvasBlurObserver;
  95896. private _onKeyboardObserver;
  95897. private _engine;
  95898. private _scene;
  95899. /**
  95900. * Attach the input controls to a specific dom element to get the input from.
  95901. * @param element Defines the element the controls should be listened from
  95902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95903. */
  95904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95905. /**
  95906. * Detach the current controls from the specified dom element.
  95907. * @param element Defines the element to stop listening the inputs from
  95908. */
  95909. detachControl(element: Nullable<HTMLElement>): void;
  95910. /**
  95911. * Update the current camera state depending on the inputs that have been used this frame.
  95912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95913. */
  95914. checkInputs(): void;
  95915. /**
  95916. * Gets the class name of the current input.
  95917. * @returns the class name
  95918. */
  95919. getClassName(): string;
  95920. /**
  95921. * Get the friendly name associated with the input class.
  95922. * @returns the input friendly name
  95923. */
  95924. getSimpleName(): string;
  95925. /**
  95926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95927. * allow modification of the heightOffset value.
  95928. */
  95929. private _modifierHeightOffset;
  95930. /**
  95931. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95932. * allow modification of the rotationOffset value.
  95933. */
  95934. private _modifierRotationOffset;
  95935. /**
  95936. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95937. * allow modification of the radius value.
  95938. */
  95939. private _modifierRadius;
  95940. }
  95941. }
  95942. declare module BABYLON {
  95943. interface FreeCameraInputsManager {
  95944. /**
  95945. * @hidden
  95946. */
  95947. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  95948. /**
  95949. * Add orientation input support to the input manager.
  95950. * @returns the current input manager
  95951. */
  95952. addDeviceOrientation(): FreeCameraInputsManager;
  95953. }
  95954. /**
  95955. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95956. * Screen rotation is taken into account.
  95957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95958. */
  95959. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95960. private _camera;
  95961. private _screenOrientationAngle;
  95962. private _constantTranform;
  95963. private _screenQuaternion;
  95964. private _alpha;
  95965. private _beta;
  95966. private _gamma;
  95967. /**
  95968. * @hidden
  95969. */
  95970. _onDeviceOrientationChangedObservable: Observable<void>;
  95971. /**
  95972. * Instantiates a new input
  95973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95974. */
  95975. constructor();
  95976. /**
  95977. * Define the camera controlled by the input.
  95978. */
  95979. camera: FreeCamera;
  95980. /**
  95981. * Attach the input controls to a specific dom element to get the input from.
  95982. * @param element Defines the element the controls should be listened from
  95983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95984. */
  95985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95986. private _orientationChanged;
  95987. private _deviceOrientation;
  95988. /**
  95989. * Detach the current controls from the specified dom element.
  95990. * @param element Defines the element to stop listening the inputs from
  95991. */
  95992. detachControl(element: Nullable<HTMLElement>): void;
  95993. /**
  95994. * Update the current camera state depending on the inputs that have been used this frame.
  95995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95996. */
  95997. checkInputs(): void;
  95998. /**
  95999. * Gets the class name of the current intput.
  96000. * @returns the class name
  96001. */
  96002. getClassName(): string;
  96003. /**
  96004. * Get the friendly name associated with the input class.
  96005. * @returns the input friendly name
  96006. */
  96007. getSimpleName(): string;
  96008. }
  96009. }
  96010. declare module BABYLON {
  96011. /**
  96012. * Manage the gamepad inputs to control a free camera.
  96013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96014. */
  96015. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96016. /**
  96017. * Define the camera the input is attached to.
  96018. */
  96019. camera: FreeCamera;
  96020. /**
  96021. * Define the Gamepad controlling the input
  96022. */
  96023. gamepad: Nullable<Gamepad>;
  96024. /**
  96025. * Defines the gamepad rotation sensiblity.
  96026. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96027. */
  96028. gamepadAngularSensibility: number;
  96029. /**
  96030. * Defines the gamepad move sensiblity.
  96031. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96032. */
  96033. gamepadMoveSensibility: number;
  96034. private _onGamepadConnectedObserver;
  96035. private _onGamepadDisconnectedObserver;
  96036. private _cameraTransform;
  96037. private _deltaTransform;
  96038. private _vector3;
  96039. private _vector2;
  96040. /**
  96041. * Attach the input controls to a specific dom element to get the input from.
  96042. * @param element Defines the element the controls should be listened from
  96043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96044. */
  96045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96046. /**
  96047. * Detach the current controls from the specified dom element.
  96048. * @param element Defines the element to stop listening the inputs from
  96049. */
  96050. detachControl(element: Nullable<HTMLElement>): void;
  96051. /**
  96052. * Update the current camera state depending on the inputs that have been used this frame.
  96053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96054. */
  96055. checkInputs(): void;
  96056. /**
  96057. * Gets the class name of the current intput.
  96058. * @returns the class name
  96059. */
  96060. getClassName(): string;
  96061. /**
  96062. * Get the friendly name associated with the input class.
  96063. * @returns the input friendly name
  96064. */
  96065. getSimpleName(): string;
  96066. }
  96067. }
  96068. declare module BABYLON {
  96069. /**
  96070. * Defines the potential axis of a Joystick
  96071. */
  96072. export enum JoystickAxis {
  96073. /** X axis */
  96074. X = 0,
  96075. /** Y axis */
  96076. Y = 1,
  96077. /** Z axis */
  96078. Z = 2
  96079. }
  96080. /**
  96081. * Class used to define virtual joystick (used in touch mode)
  96082. */
  96083. export class VirtualJoystick {
  96084. /**
  96085. * Gets or sets a boolean indicating that left and right values must be inverted
  96086. */
  96087. reverseLeftRight: boolean;
  96088. /**
  96089. * Gets or sets a boolean indicating that up and down values must be inverted
  96090. */
  96091. reverseUpDown: boolean;
  96092. /**
  96093. * Gets the offset value for the position (ie. the change of the position value)
  96094. */
  96095. deltaPosition: Vector3;
  96096. /**
  96097. * Gets a boolean indicating if the virtual joystick was pressed
  96098. */
  96099. pressed: boolean;
  96100. /**
  96101. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96102. */
  96103. static Canvas: Nullable<HTMLCanvasElement>;
  96104. private static _globalJoystickIndex;
  96105. private static vjCanvasContext;
  96106. private static vjCanvasWidth;
  96107. private static vjCanvasHeight;
  96108. private static halfWidth;
  96109. private _action;
  96110. private _axisTargetedByLeftAndRight;
  96111. private _axisTargetedByUpAndDown;
  96112. private _joystickSensibility;
  96113. private _inversedSensibility;
  96114. private _joystickPointerID;
  96115. private _joystickColor;
  96116. private _joystickPointerPos;
  96117. private _joystickPreviousPointerPos;
  96118. private _joystickPointerStartPos;
  96119. private _deltaJoystickVector;
  96120. private _leftJoystick;
  96121. private _touches;
  96122. private _onPointerDownHandlerRef;
  96123. private _onPointerMoveHandlerRef;
  96124. private _onPointerUpHandlerRef;
  96125. private _onResize;
  96126. /**
  96127. * Creates a new virtual joystick
  96128. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96129. */
  96130. constructor(leftJoystick?: boolean);
  96131. /**
  96132. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96133. * @param newJoystickSensibility defines the new sensibility
  96134. */
  96135. setJoystickSensibility(newJoystickSensibility: number): void;
  96136. private _onPointerDown;
  96137. private _onPointerMove;
  96138. private _onPointerUp;
  96139. /**
  96140. * Change the color of the virtual joystick
  96141. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96142. */
  96143. setJoystickColor(newColor: string): void;
  96144. /**
  96145. * Defines a callback to call when the joystick is touched
  96146. * @param action defines the callback
  96147. */
  96148. setActionOnTouch(action: () => any): void;
  96149. /**
  96150. * Defines which axis you'd like to control for left & right
  96151. * @param axis defines the axis to use
  96152. */
  96153. setAxisForLeftRight(axis: JoystickAxis): void;
  96154. /**
  96155. * Defines which axis you'd like to control for up & down
  96156. * @param axis defines the axis to use
  96157. */
  96158. setAxisForUpDown(axis: JoystickAxis): void;
  96159. private _drawVirtualJoystick;
  96160. /**
  96161. * Release internal HTML canvas
  96162. */
  96163. releaseCanvas(): void;
  96164. }
  96165. }
  96166. declare module BABYLON {
  96167. interface FreeCameraInputsManager {
  96168. /**
  96169. * Add virtual joystick input support to the input manager.
  96170. * @returns the current input manager
  96171. */
  96172. addVirtualJoystick(): FreeCameraInputsManager;
  96173. }
  96174. /**
  96175. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96177. */
  96178. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96179. /**
  96180. * Defines the camera the input is attached to.
  96181. */
  96182. camera: FreeCamera;
  96183. private _leftjoystick;
  96184. private _rightjoystick;
  96185. /**
  96186. * Gets the left stick of the virtual joystick.
  96187. * @returns The virtual Joystick
  96188. */
  96189. getLeftJoystick(): VirtualJoystick;
  96190. /**
  96191. * Gets the right stick of the virtual joystick.
  96192. * @returns The virtual Joystick
  96193. */
  96194. getRightJoystick(): VirtualJoystick;
  96195. /**
  96196. * Update the current camera state depending on the inputs that have been used this frame.
  96197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96198. */
  96199. checkInputs(): void;
  96200. /**
  96201. * Attach the input controls to a specific dom element to get the input from.
  96202. * @param element Defines the element the controls should be listened from
  96203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96204. */
  96205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96206. /**
  96207. * Detach the current controls from the specified dom element.
  96208. * @param element Defines the element to stop listening the inputs from
  96209. */
  96210. detachControl(element: Nullable<HTMLElement>): void;
  96211. /**
  96212. * Gets the class name of the current intput.
  96213. * @returns the class name
  96214. */
  96215. getClassName(): string;
  96216. /**
  96217. * Get the friendly name associated with the input class.
  96218. * @returns the input friendly name
  96219. */
  96220. getSimpleName(): string;
  96221. }
  96222. }
  96223. declare module BABYLON {
  96224. /**
  96225. * This represents a FPS type of camera controlled by touch.
  96226. * This is like a universal camera minus the Gamepad controls.
  96227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96228. */
  96229. export class TouchCamera extends FreeCamera {
  96230. /**
  96231. * Defines the touch sensibility for rotation.
  96232. * The higher the faster.
  96233. */
  96234. touchAngularSensibility: number;
  96235. /**
  96236. * Defines the touch sensibility for move.
  96237. * The higher the faster.
  96238. */
  96239. touchMoveSensibility: number;
  96240. /**
  96241. * Instantiates a new touch camera.
  96242. * This represents a FPS type of camera controlled by touch.
  96243. * This is like a universal camera minus the Gamepad controls.
  96244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96245. * @param name Define the name of the camera in the scene
  96246. * @param position Define the start position of the camera in the scene
  96247. * @param scene Define the scene the camera belongs to
  96248. */
  96249. constructor(name: string, position: Vector3, scene: Scene);
  96250. /**
  96251. * Gets the current object class name.
  96252. * @return the class name
  96253. */
  96254. getClassName(): string;
  96255. /** @hidden */
  96256. _setupInputs(): void;
  96257. }
  96258. }
  96259. declare module BABYLON {
  96260. /**
  96261. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96262. * being tilted forward or back and left or right.
  96263. */
  96264. export class DeviceOrientationCamera extends FreeCamera {
  96265. private _initialQuaternion;
  96266. private _quaternionCache;
  96267. private _tmpDragQuaternion;
  96268. /**
  96269. * Creates a new device orientation camera
  96270. * @param name The name of the camera
  96271. * @param position The start position camera
  96272. * @param scene The scene the camera belongs to
  96273. */
  96274. constructor(name: string, position: Vector3, scene: Scene);
  96275. /**
  96276. * Disabled pointer input on first orientation sensor update (Default: true)
  96277. */
  96278. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96279. private _dragFactor;
  96280. /**
  96281. * Enabled turning on the y axis when the orientation sensor is active
  96282. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96283. */
  96284. enableHorizontalDragging(dragFactor?: number): void;
  96285. /**
  96286. * Gets the current instance class name ("DeviceOrientationCamera").
  96287. * This helps avoiding instanceof at run time.
  96288. * @returns the class name
  96289. */
  96290. getClassName(): string;
  96291. /**
  96292. * @hidden
  96293. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96294. */
  96295. _checkInputs(): void;
  96296. /**
  96297. * Reset the camera to its default orientation on the specified axis only.
  96298. * @param axis The axis to reset
  96299. */
  96300. resetToCurrentRotation(axis?: Axis): void;
  96301. }
  96302. }
  96303. declare module BABYLON {
  96304. /**
  96305. * 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,
  96306. * which still works and will still be found in many Playgrounds.
  96307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96308. */
  96309. export class UniversalCamera extends TouchCamera {
  96310. /**
  96311. * Defines the gamepad rotation sensiblity.
  96312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96313. */
  96314. gamepadAngularSensibility: number;
  96315. /**
  96316. * Defines the gamepad move sensiblity.
  96317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96318. */
  96319. gamepadMoveSensibility: number;
  96320. /**
  96321. * 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,
  96322. * which still works and will still be found in many Playgrounds.
  96323. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96324. * @param name Define the name of the camera in the scene
  96325. * @param position Define the start position of the camera in the scene
  96326. * @param scene Define the scene the camera belongs to
  96327. */
  96328. constructor(name: string, position: Vector3, scene: Scene);
  96329. /**
  96330. * Gets the current object class name.
  96331. * @return the class name
  96332. */
  96333. getClassName(): string;
  96334. }
  96335. }
  96336. declare module BABYLON {
  96337. /**
  96338. * This represents a FPS type of camera. This is only here for back compat purpose.
  96339. * Please use the UniversalCamera instead as both are identical.
  96340. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96341. */
  96342. export class GamepadCamera extends UniversalCamera {
  96343. /**
  96344. * Instantiates a new Gamepad Camera
  96345. * This represents a FPS type of camera. This is only here for back compat purpose.
  96346. * Please use the UniversalCamera instead as both are identical.
  96347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96348. * @param name Define the name of the camera in the scene
  96349. * @param position Define the start position of the camera in the scene
  96350. * @param scene Define the scene the camera belongs to
  96351. */
  96352. constructor(name: string, position: Vector3, scene: Scene);
  96353. /**
  96354. * Gets the current object class name.
  96355. * @return the class name
  96356. */
  96357. getClassName(): string;
  96358. }
  96359. }
  96360. declare module BABYLON {
  96361. /** @hidden */
  96362. export var passPixelShader: {
  96363. name: string;
  96364. shader: string;
  96365. };
  96366. }
  96367. declare module BABYLON {
  96368. /** @hidden */
  96369. export var passCubePixelShader: {
  96370. name: string;
  96371. shader: string;
  96372. };
  96373. }
  96374. declare module BABYLON {
  96375. /**
  96376. * PassPostProcess which produces an output the same as it's input
  96377. */
  96378. export class PassPostProcess extends PostProcess {
  96379. /**
  96380. * Creates the PassPostProcess
  96381. * @param name The name of the effect.
  96382. * @param options The required width/height ratio to downsize to before computing the render pass.
  96383. * @param camera The camera to apply the render pass to.
  96384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96385. * @param engine The engine which the post process will be applied. (default: current engine)
  96386. * @param reusable If the post process can be reused on the same frame. (default: false)
  96387. * @param textureType The type of texture to be used when performing the post processing.
  96388. * @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)
  96389. */
  96390. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96391. }
  96392. /**
  96393. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96394. */
  96395. export class PassCubePostProcess extends PostProcess {
  96396. private _face;
  96397. /**
  96398. * Gets or sets the cube face to display.
  96399. * * 0 is +X
  96400. * * 1 is -X
  96401. * * 2 is +Y
  96402. * * 3 is -Y
  96403. * * 4 is +Z
  96404. * * 5 is -Z
  96405. */
  96406. face: number;
  96407. /**
  96408. * Creates the PassCubePostProcess
  96409. * @param name The name of the effect.
  96410. * @param options The required width/height ratio to downsize to before computing the render pass.
  96411. * @param camera The camera to apply the render pass to.
  96412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96413. * @param engine The engine which the post process will be applied. (default: current engine)
  96414. * @param reusable If the post process can be reused on the same frame. (default: false)
  96415. * @param textureType The type of texture to be used when performing the post processing.
  96416. * @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)
  96417. */
  96418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. /** @hidden */
  96423. export var anaglyphPixelShader: {
  96424. name: string;
  96425. shader: string;
  96426. };
  96427. }
  96428. declare module BABYLON {
  96429. /**
  96430. * Postprocess used to generate anaglyphic rendering
  96431. */
  96432. export class AnaglyphPostProcess extends PostProcess {
  96433. private _passedProcess;
  96434. /**
  96435. * Creates a new AnaglyphPostProcess
  96436. * @param name defines postprocess name
  96437. * @param options defines creation options or target ratio scale
  96438. * @param rigCameras defines cameras using this postprocess
  96439. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96440. * @param engine defines hosting engine
  96441. * @param reusable defines if the postprocess will be reused multiple times per frame
  96442. */
  96443. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96444. }
  96445. }
  96446. declare module BABYLON {
  96447. /**
  96448. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96449. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96450. */
  96451. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96452. /**
  96453. * Creates a new AnaglyphArcRotateCamera
  96454. * @param name defines camera name
  96455. * @param alpha defines alpha angle (in radians)
  96456. * @param beta defines beta angle (in radians)
  96457. * @param radius defines radius
  96458. * @param target defines camera target
  96459. * @param interaxialDistance defines distance between each color axis
  96460. * @param scene defines the hosting scene
  96461. */
  96462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96463. /**
  96464. * Gets camera class name
  96465. * @returns AnaglyphArcRotateCamera
  96466. */
  96467. getClassName(): string;
  96468. }
  96469. }
  96470. declare module BABYLON {
  96471. /**
  96472. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96473. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96474. */
  96475. export class AnaglyphFreeCamera extends FreeCamera {
  96476. /**
  96477. * Creates a new AnaglyphFreeCamera
  96478. * @param name defines camera name
  96479. * @param position defines initial position
  96480. * @param interaxialDistance defines distance between each color axis
  96481. * @param scene defines the hosting scene
  96482. */
  96483. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96484. /**
  96485. * Gets camera class name
  96486. * @returns AnaglyphFreeCamera
  96487. */
  96488. getClassName(): string;
  96489. }
  96490. }
  96491. declare module BABYLON {
  96492. /**
  96493. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96494. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96495. */
  96496. export class AnaglyphGamepadCamera extends GamepadCamera {
  96497. /**
  96498. * Creates a new AnaglyphGamepadCamera
  96499. * @param name defines camera name
  96500. * @param position defines initial position
  96501. * @param interaxialDistance defines distance between each color axis
  96502. * @param scene defines the hosting scene
  96503. */
  96504. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96505. /**
  96506. * Gets camera class name
  96507. * @returns AnaglyphGamepadCamera
  96508. */
  96509. getClassName(): string;
  96510. }
  96511. }
  96512. declare module BABYLON {
  96513. /**
  96514. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96515. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96516. */
  96517. export class AnaglyphUniversalCamera extends UniversalCamera {
  96518. /**
  96519. * Creates a new AnaglyphUniversalCamera
  96520. * @param name defines camera name
  96521. * @param position defines initial position
  96522. * @param interaxialDistance defines distance between each color axis
  96523. * @param scene defines the hosting scene
  96524. */
  96525. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96526. /**
  96527. * Gets camera class name
  96528. * @returns AnaglyphUniversalCamera
  96529. */
  96530. getClassName(): string;
  96531. }
  96532. }
  96533. declare module BABYLON {
  96534. /** @hidden */
  96535. export var stereoscopicInterlacePixelShader: {
  96536. name: string;
  96537. shader: string;
  96538. };
  96539. }
  96540. declare module BABYLON {
  96541. /**
  96542. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96543. */
  96544. export class StereoscopicInterlacePostProcess extends PostProcess {
  96545. private _stepSize;
  96546. private _passedProcess;
  96547. /**
  96548. * Initializes a StereoscopicInterlacePostProcess
  96549. * @param name The name of the effect.
  96550. * @param rigCameras The rig cameras to be appled to the post process
  96551. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96553. * @param engine The engine which the post process will be applied. (default: current engine)
  96554. * @param reusable If the post process can be reused on the same frame. (default: false)
  96555. */
  96556. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96557. }
  96558. }
  96559. declare module BABYLON {
  96560. /**
  96561. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96562. * @see http://doc.babylonjs.com/features/cameras
  96563. */
  96564. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96565. /**
  96566. * Creates a new StereoscopicArcRotateCamera
  96567. * @param name defines camera name
  96568. * @param alpha defines alpha angle (in radians)
  96569. * @param beta defines beta angle (in radians)
  96570. * @param radius defines radius
  96571. * @param target defines camera target
  96572. * @param interaxialDistance defines distance between each color axis
  96573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96574. * @param scene defines the hosting scene
  96575. */
  96576. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96577. /**
  96578. * Gets camera class name
  96579. * @returns StereoscopicArcRotateCamera
  96580. */
  96581. getClassName(): string;
  96582. }
  96583. }
  96584. declare module BABYLON {
  96585. /**
  96586. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96587. * @see http://doc.babylonjs.com/features/cameras
  96588. */
  96589. export class StereoscopicFreeCamera extends FreeCamera {
  96590. /**
  96591. * Creates a new StereoscopicFreeCamera
  96592. * @param name defines camera name
  96593. * @param position defines initial position
  96594. * @param interaxialDistance defines distance between each color axis
  96595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96596. * @param scene defines the hosting scene
  96597. */
  96598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96599. /**
  96600. * Gets camera class name
  96601. * @returns StereoscopicFreeCamera
  96602. */
  96603. getClassName(): string;
  96604. }
  96605. }
  96606. declare module BABYLON {
  96607. /**
  96608. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96609. * @see http://doc.babylonjs.com/features/cameras
  96610. */
  96611. export class StereoscopicGamepadCamera extends GamepadCamera {
  96612. /**
  96613. * Creates a new StereoscopicGamepadCamera
  96614. * @param name defines camera name
  96615. * @param position defines initial position
  96616. * @param interaxialDistance defines distance between each color axis
  96617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96618. * @param scene defines the hosting scene
  96619. */
  96620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96621. /**
  96622. * Gets camera class name
  96623. * @returns StereoscopicGamepadCamera
  96624. */
  96625. getClassName(): string;
  96626. }
  96627. }
  96628. declare module BABYLON {
  96629. /**
  96630. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96631. * @see http://doc.babylonjs.com/features/cameras
  96632. */
  96633. export class StereoscopicUniversalCamera extends UniversalCamera {
  96634. /**
  96635. * Creates a new StereoscopicUniversalCamera
  96636. * @param name defines camera name
  96637. * @param position defines initial position
  96638. * @param interaxialDistance defines distance between each color axis
  96639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96640. * @param scene defines the hosting scene
  96641. */
  96642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96643. /**
  96644. * Gets camera class name
  96645. * @returns StereoscopicUniversalCamera
  96646. */
  96647. getClassName(): string;
  96648. }
  96649. }
  96650. declare module BABYLON {
  96651. /**
  96652. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96653. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96654. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96655. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96656. */
  96657. export class VirtualJoysticksCamera extends FreeCamera {
  96658. /**
  96659. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96660. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96661. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96662. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96663. * @param name Define the name of the camera in the scene
  96664. * @param position Define the start position of the camera in the scene
  96665. * @param scene Define the scene the camera belongs to
  96666. */
  96667. constructor(name: string, position: Vector3, scene: Scene);
  96668. /**
  96669. * Gets the current object class name.
  96670. * @return the class name
  96671. */
  96672. getClassName(): string;
  96673. }
  96674. }
  96675. declare module BABYLON {
  96676. /**
  96677. * This represents all the required metrics to create a VR camera.
  96678. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96679. */
  96680. export class VRCameraMetrics {
  96681. /**
  96682. * Define the horizontal resolution off the screen.
  96683. */
  96684. hResolution: number;
  96685. /**
  96686. * Define the vertical resolution off the screen.
  96687. */
  96688. vResolution: number;
  96689. /**
  96690. * Define the horizontal screen size.
  96691. */
  96692. hScreenSize: number;
  96693. /**
  96694. * Define the vertical screen size.
  96695. */
  96696. vScreenSize: number;
  96697. /**
  96698. * Define the vertical screen center position.
  96699. */
  96700. vScreenCenter: number;
  96701. /**
  96702. * Define the distance of the eyes to the screen.
  96703. */
  96704. eyeToScreenDistance: number;
  96705. /**
  96706. * Define the distance between both lenses
  96707. */
  96708. lensSeparationDistance: number;
  96709. /**
  96710. * Define the distance between both viewer's eyes.
  96711. */
  96712. interpupillaryDistance: number;
  96713. /**
  96714. * Define the distortion factor of the VR postprocess.
  96715. * Please, touch with care.
  96716. */
  96717. distortionK: number[];
  96718. /**
  96719. * Define the chromatic aberration correction factors for the VR post process.
  96720. */
  96721. chromaAbCorrection: number[];
  96722. /**
  96723. * Define the scale factor of the post process.
  96724. * The smaller the better but the slower.
  96725. */
  96726. postProcessScaleFactor: number;
  96727. /**
  96728. * Define an offset for the lens center.
  96729. */
  96730. lensCenterOffset: number;
  96731. /**
  96732. * Define if the current vr camera should compensate the distortion of the lense or not.
  96733. */
  96734. compensateDistortion: boolean;
  96735. /**
  96736. * Defines if multiview should be enabled when rendering (Default: false)
  96737. */
  96738. multiviewEnabled: boolean;
  96739. /**
  96740. * Gets the rendering aspect ratio based on the provided resolutions.
  96741. */
  96742. readonly aspectRatio: number;
  96743. /**
  96744. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  96745. */
  96746. readonly aspectRatioFov: number;
  96747. /**
  96748. * @hidden
  96749. */
  96750. readonly leftHMatrix: Matrix;
  96751. /**
  96752. * @hidden
  96753. */
  96754. readonly rightHMatrix: Matrix;
  96755. /**
  96756. * @hidden
  96757. */
  96758. readonly leftPreViewMatrix: Matrix;
  96759. /**
  96760. * @hidden
  96761. */
  96762. readonly rightPreViewMatrix: Matrix;
  96763. /**
  96764. * Get the default VRMetrics based on the most generic setup.
  96765. * @returns the default vr metrics
  96766. */
  96767. static GetDefault(): VRCameraMetrics;
  96768. }
  96769. }
  96770. declare module BABYLON {
  96771. /** @hidden */
  96772. export var vrDistortionCorrectionPixelShader: {
  96773. name: string;
  96774. shader: string;
  96775. };
  96776. }
  96777. declare module BABYLON {
  96778. /**
  96779. * VRDistortionCorrectionPostProcess used for mobile VR
  96780. */
  96781. export class VRDistortionCorrectionPostProcess extends PostProcess {
  96782. private _isRightEye;
  96783. private _distortionFactors;
  96784. private _postProcessScaleFactor;
  96785. private _lensCenterOffset;
  96786. private _scaleIn;
  96787. private _scaleFactor;
  96788. private _lensCenter;
  96789. /**
  96790. * Initializes the VRDistortionCorrectionPostProcess
  96791. * @param name The name of the effect.
  96792. * @param camera The camera to apply the render pass to.
  96793. * @param isRightEye If this is for the right eye distortion
  96794. * @param vrMetrics All the required metrics for the VR camera
  96795. */
  96796. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  96797. }
  96798. }
  96799. declare module BABYLON {
  96800. /**
  96801. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  96802. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96803. */
  96804. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  96805. /**
  96806. * Creates a new VRDeviceOrientationArcRotateCamera
  96807. * @param name defines camera name
  96808. * @param alpha defines the camera rotation along the logitudinal axis
  96809. * @param beta defines the camera rotation along the latitudinal axis
  96810. * @param radius defines the camera distance from its target
  96811. * @param target defines the camera target
  96812. * @param scene defines the scene the camera belongs to
  96813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96815. */
  96816. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96817. /**
  96818. * Gets camera class name
  96819. * @returns VRDeviceOrientationArcRotateCamera
  96820. */
  96821. getClassName(): string;
  96822. }
  96823. }
  96824. declare module BABYLON {
  96825. /**
  96826. * Camera used to simulate VR rendering (based on FreeCamera)
  96827. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96828. */
  96829. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96830. /**
  96831. * Creates a new VRDeviceOrientationFreeCamera
  96832. * @param name defines camera name
  96833. * @param position defines the start position of the camera
  96834. * @param scene defines the scene the camera belongs to
  96835. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96836. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96837. */
  96838. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96839. /**
  96840. * Gets camera class name
  96841. * @returns VRDeviceOrientationFreeCamera
  96842. */
  96843. getClassName(): string;
  96844. }
  96845. }
  96846. declare module BABYLON {
  96847. /**
  96848. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96849. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96850. */
  96851. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96852. /**
  96853. * Creates a new VRDeviceOrientationGamepadCamera
  96854. * @param name defines camera name
  96855. * @param position defines the start position of the camera
  96856. * @param scene defines the scene the camera belongs to
  96857. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96858. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96859. */
  96860. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96861. /**
  96862. * Gets camera class name
  96863. * @returns VRDeviceOrientationGamepadCamera
  96864. */
  96865. getClassName(): string;
  96866. }
  96867. }
  96868. declare module BABYLON {
  96869. /**
  96870. * Defines supported buttons for XBox360 compatible gamepads
  96871. */
  96872. export enum Xbox360Button {
  96873. /** A */
  96874. A = 0,
  96875. /** B */
  96876. B = 1,
  96877. /** X */
  96878. X = 2,
  96879. /** Y */
  96880. Y = 3,
  96881. /** Start */
  96882. Start = 4,
  96883. /** Back */
  96884. Back = 5,
  96885. /** Left button */
  96886. LB = 6,
  96887. /** Right button */
  96888. RB = 7,
  96889. /** Left stick */
  96890. LeftStick = 8,
  96891. /** Right stick */
  96892. RightStick = 9
  96893. }
  96894. /** Defines values for XBox360 DPad */
  96895. export enum Xbox360Dpad {
  96896. /** Up */
  96897. Up = 0,
  96898. /** Down */
  96899. Down = 1,
  96900. /** Left */
  96901. Left = 2,
  96902. /** Right */
  96903. Right = 3
  96904. }
  96905. /**
  96906. * Defines a XBox360 gamepad
  96907. */
  96908. export class Xbox360Pad extends Gamepad {
  96909. private _leftTrigger;
  96910. private _rightTrigger;
  96911. private _onlefttriggerchanged;
  96912. private _onrighttriggerchanged;
  96913. private _onbuttondown;
  96914. private _onbuttonup;
  96915. private _ondpaddown;
  96916. private _ondpadup;
  96917. /** Observable raised when a button is pressed */
  96918. onButtonDownObservable: Observable<Xbox360Button>;
  96919. /** Observable raised when a button is released */
  96920. onButtonUpObservable: Observable<Xbox360Button>;
  96921. /** Observable raised when a pad is pressed */
  96922. onPadDownObservable: Observable<Xbox360Dpad>;
  96923. /** Observable raised when a pad is released */
  96924. onPadUpObservable: Observable<Xbox360Dpad>;
  96925. private _buttonA;
  96926. private _buttonB;
  96927. private _buttonX;
  96928. private _buttonY;
  96929. private _buttonBack;
  96930. private _buttonStart;
  96931. private _buttonLB;
  96932. private _buttonRB;
  96933. private _buttonLeftStick;
  96934. private _buttonRightStick;
  96935. private _dPadUp;
  96936. private _dPadDown;
  96937. private _dPadLeft;
  96938. private _dPadRight;
  96939. private _isXboxOnePad;
  96940. /**
  96941. * Creates a new XBox360 gamepad object
  96942. * @param id defines the id of this gamepad
  96943. * @param index defines its index
  96944. * @param gamepad defines the internal HTML gamepad object
  96945. * @param xboxOne defines if it is a XBox One gamepad
  96946. */
  96947. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96948. /**
  96949. * Defines the callback to call when left trigger is pressed
  96950. * @param callback defines the callback to use
  96951. */
  96952. onlefttriggerchanged(callback: (value: number) => void): void;
  96953. /**
  96954. * Defines the callback to call when right trigger is pressed
  96955. * @param callback defines the callback to use
  96956. */
  96957. onrighttriggerchanged(callback: (value: number) => void): void;
  96958. /**
  96959. * Gets the left trigger value
  96960. */
  96961. /**
  96962. * Sets the left trigger value
  96963. */
  96964. leftTrigger: number;
  96965. /**
  96966. * Gets the right trigger value
  96967. */
  96968. /**
  96969. * Sets the right trigger value
  96970. */
  96971. rightTrigger: number;
  96972. /**
  96973. * Defines the callback to call when a button is pressed
  96974. * @param callback defines the callback to use
  96975. */
  96976. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96977. /**
  96978. * Defines the callback to call when a button is released
  96979. * @param callback defines the callback to use
  96980. */
  96981. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96982. /**
  96983. * Defines the callback to call when a pad is pressed
  96984. * @param callback defines the callback to use
  96985. */
  96986. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96987. /**
  96988. * Defines the callback to call when a pad is released
  96989. * @param callback defines the callback to use
  96990. */
  96991. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96992. private _setButtonValue;
  96993. private _setDPadValue;
  96994. /**
  96995. * Gets the value of the `A` button
  96996. */
  96997. /**
  96998. * Sets the value of the `A` button
  96999. */
  97000. buttonA: number;
  97001. /**
  97002. * Gets the value of the `B` button
  97003. */
  97004. /**
  97005. * Sets the value of the `B` button
  97006. */
  97007. buttonB: number;
  97008. /**
  97009. * Gets the value of the `X` button
  97010. */
  97011. /**
  97012. * Sets the value of the `X` button
  97013. */
  97014. buttonX: number;
  97015. /**
  97016. * Gets the value of the `Y` button
  97017. */
  97018. /**
  97019. * Sets the value of the `Y` button
  97020. */
  97021. buttonY: number;
  97022. /**
  97023. * Gets the value of the `Start` button
  97024. */
  97025. /**
  97026. * Sets the value of the `Start` button
  97027. */
  97028. buttonStart: number;
  97029. /**
  97030. * Gets the value of the `Back` button
  97031. */
  97032. /**
  97033. * Sets the value of the `Back` button
  97034. */
  97035. buttonBack: number;
  97036. /**
  97037. * Gets the value of the `Left` button
  97038. */
  97039. /**
  97040. * Sets the value of the `Left` button
  97041. */
  97042. buttonLB: number;
  97043. /**
  97044. * Gets the value of the `Right` button
  97045. */
  97046. /**
  97047. * Sets the value of the `Right` button
  97048. */
  97049. buttonRB: number;
  97050. /**
  97051. * Gets the value of the Left joystick
  97052. */
  97053. /**
  97054. * Sets the value of the Left joystick
  97055. */
  97056. buttonLeftStick: number;
  97057. /**
  97058. * Gets the value of the Right joystick
  97059. */
  97060. /**
  97061. * Sets the value of the Right joystick
  97062. */
  97063. buttonRightStick: number;
  97064. /**
  97065. * Gets the value of D-pad up
  97066. */
  97067. /**
  97068. * Sets the value of D-pad up
  97069. */
  97070. dPadUp: number;
  97071. /**
  97072. * Gets the value of D-pad down
  97073. */
  97074. /**
  97075. * Sets the value of D-pad down
  97076. */
  97077. dPadDown: number;
  97078. /**
  97079. * Gets the value of D-pad left
  97080. */
  97081. /**
  97082. * Sets the value of D-pad left
  97083. */
  97084. dPadLeft: number;
  97085. /**
  97086. * Gets the value of D-pad right
  97087. */
  97088. /**
  97089. * Sets the value of D-pad right
  97090. */
  97091. dPadRight: number;
  97092. /**
  97093. * Force the gamepad to synchronize with device values
  97094. */
  97095. update(): void;
  97096. /**
  97097. * Disposes the gamepad
  97098. */
  97099. dispose(): void;
  97100. }
  97101. }
  97102. declare module BABYLON {
  97103. /**
  97104. * Base class of materials working in push mode in babylon JS
  97105. * @hidden
  97106. */
  97107. export class PushMaterial extends Material {
  97108. protected _activeEffect: Effect;
  97109. protected _normalMatrix: Matrix;
  97110. /**
  97111. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97112. * This means that the material can keep using a previous shader while a new one is being compiled.
  97113. * This is mostly used when shader parallel compilation is supported (true by default)
  97114. */
  97115. allowShaderHotSwapping: boolean;
  97116. constructor(name: string, scene: Scene);
  97117. getEffect(): Effect;
  97118. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97119. /**
  97120. * Binds the given world matrix to the active effect
  97121. *
  97122. * @param world the matrix to bind
  97123. */
  97124. bindOnlyWorldMatrix(world: Matrix): void;
  97125. /**
  97126. * Binds the given normal matrix to the active effect
  97127. *
  97128. * @param normalMatrix the matrix to bind
  97129. */
  97130. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97131. bind(world: Matrix, mesh?: Mesh): void;
  97132. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97133. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97134. }
  97135. }
  97136. declare module BABYLON {
  97137. /**
  97138. * This groups all the flags used to control the materials channel.
  97139. */
  97140. export class MaterialFlags {
  97141. private static _DiffuseTextureEnabled;
  97142. /**
  97143. * Are diffuse textures enabled in the application.
  97144. */
  97145. static DiffuseTextureEnabled: boolean;
  97146. private static _AmbientTextureEnabled;
  97147. /**
  97148. * Are ambient textures enabled in the application.
  97149. */
  97150. static AmbientTextureEnabled: boolean;
  97151. private static _OpacityTextureEnabled;
  97152. /**
  97153. * Are opacity textures enabled in the application.
  97154. */
  97155. static OpacityTextureEnabled: boolean;
  97156. private static _ReflectionTextureEnabled;
  97157. /**
  97158. * Are reflection textures enabled in the application.
  97159. */
  97160. static ReflectionTextureEnabled: boolean;
  97161. private static _EmissiveTextureEnabled;
  97162. /**
  97163. * Are emissive textures enabled in the application.
  97164. */
  97165. static EmissiveTextureEnabled: boolean;
  97166. private static _SpecularTextureEnabled;
  97167. /**
  97168. * Are specular textures enabled in the application.
  97169. */
  97170. static SpecularTextureEnabled: boolean;
  97171. private static _BumpTextureEnabled;
  97172. /**
  97173. * Are bump textures enabled in the application.
  97174. */
  97175. static BumpTextureEnabled: boolean;
  97176. private static _LightmapTextureEnabled;
  97177. /**
  97178. * Are lightmap textures enabled in the application.
  97179. */
  97180. static LightmapTextureEnabled: boolean;
  97181. private static _RefractionTextureEnabled;
  97182. /**
  97183. * Are refraction textures enabled in the application.
  97184. */
  97185. static RefractionTextureEnabled: boolean;
  97186. private static _ColorGradingTextureEnabled;
  97187. /**
  97188. * Are color grading textures enabled in the application.
  97189. */
  97190. static ColorGradingTextureEnabled: boolean;
  97191. private static _FresnelEnabled;
  97192. /**
  97193. * Are fresnels enabled in the application.
  97194. */
  97195. static FresnelEnabled: boolean;
  97196. private static _ClearCoatTextureEnabled;
  97197. /**
  97198. * Are clear coat textures enabled in the application.
  97199. */
  97200. static ClearCoatTextureEnabled: boolean;
  97201. private static _ClearCoatBumpTextureEnabled;
  97202. /**
  97203. * Are clear coat bump textures enabled in the application.
  97204. */
  97205. static ClearCoatBumpTextureEnabled: boolean;
  97206. private static _ClearCoatTintTextureEnabled;
  97207. /**
  97208. * Are clear coat tint textures enabled in the application.
  97209. */
  97210. static ClearCoatTintTextureEnabled: boolean;
  97211. private static _SheenTextureEnabled;
  97212. /**
  97213. * Are sheen textures enabled in the application.
  97214. */
  97215. static SheenTextureEnabled: boolean;
  97216. private static _AnisotropicTextureEnabled;
  97217. /**
  97218. * Are anisotropic textures enabled in the application.
  97219. */
  97220. static AnisotropicTextureEnabled: boolean;
  97221. }
  97222. }
  97223. declare module BABYLON {
  97224. /** @hidden */
  97225. export var defaultFragmentDeclaration: {
  97226. name: string;
  97227. shader: string;
  97228. };
  97229. }
  97230. declare module BABYLON {
  97231. /** @hidden */
  97232. export var defaultUboDeclaration: {
  97233. name: string;
  97234. shader: string;
  97235. };
  97236. }
  97237. declare module BABYLON {
  97238. /** @hidden */
  97239. export var lightFragmentDeclaration: {
  97240. name: string;
  97241. shader: string;
  97242. };
  97243. }
  97244. declare module BABYLON {
  97245. /** @hidden */
  97246. export var lightUboDeclaration: {
  97247. name: string;
  97248. shader: string;
  97249. };
  97250. }
  97251. declare module BABYLON {
  97252. /** @hidden */
  97253. export var lightsFragmentFunctions: {
  97254. name: string;
  97255. shader: string;
  97256. };
  97257. }
  97258. declare module BABYLON {
  97259. /** @hidden */
  97260. export var shadowsFragmentFunctions: {
  97261. name: string;
  97262. shader: string;
  97263. };
  97264. }
  97265. declare module BABYLON {
  97266. /** @hidden */
  97267. export var fresnelFunction: {
  97268. name: string;
  97269. shader: string;
  97270. };
  97271. }
  97272. declare module BABYLON {
  97273. /** @hidden */
  97274. export var reflectionFunction: {
  97275. name: string;
  97276. shader: string;
  97277. };
  97278. }
  97279. declare module BABYLON {
  97280. /** @hidden */
  97281. export var bumpFragmentFunctions: {
  97282. name: string;
  97283. shader: string;
  97284. };
  97285. }
  97286. declare module BABYLON {
  97287. /** @hidden */
  97288. export var logDepthDeclaration: {
  97289. name: string;
  97290. shader: string;
  97291. };
  97292. }
  97293. declare module BABYLON {
  97294. /** @hidden */
  97295. export var bumpFragment: {
  97296. name: string;
  97297. shader: string;
  97298. };
  97299. }
  97300. declare module BABYLON {
  97301. /** @hidden */
  97302. export var depthPrePass: {
  97303. name: string;
  97304. shader: string;
  97305. };
  97306. }
  97307. declare module BABYLON {
  97308. /** @hidden */
  97309. export var lightFragment: {
  97310. name: string;
  97311. shader: string;
  97312. };
  97313. }
  97314. declare module BABYLON {
  97315. /** @hidden */
  97316. export var logDepthFragment: {
  97317. name: string;
  97318. shader: string;
  97319. };
  97320. }
  97321. declare module BABYLON {
  97322. /** @hidden */
  97323. export var defaultPixelShader: {
  97324. name: string;
  97325. shader: string;
  97326. };
  97327. }
  97328. declare module BABYLON {
  97329. /** @hidden */
  97330. export var defaultVertexDeclaration: {
  97331. name: string;
  97332. shader: string;
  97333. };
  97334. }
  97335. declare module BABYLON {
  97336. /** @hidden */
  97337. export var bumpVertexDeclaration: {
  97338. name: string;
  97339. shader: string;
  97340. };
  97341. }
  97342. declare module BABYLON {
  97343. /** @hidden */
  97344. export var bumpVertex: {
  97345. name: string;
  97346. shader: string;
  97347. };
  97348. }
  97349. declare module BABYLON {
  97350. /** @hidden */
  97351. export var fogVertex: {
  97352. name: string;
  97353. shader: string;
  97354. };
  97355. }
  97356. declare module BABYLON {
  97357. /** @hidden */
  97358. export var shadowsVertex: {
  97359. name: string;
  97360. shader: string;
  97361. };
  97362. }
  97363. declare module BABYLON {
  97364. /** @hidden */
  97365. export var pointCloudVertex: {
  97366. name: string;
  97367. shader: string;
  97368. };
  97369. }
  97370. declare module BABYLON {
  97371. /** @hidden */
  97372. export var logDepthVertex: {
  97373. name: string;
  97374. shader: string;
  97375. };
  97376. }
  97377. declare module BABYLON {
  97378. /** @hidden */
  97379. export var defaultVertexShader: {
  97380. name: string;
  97381. shader: string;
  97382. };
  97383. }
  97384. declare module BABYLON {
  97385. /** @hidden */
  97386. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97387. MAINUV1: boolean;
  97388. MAINUV2: boolean;
  97389. DIFFUSE: boolean;
  97390. DIFFUSEDIRECTUV: number;
  97391. AMBIENT: boolean;
  97392. AMBIENTDIRECTUV: number;
  97393. OPACITY: boolean;
  97394. OPACITYDIRECTUV: number;
  97395. OPACITYRGB: boolean;
  97396. REFLECTION: boolean;
  97397. EMISSIVE: boolean;
  97398. EMISSIVEDIRECTUV: number;
  97399. SPECULAR: boolean;
  97400. SPECULARDIRECTUV: number;
  97401. BUMP: boolean;
  97402. BUMPDIRECTUV: number;
  97403. PARALLAX: boolean;
  97404. PARALLAXOCCLUSION: boolean;
  97405. SPECULAROVERALPHA: boolean;
  97406. CLIPPLANE: boolean;
  97407. CLIPPLANE2: boolean;
  97408. CLIPPLANE3: boolean;
  97409. CLIPPLANE4: boolean;
  97410. ALPHATEST: boolean;
  97411. DEPTHPREPASS: boolean;
  97412. ALPHAFROMDIFFUSE: boolean;
  97413. POINTSIZE: boolean;
  97414. FOG: boolean;
  97415. SPECULARTERM: boolean;
  97416. DIFFUSEFRESNEL: boolean;
  97417. OPACITYFRESNEL: boolean;
  97418. REFLECTIONFRESNEL: boolean;
  97419. REFRACTIONFRESNEL: boolean;
  97420. EMISSIVEFRESNEL: boolean;
  97421. FRESNEL: boolean;
  97422. NORMAL: boolean;
  97423. UV1: boolean;
  97424. UV2: boolean;
  97425. VERTEXCOLOR: boolean;
  97426. VERTEXALPHA: boolean;
  97427. NUM_BONE_INFLUENCERS: number;
  97428. BonesPerMesh: number;
  97429. BONETEXTURE: boolean;
  97430. INSTANCES: boolean;
  97431. GLOSSINESS: boolean;
  97432. ROUGHNESS: boolean;
  97433. EMISSIVEASILLUMINATION: boolean;
  97434. LINKEMISSIVEWITHDIFFUSE: boolean;
  97435. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97436. LIGHTMAP: boolean;
  97437. LIGHTMAPDIRECTUV: number;
  97438. OBJECTSPACE_NORMALMAP: boolean;
  97439. USELIGHTMAPASSHADOWMAP: boolean;
  97440. REFLECTIONMAP_3D: boolean;
  97441. REFLECTIONMAP_SPHERICAL: boolean;
  97442. REFLECTIONMAP_PLANAR: boolean;
  97443. REFLECTIONMAP_CUBIC: boolean;
  97444. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97445. REFLECTIONMAP_PROJECTION: boolean;
  97446. REFLECTIONMAP_SKYBOX: boolean;
  97447. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97448. REFLECTIONMAP_EXPLICIT: boolean;
  97449. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97450. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97451. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97452. INVERTCUBICMAP: boolean;
  97453. LOGARITHMICDEPTH: boolean;
  97454. REFRACTION: boolean;
  97455. REFRACTIONMAP_3D: boolean;
  97456. REFLECTIONOVERALPHA: boolean;
  97457. TWOSIDEDLIGHTING: boolean;
  97458. SHADOWFLOAT: boolean;
  97459. MORPHTARGETS: boolean;
  97460. MORPHTARGETS_NORMAL: boolean;
  97461. MORPHTARGETS_TANGENT: boolean;
  97462. NUM_MORPH_INFLUENCERS: number;
  97463. NONUNIFORMSCALING: boolean;
  97464. PREMULTIPLYALPHA: boolean;
  97465. IMAGEPROCESSING: boolean;
  97466. VIGNETTE: boolean;
  97467. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97468. VIGNETTEBLENDMODEOPAQUE: boolean;
  97469. TONEMAPPING: boolean;
  97470. TONEMAPPING_ACES: boolean;
  97471. CONTRAST: boolean;
  97472. COLORCURVES: boolean;
  97473. COLORGRADING: boolean;
  97474. COLORGRADING3D: boolean;
  97475. SAMPLER3DGREENDEPTH: boolean;
  97476. SAMPLER3DBGRMAP: boolean;
  97477. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97478. MULTIVIEW: boolean;
  97479. /**
  97480. * If the reflection texture on this material is in linear color space
  97481. * @hidden
  97482. */
  97483. IS_REFLECTION_LINEAR: boolean;
  97484. /**
  97485. * If the refraction texture on this material is in linear color space
  97486. * @hidden
  97487. */
  97488. IS_REFRACTION_LINEAR: boolean;
  97489. EXPOSURE: boolean;
  97490. constructor();
  97491. setReflectionMode(modeToEnable: string): void;
  97492. }
  97493. /**
  97494. * This is the default material used in Babylon. It is the best trade off between quality
  97495. * and performances.
  97496. * @see http://doc.babylonjs.com/babylon101/materials
  97497. */
  97498. export class StandardMaterial extends PushMaterial {
  97499. private _diffuseTexture;
  97500. /**
  97501. * The basic texture of the material as viewed under a light.
  97502. */
  97503. diffuseTexture: Nullable<BaseTexture>;
  97504. private _ambientTexture;
  97505. /**
  97506. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97507. */
  97508. ambientTexture: Nullable<BaseTexture>;
  97509. private _opacityTexture;
  97510. /**
  97511. * Define the transparency of the material from a texture.
  97512. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97513. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97514. */
  97515. opacityTexture: Nullable<BaseTexture>;
  97516. private _reflectionTexture;
  97517. /**
  97518. * Define the texture used to display the reflection.
  97519. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97520. */
  97521. reflectionTexture: Nullable<BaseTexture>;
  97522. private _emissiveTexture;
  97523. /**
  97524. * Define texture of the material as if self lit.
  97525. * This will be mixed in the final result even in the absence of light.
  97526. */
  97527. emissiveTexture: Nullable<BaseTexture>;
  97528. private _specularTexture;
  97529. /**
  97530. * Define how the color and intensity of the highlight given by the light in the material.
  97531. */
  97532. specularTexture: Nullable<BaseTexture>;
  97533. private _bumpTexture;
  97534. /**
  97535. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97536. * 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.
  97537. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97538. */
  97539. bumpTexture: Nullable<BaseTexture>;
  97540. private _lightmapTexture;
  97541. /**
  97542. * Complex lighting can be computationally expensive to compute at runtime.
  97543. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97544. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97545. */
  97546. lightmapTexture: Nullable<BaseTexture>;
  97547. private _refractionTexture;
  97548. /**
  97549. * Define the texture used to display the refraction.
  97550. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97551. */
  97552. refractionTexture: Nullable<BaseTexture>;
  97553. /**
  97554. * The color of the material lit by the environmental background lighting.
  97555. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97556. */
  97557. ambientColor: Color3;
  97558. /**
  97559. * The basic color of the material as viewed under a light.
  97560. */
  97561. diffuseColor: Color3;
  97562. /**
  97563. * Define how the color and intensity of the highlight given by the light in the material.
  97564. */
  97565. specularColor: Color3;
  97566. /**
  97567. * Define the color of the material as if self lit.
  97568. * This will be mixed in the final result even in the absence of light.
  97569. */
  97570. emissiveColor: Color3;
  97571. /**
  97572. * Defines how sharp are the highlights in the material.
  97573. * The bigger the value the sharper giving a more glossy feeling to the result.
  97574. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97575. */
  97576. specularPower: number;
  97577. private _useAlphaFromDiffuseTexture;
  97578. /**
  97579. * Does the transparency come from the diffuse texture alpha channel.
  97580. */
  97581. useAlphaFromDiffuseTexture: boolean;
  97582. private _useEmissiveAsIllumination;
  97583. /**
  97584. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97585. */
  97586. useEmissiveAsIllumination: boolean;
  97587. private _linkEmissiveWithDiffuse;
  97588. /**
  97589. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97590. * the emissive level when the final color is close to one.
  97591. */
  97592. linkEmissiveWithDiffuse: boolean;
  97593. private _useSpecularOverAlpha;
  97594. /**
  97595. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97596. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97597. */
  97598. useSpecularOverAlpha: boolean;
  97599. private _useReflectionOverAlpha;
  97600. /**
  97601. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97602. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97603. */
  97604. useReflectionOverAlpha: boolean;
  97605. private _disableLighting;
  97606. /**
  97607. * Does lights from the scene impacts this material.
  97608. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97609. */
  97610. disableLighting: boolean;
  97611. private _useObjectSpaceNormalMap;
  97612. /**
  97613. * Allows using an object space normal map (instead of tangent space).
  97614. */
  97615. useObjectSpaceNormalMap: boolean;
  97616. private _useParallax;
  97617. /**
  97618. * Is parallax enabled or not.
  97619. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97620. */
  97621. useParallax: boolean;
  97622. private _useParallaxOcclusion;
  97623. /**
  97624. * Is parallax occlusion enabled or not.
  97625. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97626. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97627. */
  97628. useParallaxOcclusion: boolean;
  97629. /**
  97630. * 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.
  97631. */
  97632. parallaxScaleBias: number;
  97633. private _roughness;
  97634. /**
  97635. * Helps to define how blurry the reflections should appears in the material.
  97636. */
  97637. roughness: number;
  97638. /**
  97639. * In case of refraction, define the value of the indice of refraction.
  97640. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97641. */
  97642. indexOfRefraction: number;
  97643. /**
  97644. * Invert the refraction texture alongside the y axis.
  97645. * It can be useful with procedural textures or probe for instance.
  97646. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97647. */
  97648. invertRefractionY: boolean;
  97649. /**
  97650. * Defines the alpha limits in alpha test mode.
  97651. */
  97652. alphaCutOff: number;
  97653. private _useLightmapAsShadowmap;
  97654. /**
  97655. * In case of light mapping, define whether the map contains light or shadow informations.
  97656. */
  97657. useLightmapAsShadowmap: boolean;
  97658. private _diffuseFresnelParameters;
  97659. /**
  97660. * Define the diffuse fresnel parameters of the material.
  97661. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97662. */
  97663. diffuseFresnelParameters: FresnelParameters;
  97664. private _opacityFresnelParameters;
  97665. /**
  97666. * Define the opacity fresnel parameters of the material.
  97667. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97668. */
  97669. opacityFresnelParameters: FresnelParameters;
  97670. private _reflectionFresnelParameters;
  97671. /**
  97672. * Define the reflection fresnel parameters of the material.
  97673. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97674. */
  97675. reflectionFresnelParameters: FresnelParameters;
  97676. private _refractionFresnelParameters;
  97677. /**
  97678. * Define the refraction fresnel parameters of the material.
  97679. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97680. */
  97681. refractionFresnelParameters: FresnelParameters;
  97682. private _emissiveFresnelParameters;
  97683. /**
  97684. * Define the emissive fresnel parameters of the material.
  97685. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97686. */
  97687. emissiveFresnelParameters: FresnelParameters;
  97688. private _useReflectionFresnelFromSpecular;
  97689. /**
  97690. * If true automatically deducts the fresnels values from the material specularity.
  97691. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97692. */
  97693. useReflectionFresnelFromSpecular: boolean;
  97694. private _useGlossinessFromSpecularMapAlpha;
  97695. /**
  97696. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97697. */
  97698. useGlossinessFromSpecularMapAlpha: boolean;
  97699. private _maxSimultaneousLights;
  97700. /**
  97701. * Defines the maximum number of lights that can be used in the material
  97702. */
  97703. maxSimultaneousLights: number;
  97704. private _invertNormalMapX;
  97705. /**
  97706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97707. */
  97708. invertNormalMapX: boolean;
  97709. private _invertNormalMapY;
  97710. /**
  97711. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97712. */
  97713. invertNormalMapY: boolean;
  97714. private _twoSidedLighting;
  97715. /**
  97716. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97717. */
  97718. twoSidedLighting: boolean;
  97719. /**
  97720. * Default configuration related to image processing available in the standard Material.
  97721. */
  97722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97723. /**
  97724. * Gets the image processing configuration used either in this material.
  97725. */
  97726. /**
  97727. * Sets the Default image processing configuration used either in the this material.
  97728. *
  97729. * If sets to null, the scene one is in use.
  97730. */
  97731. imageProcessingConfiguration: ImageProcessingConfiguration;
  97732. /**
  97733. * Keep track of the image processing observer to allow dispose and replace.
  97734. */
  97735. private _imageProcessingObserver;
  97736. /**
  97737. * Attaches a new image processing configuration to the Standard Material.
  97738. * @param configuration
  97739. */
  97740. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97741. /**
  97742. * Gets wether the color curves effect is enabled.
  97743. */
  97744. /**
  97745. * Sets wether the color curves effect is enabled.
  97746. */
  97747. cameraColorCurvesEnabled: boolean;
  97748. /**
  97749. * Gets wether the color grading effect is enabled.
  97750. */
  97751. /**
  97752. * Gets wether the color grading effect is enabled.
  97753. */
  97754. cameraColorGradingEnabled: boolean;
  97755. /**
  97756. * Gets wether tonemapping is enabled or not.
  97757. */
  97758. /**
  97759. * Sets wether tonemapping is enabled or not
  97760. */
  97761. cameraToneMappingEnabled: boolean;
  97762. /**
  97763. * The camera exposure used on this material.
  97764. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97765. * This corresponds to a photographic exposure.
  97766. */
  97767. /**
  97768. * The camera exposure used on this material.
  97769. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97770. * This corresponds to a photographic exposure.
  97771. */
  97772. cameraExposure: number;
  97773. /**
  97774. * Gets The camera contrast used on this material.
  97775. */
  97776. /**
  97777. * Sets The camera contrast used on this material.
  97778. */
  97779. cameraContrast: number;
  97780. /**
  97781. * Gets the Color Grading 2D Lookup Texture.
  97782. */
  97783. /**
  97784. * Sets the Color Grading 2D Lookup Texture.
  97785. */
  97786. cameraColorGradingTexture: Nullable<BaseTexture>;
  97787. /**
  97788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97790. * 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;
  97791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97792. */
  97793. /**
  97794. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97795. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97796. * 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;
  97797. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97798. */
  97799. cameraColorCurves: Nullable<ColorCurves>;
  97800. /**
  97801. * Custom callback helping to override the default shader used in the material.
  97802. */
  97803. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97804. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97805. protected _worldViewProjectionMatrix: Matrix;
  97806. protected _globalAmbientColor: Color3;
  97807. protected _useLogarithmicDepth: boolean;
  97808. /**
  97809. * Instantiates a new standard material.
  97810. * This is the default material used in Babylon. It is the best trade off between quality
  97811. * and performances.
  97812. * @see http://doc.babylonjs.com/babylon101/materials
  97813. * @param name Define the name of the material in the scene
  97814. * @param scene Define the scene the material belong to
  97815. */
  97816. constructor(name: string, scene: Scene);
  97817. /**
  97818. * Gets a boolean indicating that current material needs to register RTT
  97819. */
  97820. readonly hasRenderTargetTextures: boolean;
  97821. /**
  97822. * Gets the current class name of the material e.g. "StandardMaterial"
  97823. * Mainly use in serialization.
  97824. * @returns the class name
  97825. */
  97826. getClassName(): string;
  97827. /**
  97828. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97829. * You can try switching to logarithmic depth.
  97830. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97831. */
  97832. useLogarithmicDepth: boolean;
  97833. /**
  97834. * Specifies if the material will require alpha blending
  97835. * @returns a boolean specifying if alpha blending is needed
  97836. */
  97837. needAlphaBlending(): boolean;
  97838. /**
  97839. * Specifies if this material should be rendered in alpha test mode
  97840. * @returns a boolean specifying if an alpha test is needed.
  97841. */
  97842. needAlphaTesting(): boolean;
  97843. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97844. /**
  97845. * Get the texture used for alpha test purpose.
  97846. * @returns the diffuse texture in case of the standard material.
  97847. */
  97848. getAlphaTestTexture(): Nullable<BaseTexture>;
  97849. /**
  97850. * Get if the submesh is ready to be used and all its information available.
  97851. * Child classes can use it to update shaders
  97852. * @param mesh defines the mesh to check
  97853. * @param subMesh defines which submesh to check
  97854. * @param useInstances specifies that instances should be used
  97855. * @returns a boolean indicating that the submesh is ready or not
  97856. */
  97857. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97858. /**
  97859. * Builds the material UBO layouts.
  97860. * Used internally during the effect preparation.
  97861. */
  97862. buildUniformLayout(): void;
  97863. /**
  97864. * Unbinds the material from the mesh
  97865. */
  97866. unbind(): void;
  97867. /**
  97868. * Binds the submesh to this material by preparing the effect and shader to draw
  97869. * @param world defines the world transformation matrix
  97870. * @param mesh defines the mesh containing the submesh
  97871. * @param subMesh defines the submesh to bind the material to
  97872. */
  97873. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97874. /**
  97875. * Get the list of animatables in the material.
  97876. * @returns the list of animatables object used in the material
  97877. */
  97878. getAnimatables(): IAnimatable[];
  97879. /**
  97880. * Gets the active textures from the material
  97881. * @returns an array of textures
  97882. */
  97883. getActiveTextures(): BaseTexture[];
  97884. /**
  97885. * Specifies if the material uses a texture
  97886. * @param texture defines the texture to check against the material
  97887. * @returns a boolean specifying if the material uses the texture
  97888. */
  97889. hasTexture(texture: BaseTexture): boolean;
  97890. /**
  97891. * Disposes the material
  97892. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97893. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97894. */
  97895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97896. /**
  97897. * Makes a duplicate of the material, and gives it a new name
  97898. * @param name defines the new name for the duplicated material
  97899. * @returns the cloned material
  97900. */
  97901. clone(name: string): StandardMaterial;
  97902. /**
  97903. * Serializes this material in a JSON representation
  97904. * @returns the serialized material object
  97905. */
  97906. serialize(): any;
  97907. /**
  97908. * Creates a standard material from parsed material data
  97909. * @param source defines the JSON representation of the material
  97910. * @param scene defines the hosting scene
  97911. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97912. * @returns a new standard material
  97913. */
  97914. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97915. /**
  97916. * Are diffuse textures enabled in the application.
  97917. */
  97918. static DiffuseTextureEnabled: boolean;
  97919. /**
  97920. * Are ambient textures enabled in the application.
  97921. */
  97922. static AmbientTextureEnabled: boolean;
  97923. /**
  97924. * Are opacity textures enabled in the application.
  97925. */
  97926. static OpacityTextureEnabled: boolean;
  97927. /**
  97928. * Are reflection textures enabled in the application.
  97929. */
  97930. static ReflectionTextureEnabled: boolean;
  97931. /**
  97932. * Are emissive textures enabled in the application.
  97933. */
  97934. static EmissiveTextureEnabled: boolean;
  97935. /**
  97936. * Are specular textures enabled in the application.
  97937. */
  97938. static SpecularTextureEnabled: boolean;
  97939. /**
  97940. * Are bump textures enabled in the application.
  97941. */
  97942. static BumpTextureEnabled: boolean;
  97943. /**
  97944. * Are lightmap textures enabled in the application.
  97945. */
  97946. static LightmapTextureEnabled: boolean;
  97947. /**
  97948. * Are refraction textures enabled in the application.
  97949. */
  97950. static RefractionTextureEnabled: boolean;
  97951. /**
  97952. * Are color grading textures enabled in the application.
  97953. */
  97954. static ColorGradingTextureEnabled: boolean;
  97955. /**
  97956. * Are fresnels enabled in the application.
  97957. */
  97958. static FresnelEnabled: boolean;
  97959. }
  97960. }
  97961. declare module BABYLON {
  97962. /**
  97963. * A class extending Texture allowing drawing on a texture
  97964. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97965. */
  97966. export class DynamicTexture extends Texture {
  97967. private _generateMipMaps;
  97968. private _canvas;
  97969. private _context;
  97970. private _engine;
  97971. /**
  97972. * Creates a DynamicTexture
  97973. * @param name defines the name of the texture
  97974. * @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
  97975. * @param scene defines the scene where you want the texture
  97976. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97977. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97978. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97979. */
  97980. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97981. /**
  97982. * Get the current class name of the texture useful for serialization or dynamic coding.
  97983. * @returns "DynamicTexture"
  97984. */
  97985. getClassName(): string;
  97986. /**
  97987. * Gets the current state of canRescale
  97988. */
  97989. readonly canRescale: boolean;
  97990. private _recreate;
  97991. /**
  97992. * Scales the texture
  97993. * @param ratio the scale factor to apply to both width and height
  97994. */
  97995. scale(ratio: number): void;
  97996. /**
  97997. * Resizes the texture
  97998. * @param width the new width
  97999. * @param height the new height
  98000. */
  98001. scaleTo(width: number, height: number): void;
  98002. /**
  98003. * Gets the context of the canvas used by the texture
  98004. * @returns the canvas context of the dynamic texture
  98005. */
  98006. getContext(): CanvasRenderingContext2D;
  98007. /**
  98008. * Clears the texture
  98009. */
  98010. clear(): void;
  98011. /**
  98012. * Updates the texture
  98013. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98014. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98015. */
  98016. update(invertY?: boolean, premulAlpha?: boolean): void;
  98017. /**
  98018. * Draws text onto the texture
  98019. * @param text defines the text to be drawn
  98020. * @param x defines the placement of the text from the left
  98021. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98022. * @param font defines the font to be used with font-style, font-size, font-name
  98023. * @param color defines the color used for the text
  98024. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98025. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98026. * @param update defines whether texture is immediately update (default is true)
  98027. */
  98028. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98029. /**
  98030. * Clones the texture
  98031. * @returns the clone of the texture.
  98032. */
  98033. clone(): DynamicTexture;
  98034. /**
  98035. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98036. * @returns a serialized dynamic texture object
  98037. */
  98038. serialize(): any;
  98039. /** @hidden */
  98040. _rebuild(): void;
  98041. }
  98042. }
  98043. declare module BABYLON {
  98044. /** @hidden */
  98045. export var imageProcessingPixelShader: {
  98046. name: string;
  98047. shader: string;
  98048. };
  98049. }
  98050. declare module BABYLON {
  98051. /**
  98052. * ImageProcessingPostProcess
  98053. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98054. */
  98055. export class ImageProcessingPostProcess extends PostProcess {
  98056. /**
  98057. * Default configuration related to image processing available in the PBR Material.
  98058. */
  98059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98060. /**
  98061. * Gets the image processing configuration used either in this material.
  98062. */
  98063. /**
  98064. * Sets the Default image processing configuration used either in the this material.
  98065. *
  98066. * If sets to null, the scene one is in use.
  98067. */
  98068. imageProcessingConfiguration: ImageProcessingConfiguration;
  98069. /**
  98070. * Keep track of the image processing observer to allow dispose and replace.
  98071. */
  98072. private _imageProcessingObserver;
  98073. /**
  98074. * Attaches a new image processing configuration to the PBR Material.
  98075. * @param configuration
  98076. */
  98077. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98078. /**
  98079. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98080. */
  98081. /**
  98082. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98083. */
  98084. colorCurves: Nullable<ColorCurves>;
  98085. /**
  98086. * Gets wether the color curves effect is enabled.
  98087. */
  98088. /**
  98089. * Sets wether the color curves effect is enabled.
  98090. */
  98091. colorCurvesEnabled: boolean;
  98092. /**
  98093. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98094. */
  98095. /**
  98096. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98097. */
  98098. colorGradingTexture: Nullable<BaseTexture>;
  98099. /**
  98100. * Gets wether the color grading effect is enabled.
  98101. */
  98102. /**
  98103. * Gets wether the color grading effect is enabled.
  98104. */
  98105. colorGradingEnabled: boolean;
  98106. /**
  98107. * Gets exposure used in the effect.
  98108. */
  98109. /**
  98110. * Sets exposure used in the effect.
  98111. */
  98112. exposure: number;
  98113. /**
  98114. * Gets wether tonemapping is enabled or not.
  98115. */
  98116. /**
  98117. * Sets wether tonemapping is enabled or not
  98118. */
  98119. toneMappingEnabled: boolean;
  98120. /**
  98121. * Gets the type of tone mapping effect.
  98122. */
  98123. /**
  98124. * Sets the type of tone mapping effect.
  98125. */
  98126. toneMappingType: number;
  98127. /**
  98128. * Gets contrast used in the effect.
  98129. */
  98130. /**
  98131. * Sets contrast used in the effect.
  98132. */
  98133. contrast: number;
  98134. /**
  98135. * Gets Vignette stretch size.
  98136. */
  98137. /**
  98138. * Sets Vignette stretch size.
  98139. */
  98140. vignetteStretch: number;
  98141. /**
  98142. * Gets Vignette centre X Offset.
  98143. */
  98144. /**
  98145. * Sets Vignette centre X Offset.
  98146. */
  98147. vignetteCentreX: number;
  98148. /**
  98149. * Gets Vignette centre Y Offset.
  98150. */
  98151. /**
  98152. * Sets Vignette centre Y Offset.
  98153. */
  98154. vignetteCentreY: number;
  98155. /**
  98156. * Gets Vignette weight or intensity of the vignette effect.
  98157. */
  98158. /**
  98159. * Sets Vignette weight or intensity of the vignette effect.
  98160. */
  98161. vignetteWeight: number;
  98162. /**
  98163. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98164. * if vignetteEnabled is set to true.
  98165. */
  98166. /**
  98167. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98168. * if vignetteEnabled is set to true.
  98169. */
  98170. vignetteColor: Color4;
  98171. /**
  98172. * Gets Camera field of view used by the Vignette effect.
  98173. */
  98174. /**
  98175. * Sets Camera field of view used by the Vignette effect.
  98176. */
  98177. vignetteCameraFov: number;
  98178. /**
  98179. * Gets the vignette blend mode allowing different kind of effect.
  98180. */
  98181. /**
  98182. * Sets the vignette blend mode allowing different kind of effect.
  98183. */
  98184. vignetteBlendMode: number;
  98185. /**
  98186. * Gets wether the vignette effect is enabled.
  98187. */
  98188. /**
  98189. * Sets wether the vignette effect is enabled.
  98190. */
  98191. vignetteEnabled: boolean;
  98192. private _fromLinearSpace;
  98193. /**
  98194. * Gets wether the input of the processing is in Gamma or Linear Space.
  98195. */
  98196. /**
  98197. * Sets wether the input of the processing is in Gamma or Linear Space.
  98198. */
  98199. fromLinearSpace: boolean;
  98200. /**
  98201. * Defines cache preventing GC.
  98202. */
  98203. private _defines;
  98204. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98205. /**
  98206. * "ImageProcessingPostProcess"
  98207. * @returns "ImageProcessingPostProcess"
  98208. */
  98209. getClassName(): string;
  98210. protected _updateParameters(): void;
  98211. dispose(camera?: Camera): void;
  98212. }
  98213. }
  98214. declare module BABYLON {
  98215. /**
  98216. * Class containing static functions to help procedurally build meshes
  98217. */
  98218. export class GroundBuilder {
  98219. /**
  98220. * Creates a ground mesh
  98221. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98222. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98224. * @param name defines the name of the mesh
  98225. * @param options defines the options used to create the mesh
  98226. * @param scene defines the hosting scene
  98227. * @returns the ground mesh
  98228. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98229. */
  98230. static CreateGround(name: string, options: {
  98231. width?: number;
  98232. height?: number;
  98233. subdivisions?: number;
  98234. subdivisionsX?: number;
  98235. subdivisionsY?: number;
  98236. updatable?: boolean;
  98237. }, scene: any): Mesh;
  98238. /**
  98239. * Creates a tiled ground mesh
  98240. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98241. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98242. * * 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
  98243. * * 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
  98244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98245. * @param name defines the name of the mesh
  98246. * @param options defines the options used to create the mesh
  98247. * @param scene defines the hosting scene
  98248. * @returns the tiled ground mesh
  98249. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98250. */
  98251. static CreateTiledGround(name: string, options: {
  98252. xmin: number;
  98253. zmin: number;
  98254. xmax: number;
  98255. zmax: number;
  98256. subdivisions?: {
  98257. w: number;
  98258. h: number;
  98259. };
  98260. precision?: {
  98261. w: number;
  98262. h: number;
  98263. };
  98264. updatable?: boolean;
  98265. }, scene: Scene): Mesh;
  98266. /**
  98267. * Creates a ground mesh from a height map
  98268. * * The parameter `url` sets the URL of the height map image resource.
  98269. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98270. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98271. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98272. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98273. * * 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.
  98274. * * 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).
  98275. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98277. * @param name defines the name of the mesh
  98278. * @param url defines the url to the height map
  98279. * @param options defines the options used to create the mesh
  98280. * @param scene defines the hosting scene
  98281. * @returns the ground mesh
  98282. * @see https://doc.babylonjs.com/babylon101/height_map
  98283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98284. */
  98285. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98286. width?: number;
  98287. height?: number;
  98288. subdivisions?: number;
  98289. minHeight?: number;
  98290. maxHeight?: number;
  98291. colorFilter?: Color3;
  98292. alphaFilter?: number;
  98293. updatable?: boolean;
  98294. onReady?: (mesh: GroundMesh) => void;
  98295. }, scene: Scene): GroundMesh;
  98296. }
  98297. }
  98298. declare module BABYLON {
  98299. /**
  98300. * Class containing static functions to help procedurally build meshes
  98301. */
  98302. export class TorusBuilder {
  98303. /**
  98304. * Creates a torus mesh
  98305. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98306. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98307. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98311. * @param name defines the name of the mesh
  98312. * @param options defines the options used to create the mesh
  98313. * @param scene defines the hosting scene
  98314. * @returns the torus mesh
  98315. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98316. */
  98317. static CreateTorus(name: string, options: {
  98318. diameter?: number;
  98319. thickness?: number;
  98320. tessellation?: number;
  98321. updatable?: boolean;
  98322. sideOrientation?: number;
  98323. frontUVs?: Vector4;
  98324. backUVs?: Vector4;
  98325. }, scene: any): Mesh;
  98326. }
  98327. }
  98328. declare module BABYLON {
  98329. /**
  98330. * Class containing static functions to help procedurally build meshes
  98331. */
  98332. export class CylinderBuilder {
  98333. /**
  98334. * Creates a cylinder or a cone mesh
  98335. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98336. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98337. * * 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.
  98338. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98339. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98340. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98341. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98343. * * 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).
  98344. * * 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
  98345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98346. * * 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
  98347. * * 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.
  98348. * * If `enclose` is false, a ring surface is one element.
  98349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98350. * * 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
  98351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98354. * @param name defines the name of the mesh
  98355. * @param options defines the options used to create the mesh
  98356. * @param scene defines the hosting scene
  98357. * @returns the cylinder mesh
  98358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98359. */
  98360. static CreateCylinder(name: string, options: {
  98361. height?: number;
  98362. diameterTop?: number;
  98363. diameterBottom?: number;
  98364. diameter?: number;
  98365. tessellation?: number;
  98366. subdivisions?: number;
  98367. arc?: number;
  98368. faceColors?: Color4[];
  98369. faceUV?: Vector4[];
  98370. updatable?: boolean;
  98371. hasRings?: boolean;
  98372. enclose?: boolean;
  98373. sideOrientation?: number;
  98374. frontUVs?: Vector4;
  98375. backUVs?: Vector4;
  98376. }, scene: any): Mesh;
  98377. }
  98378. }
  98379. declare module BABYLON {
  98380. /**
  98381. * Manager for handling gamepads
  98382. */
  98383. export class GamepadManager {
  98384. private _scene?;
  98385. private _babylonGamepads;
  98386. private _oneGamepadConnected;
  98387. /** @hidden */
  98388. _isMonitoring: boolean;
  98389. private _gamepadEventSupported;
  98390. private _gamepadSupport;
  98391. /**
  98392. * observable to be triggered when the gamepad controller has been connected
  98393. */
  98394. onGamepadConnectedObservable: Observable<Gamepad>;
  98395. /**
  98396. * observable to be triggered when the gamepad controller has been disconnected
  98397. */
  98398. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98399. private _onGamepadConnectedEvent;
  98400. private _onGamepadDisconnectedEvent;
  98401. /**
  98402. * Initializes the gamepad manager
  98403. * @param _scene BabylonJS scene
  98404. */
  98405. constructor(_scene?: Scene | undefined);
  98406. /**
  98407. * The gamepads in the game pad manager
  98408. */
  98409. readonly gamepads: Gamepad[];
  98410. /**
  98411. * Get the gamepad controllers based on type
  98412. * @param type The type of gamepad controller
  98413. * @returns Nullable gamepad
  98414. */
  98415. getGamepadByType(type?: number): Nullable<Gamepad>;
  98416. /**
  98417. * Disposes the gamepad manager
  98418. */
  98419. dispose(): void;
  98420. private _addNewGamepad;
  98421. private _startMonitoringGamepads;
  98422. private _stopMonitoringGamepads;
  98423. /** @hidden */
  98424. _checkGamepadsStatus(): void;
  98425. private _updateGamepadObjects;
  98426. }
  98427. }
  98428. declare module BABYLON {
  98429. interface Scene {
  98430. /** @hidden */
  98431. _gamepadManager: Nullable<GamepadManager>;
  98432. /**
  98433. * Gets the gamepad manager associated with the scene
  98434. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98435. */
  98436. gamepadManager: GamepadManager;
  98437. }
  98438. /**
  98439. * Interface representing a free camera inputs manager
  98440. */
  98441. interface FreeCameraInputsManager {
  98442. /**
  98443. * Adds gamepad input support to the FreeCameraInputsManager.
  98444. * @returns the FreeCameraInputsManager
  98445. */
  98446. addGamepad(): FreeCameraInputsManager;
  98447. }
  98448. /**
  98449. * Interface representing an arc rotate camera inputs manager
  98450. */
  98451. interface ArcRotateCameraInputsManager {
  98452. /**
  98453. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98454. * @returns the camera inputs manager
  98455. */
  98456. addGamepad(): ArcRotateCameraInputsManager;
  98457. }
  98458. /**
  98459. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98460. */
  98461. export class GamepadSystemSceneComponent implements ISceneComponent {
  98462. /**
  98463. * The component name helpfull to identify the component in the list of scene components.
  98464. */
  98465. readonly name: string;
  98466. /**
  98467. * The scene the component belongs to.
  98468. */
  98469. scene: Scene;
  98470. /**
  98471. * Creates a new instance of the component for the given scene
  98472. * @param scene Defines the scene to register the component in
  98473. */
  98474. constructor(scene: Scene);
  98475. /**
  98476. * Registers the component in a given scene
  98477. */
  98478. register(): void;
  98479. /**
  98480. * Rebuilds the elements related to this component in case of
  98481. * context lost for instance.
  98482. */
  98483. rebuild(): void;
  98484. /**
  98485. * Disposes the component and the associated ressources
  98486. */
  98487. dispose(): void;
  98488. private _beforeCameraUpdate;
  98489. }
  98490. }
  98491. declare module BABYLON {
  98492. /**
  98493. * Options to modify the vr teleportation behavior.
  98494. */
  98495. export interface VRTeleportationOptions {
  98496. /**
  98497. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98498. */
  98499. floorMeshName?: string;
  98500. /**
  98501. * A list of meshes to be used as the teleportation floor. (default: empty)
  98502. */
  98503. floorMeshes?: Mesh[];
  98504. }
  98505. /**
  98506. * Options to modify the vr experience helper's behavior.
  98507. */
  98508. export interface VRExperienceHelperOptions extends WebVROptions {
  98509. /**
  98510. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98511. */
  98512. createDeviceOrientationCamera?: boolean;
  98513. /**
  98514. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98515. */
  98516. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98517. /**
  98518. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98519. */
  98520. laserToggle?: boolean;
  98521. /**
  98522. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98523. */
  98524. floorMeshes?: Mesh[];
  98525. /**
  98526. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98527. */
  98528. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98529. }
  98530. /**
  98531. * Event containing information after VR has been entered
  98532. */
  98533. export class OnAfterEnteringVRObservableEvent {
  98534. /**
  98535. * If entering vr was successful
  98536. */
  98537. success: boolean;
  98538. }
  98539. /**
  98540. * Helps to quickly add VR support to an existing scene.
  98541. * See http://doc.babylonjs.com/how_to/webvr_helper
  98542. */
  98543. export class VRExperienceHelper {
  98544. /** Options to modify the vr experience helper's behavior. */
  98545. webVROptions: VRExperienceHelperOptions;
  98546. private _scene;
  98547. private _position;
  98548. private _btnVR;
  98549. private _btnVRDisplayed;
  98550. private _webVRsupported;
  98551. private _webVRready;
  98552. private _webVRrequesting;
  98553. private _webVRpresenting;
  98554. private _hasEnteredVR;
  98555. private _fullscreenVRpresenting;
  98556. private _canvas;
  98557. private _webVRCamera;
  98558. private _vrDeviceOrientationCamera;
  98559. private _deviceOrientationCamera;
  98560. private _existingCamera;
  98561. private _onKeyDown;
  98562. private _onVrDisplayPresentChange;
  98563. private _onVRDisplayChanged;
  98564. private _onVRRequestPresentStart;
  98565. private _onVRRequestPresentComplete;
  98566. /**
  98567. * Observable raised right before entering VR.
  98568. */
  98569. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98570. /**
  98571. * Observable raised when entering VR has completed.
  98572. */
  98573. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98574. /**
  98575. * Observable raised when exiting VR.
  98576. */
  98577. onExitingVRObservable: Observable<VRExperienceHelper>;
  98578. /**
  98579. * Observable raised when controller mesh is loaded.
  98580. */
  98581. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98582. /** Return this.onEnteringVRObservable
  98583. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98584. */
  98585. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98586. /** Return this.onExitingVRObservable
  98587. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98588. */
  98589. readonly onExitingVR: Observable<VRExperienceHelper>;
  98590. /** Return this.onControllerMeshLoadedObservable
  98591. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98592. */
  98593. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98594. private _rayLength;
  98595. private _useCustomVRButton;
  98596. private _teleportationRequested;
  98597. private _teleportActive;
  98598. private _floorMeshName;
  98599. private _floorMeshesCollection;
  98600. private _rotationAllowed;
  98601. private _teleportBackwardsVector;
  98602. private _teleportationTarget;
  98603. private _isDefaultTeleportationTarget;
  98604. private _postProcessMove;
  98605. private _teleportationFillColor;
  98606. private _teleportationBorderColor;
  98607. private _rotationAngle;
  98608. private _haloCenter;
  98609. private _cameraGazer;
  98610. private _padSensibilityUp;
  98611. private _padSensibilityDown;
  98612. private _leftController;
  98613. private _rightController;
  98614. /**
  98615. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98616. */
  98617. onNewMeshSelected: Observable<AbstractMesh>;
  98618. /**
  98619. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98620. */
  98621. onNewMeshPicked: Observable<PickingInfo>;
  98622. private _circleEase;
  98623. /**
  98624. * Observable raised before camera teleportation
  98625. */
  98626. onBeforeCameraTeleport: Observable<Vector3>;
  98627. /**
  98628. * Observable raised after camera teleportation
  98629. */
  98630. onAfterCameraTeleport: Observable<Vector3>;
  98631. /**
  98632. * Observable raised when current selected mesh gets unselected
  98633. */
  98634. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98635. private _raySelectionPredicate;
  98636. /**
  98637. * To be optionaly changed by user to define custom ray selection
  98638. */
  98639. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98640. /**
  98641. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98642. */
  98643. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98644. /**
  98645. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98646. */
  98647. teleportationEnabled: boolean;
  98648. private _defaultHeight;
  98649. private _teleportationInitialized;
  98650. private _interactionsEnabled;
  98651. private _interactionsRequested;
  98652. private _displayGaze;
  98653. private _displayLaserPointer;
  98654. /**
  98655. * The mesh used to display where the user is going to teleport.
  98656. */
  98657. /**
  98658. * Sets the mesh to be used to display where the user is going to teleport.
  98659. */
  98660. teleportationTarget: Mesh;
  98661. /**
  98662. * 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
  98663. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98664. * See http://doc.babylonjs.com/resources/baking_transformations
  98665. */
  98666. gazeTrackerMesh: Mesh;
  98667. /**
  98668. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98669. */
  98670. updateGazeTrackerScale: boolean;
  98671. /**
  98672. * If the gaze trackers color should be updated when selecting meshes
  98673. */
  98674. updateGazeTrackerColor: boolean;
  98675. /**
  98676. * The gaze tracking mesh corresponding to the left controller
  98677. */
  98678. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98679. /**
  98680. * The gaze tracking mesh corresponding to the right controller
  98681. */
  98682. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98683. /**
  98684. * If the ray of the gaze should be displayed.
  98685. */
  98686. /**
  98687. * Sets if the ray of the gaze should be displayed.
  98688. */
  98689. displayGaze: boolean;
  98690. /**
  98691. * If the ray of the LaserPointer should be displayed.
  98692. */
  98693. /**
  98694. * Sets if the ray of the LaserPointer should be displayed.
  98695. */
  98696. displayLaserPointer: boolean;
  98697. /**
  98698. * The deviceOrientationCamera used as the camera when not in VR.
  98699. */
  98700. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98701. /**
  98702. * Based on the current WebVR support, returns the current VR camera used.
  98703. */
  98704. readonly currentVRCamera: Nullable<Camera>;
  98705. /**
  98706. * The webVRCamera which is used when in VR.
  98707. */
  98708. readonly webVRCamera: WebVRFreeCamera;
  98709. /**
  98710. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98711. */
  98712. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98713. private readonly _teleportationRequestInitiated;
  98714. /**
  98715. * Defines wether or not Pointer lock should be requested when switching to
  98716. * full screen.
  98717. */
  98718. requestPointerLockOnFullScreen: boolean;
  98719. /**
  98720. * Instantiates a VRExperienceHelper.
  98721. * Helps to quickly add VR support to an existing scene.
  98722. * @param scene The scene the VRExperienceHelper belongs to.
  98723. * @param webVROptions Options to modify the vr experience helper's behavior.
  98724. */
  98725. constructor(scene: Scene,
  98726. /** Options to modify the vr experience helper's behavior. */
  98727. webVROptions?: VRExperienceHelperOptions);
  98728. private _onDefaultMeshLoaded;
  98729. private _onResize;
  98730. private _onFullscreenChange;
  98731. /**
  98732. * Gets a value indicating if we are currently in VR mode.
  98733. */
  98734. readonly isInVRMode: boolean;
  98735. private onVrDisplayPresentChange;
  98736. private onVRDisplayChanged;
  98737. private moveButtonToBottomRight;
  98738. private displayVRButton;
  98739. private updateButtonVisibility;
  98740. private _cachedAngularSensibility;
  98741. /**
  98742. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98743. * Otherwise, will use the fullscreen API.
  98744. */
  98745. enterVR(): void;
  98746. /**
  98747. * Attempt to exit VR, or fullscreen.
  98748. */
  98749. exitVR(): void;
  98750. /**
  98751. * The position of the vr experience helper.
  98752. */
  98753. /**
  98754. * Sets the position of the vr experience helper.
  98755. */
  98756. position: Vector3;
  98757. /**
  98758. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98759. */
  98760. enableInteractions(): void;
  98761. private readonly _noControllerIsActive;
  98762. private beforeRender;
  98763. private _isTeleportationFloor;
  98764. /**
  98765. * Adds a floor mesh to be used for teleportation.
  98766. * @param floorMesh the mesh to be used for teleportation.
  98767. */
  98768. addFloorMesh(floorMesh: Mesh): void;
  98769. /**
  98770. * Removes a floor mesh from being used for teleportation.
  98771. * @param floorMesh the mesh to be removed.
  98772. */
  98773. removeFloorMesh(floorMesh: Mesh): void;
  98774. /**
  98775. * Enables interactions and teleportation using the VR controllers and gaze.
  98776. * @param vrTeleportationOptions options to modify teleportation behavior.
  98777. */
  98778. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  98779. private _onNewGamepadConnected;
  98780. private _tryEnableInteractionOnController;
  98781. private _onNewGamepadDisconnected;
  98782. private _enableInteractionOnController;
  98783. private _checkTeleportWithRay;
  98784. private _checkRotate;
  98785. private _checkTeleportBackwards;
  98786. private _enableTeleportationOnController;
  98787. private _createTeleportationCircles;
  98788. private _displayTeleportationTarget;
  98789. private _hideTeleportationTarget;
  98790. private _rotateCamera;
  98791. private _moveTeleportationSelectorTo;
  98792. private _workingVector;
  98793. private _workingQuaternion;
  98794. private _workingMatrix;
  98795. /**
  98796. * Teleports the users feet to the desired location
  98797. * @param location The location where the user's feet should be placed
  98798. */
  98799. teleportCamera(location: Vector3): void;
  98800. private _convertNormalToDirectionOfRay;
  98801. private _castRayAndSelectObject;
  98802. private _notifySelectedMeshUnselected;
  98803. /**
  98804. * Sets the color of the laser ray from the vr controllers.
  98805. * @param color new color for the ray.
  98806. */
  98807. changeLaserColor(color: Color3): void;
  98808. /**
  98809. * Sets the color of the ray from the vr headsets gaze.
  98810. * @param color new color for the ray.
  98811. */
  98812. changeGazeColor(color: Color3): void;
  98813. /**
  98814. * Exits VR and disposes of the vr experience helper
  98815. */
  98816. dispose(): void;
  98817. /**
  98818. * Gets the name of the VRExperienceHelper class
  98819. * @returns "VRExperienceHelper"
  98820. */
  98821. getClassName(): string;
  98822. }
  98823. }
  98824. declare module BABYLON {
  98825. /**
  98826. * Manages an XRSession
  98827. * @see https://doc.babylonjs.com/how_to/webxr
  98828. */
  98829. export class WebXRSessionManager implements IDisposable {
  98830. private scene;
  98831. /**
  98832. * Fires every time a new xrFrame arrives which can be used to update the camera
  98833. */
  98834. onXRFrameObservable: Observable<any>;
  98835. /**
  98836. * Fires when the xr session is ended either by the device or manually done
  98837. */
  98838. onXRSessionEnded: Observable<any>;
  98839. /** @hidden */
  98840. _xrSession: XRSession;
  98841. /** @hidden */
  98842. _frameOfReference: XRFrameOfReference;
  98843. /** @hidden */
  98844. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98845. /** @hidden */
  98846. _currentXRFrame: Nullable<XRFrame>;
  98847. private _xrNavigator;
  98848. private _xrDevice;
  98849. private _tmpMatrix;
  98850. /**
  98851. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98852. * @param scene The scene which the session should be created for
  98853. */
  98854. constructor(scene: Scene);
  98855. /**
  98856. * Initializes the manager
  98857. * After initialization enterXR can be called to start an XR session
  98858. * @returns Promise which resolves after it is initialized
  98859. */
  98860. initializeAsync(): Promise<void>;
  98861. /**
  98862. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98863. * @param sessionCreationOptions xr options to create the session with
  98864. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98865. * @returns Promise which resolves after it enters XR
  98866. */
  98867. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98868. /**
  98869. * Stops the xrSession and restores the renderloop
  98870. * @returns Promise which resolves after it exits XR
  98871. */
  98872. exitXRAsync(): Promise<void>;
  98873. /**
  98874. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98875. * @param ray ray to cast into the environment
  98876. * @returns Promise which resolves with a collision point in the environment if it exists
  98877. */
  98878. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98879. /**
  98880. * Checks if a session would be supported for the creation options specified
  98881. * @param options creation options to check if they are supported
  98882. * @returns true if supported
  98883. */
  98884. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98885. /**
  98886. * @hidden
  98887. * Converts the render layer of xrSession to a render target
  98888. * @param session session to create render target for
  98889. * @param scene scene the new render target should be created for
  98890. */
  98891. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98892. /**
  98893. * Disposes of the session manager
  98894. */
  98895. dispose(): void;
  98896. }
  98897. }
  98898. declare module BABYLON {
  98899. /**
  98900. * WebXR Camera which holds the views for the xrSession
  98901. * @see https://doc.babylonjs.com/how_to/webxr
  98902. */
  98903. export class WebXRCamera extends FreeCamera {
  98904. private static _TmpMatrix;
  98905. /**
  98906. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98907. * @param name the name of the camera
  98908. * @param scene the scene to add the camera to
  98909. */
  98910. constructor(name: string, scene: Scene);
  98911. private _updateNumberOfRigCameras;
  98912. /** @hidden */
  98913. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98914. /**
  98915. * Updates the cameras position from the current pose information of the XR session
  98916. * @param xrSessionManager the session containing pose information
  98917. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98918. */
  98919. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98920. }
  98921. }
  98922. declare module BABYLON {
  98923. /**
  98924. * States of the webXR experience
  98925. */
  98926. export enum WebXRState {
  98927. /**
  98928. * Transitioning to being in XR mode
  98929. */
  98930. ENTERING_XR = 0,
  98931. /**
  98932. * Transitioning to non XR mode
  98933. */
  98934. EXITING_XR = 1,
  98935. /**
  98936. * In XR mode and presenting
  98937. */
  98938. IN_XR = 2,
  98939. /**
  98940. * Not entered XR mode
  98941. */
  98942. NOT_IN_XR = 3
  98943. }
  98944. /**
  98945. * Helper class used to enable XR
  98946. * @see https://doc.babylonjs.com/how_to/webxr
  98947. */
  98948. export class WebXRExperienceHelper implements IDisposable {
  98949. private scene;
  98950. /**
  98951. * 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
  98952. */
  98953. container: AbstractMesh;
  98954. /**
  98955. * Camera used to render xr content
  98956. */
  98957. camera: WebXRCamera;
  98958. /**
  98959. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98960. */
  98961. state: WebXRState;
  98962. private _setState;
  98963. private static _TmpVector;
  98964. /**
  98965. * Fires when the state of the experience helper has changed
  98966. */
  98967. onStateChangedObservable: Observable<WebXRState>;
  98968. /** @hidden */
  98969. _sessionManager: WebXRSessionManager;
  98970. private _nonVRCamera;
  98971. private _originalSceneAutoClear;
  98972. private _supported;
  98973. /**
  98974. * Creates the experience helper
  98975. * @param scene the scene to attach the experience helper to
  98976. * @returns a promise for the experience helper
  98977. */
  98978. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98979. /**
  98980. * Creates a WebXRExperienceHelper
  98981. * @param scene The scene the helper should be created in
  98982. */
  98983. private constructor();
  98984. /**
  98985. * Exits XR mode and returns the scene to its original state
  98986. * @returns promise that resolves after xr mode has exited
  98987. */
  98988. exitXRAsync(): Promise<void>;
  98989. /**
  98990. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98991. * @param sessionCreationOptions options for the XR session
  98992. * @param frameOfReference frame of reference of the XR session
  98993. * @returns promise that resolves after xr mode has entered
  98994. */
  98995. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98996. /**
  98997. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98998. * @param ray ray to cast into the environment
  98999. * @returns Promise which resolves with a collision point in the environment if it exists
  99000. */
  99001. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99002. /**
  99003. * Updates the global position of the camera by moving the camera's container
  99004. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99005. * @param position The desired global position of the camera
  99006. */
  99007. setPositionOfCameraUsingContainer(position: Vector3): void;
  99008. /**
  99009. * Rotates the xr camera by rotating the camera's container around the camera's position
  99010. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99011. * @param rotation the desired quaternion rotation to apply to the camera
  99012. */
  99013. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99014. /**
  99015. * Checks if the creation options are supported by the xr session
  99016. * @param options creation options
  99017. * @returns true if supported
  99018. */
  99019. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99020. /**
  99021. * Disposes of the experience helper
  99022. */
  99023. dispose(): void;
  99024. }
  99025. }
  99026. declare module BABYLON {
  99027. /**
  99028. * Button which can be used to enter a different mode of XR
  99029. */
  99030. export class WebXREnterExitUIButton {
  99031. /** button element */
  99032. element: HTMLElement;
  99033. /** XR initialization options for the button */
  99034. initializationOptions: XRSessionCreationOptions;
  99035. /**
  99036. * Creates a WebXREnterExitUIButton
  99037. * @param element button element
  99038. * @param initializationOptions XR initialization options for the button
  99039. */
  99040. constructor(
  99041. /** button element */
  99042. element: HTMLElement,
  99043. /** XR initialization options for the button */
  99044. initializationOptions: XRSessionCreationOptions);
  99045. /**
  99046. * Overwritable function which can be used to update the button's visuals when the state changes
  99047. * @param activeButton the current active button in the UI
  99048. */
  99049. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99050. }
  99051. /**
  99052. * Options to create the webXR UI
  99053. */
  99054. export class WebXREnterExitUIOptions {
  99055. /**
  99056. * Context to enter xr with
  99057. */
  99058. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99059. /**
  99060. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99061. */
  99062. customButtons?: Array<WebXREnterExitUIButton>;
  99063. }
  99064. /**
  99065. * UI to allow the user to enter/exit XR mode
  99066. */
  99067. export class WebXREnterExitUI implements IDisposable {
  99068. private scene;
  99069. private _overlay;
  99070. private _buttons;
  99071. private _activeButton;
  99072. /**
  99073. * Fired every time the active button is changed.
  99074. *
  99075. * When xr is entered via a button that launches xr that button will be the callback parameter
  99076. *
  99077. * When exiting xr the callback parameter will be null)
  99078. */
  99079. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99080. /**
  99081. * Creates UI to allow the user to enter/exit XR mode
  99082. * @param scene the scene to add the ui to
  99083. * @param helper the xr experience helper to enter/exit xr with
  99084. * @param options options to configure the UI
  99085. * @returns the created ui
  99086. */
  99087. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99088. private constructor();
  99089. private _updateButtons;
  99090. /**
  99091. * Disposes of the object
  99092. */
  99093. dispose(): void;
  99094. }
  99095. }
  99096. declare module BABYLON {
  99097. /**
  99098. * Represents an XR input
  99099. */
  99100. export class WebXRController {
  99101. /**
  99102. * 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
  99103. */
  99104. grip?: AbstractMesh;
  99105. /**
  99106. * Pointer which can be used to select objects or attach a visible laser to
  99107. */
  99108. pointer: AbstractMesh;
  99109. /**
  99110. * Creates the controller
  99111. * @see https://doc.babylonjs.com/how_to/webxr
  99112. * @param scene the scene which the controller should be associated to
  99113. */
  99114. constructor(scene: Scene);
  99115. /**
  99116. * Disposes of the object
  99117. */
  99118. dispose(): void;
  99119. }
  99120. /**
  99121. * XR input used to track XR inputs such as controllers/rays
  99122. */
  99123. export class WebXRInput implements IDisposable {
  99124. private helper;
  99125. /**
  99126. * XR controllers being tracked
  99127. */
  99128. controllers: Array<WebXRController>;
  99129. private _tmpMatrix;
  99130. private _frameObserver;
  99131. /**
  99132. * Initializes the WebXRInput
  99133. * @param helper experience helper which the input should be created for
  99134. */
  99135. constructor(helper: WebXRExperienceHelper);
  99136. /**
  99137. * Disposes of the object
  99138. */
  99139. dispose(): void;
  99140. }
  99141. }
  99142. declare module BABYLON {
  99143. /**
  99144. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99145. */
  99146. export class WebXRManagedOutputCanvas implements IDisposable {
  99147. private _canvas;
  99148. /**
  99149. * xrpresent context of the canvas which can be used to display/mirror xr content
  99150. */
  99151. canvasContext: Nullable<WebGLRenderingContext>;
  99152. /**
  99153. * Initializes the canvas to be added/removed upon entering/exiting xr
  99154. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99155. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99156. */
  99157. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99158. /**
  99159. * Disposes of the object
  99160. */
  99161. dispose(): void;
  99162. private _setManagedOutputCanvas;
  99163. private _addCanvas;
  99164. private _removeCanvas;
  99165. }
  99166. }
  99167. declare module BABYLON {
  99168. /**
  99169. * Contains an array of blocks representing the octree
  99170. */
  99171. export interface IOctreeContainer<T> {
  99172. /**
  99173. * Blocks within the octree
  99174. */
  99175. blocks: Array<OctreeBlock<T>>;
  99176. }
  99177. /**
  99178. * Class used to store a cell in an octree
  99179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99180. */
  99181. export class OctreeBlock<T> {
  99182. /**
  99183. * Gets the content of the current block
  99184. */
  99185. entries: T[];
  99186. /**
  99187. * Gets the list of block children
  99188. */
  99189. blocks: Array<OctreeBlock<T>>;
  99190. private _depth;
  99191. private _maxDepth;
  99192. private _capacity;
  99193. private _minPoint;
  99194. private _maxPoint;
  99195. private _boundingVectors;
  99196. private _creationFunc;
  99197. /**
  99198. * Creates a new block
  99199. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99200. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99201. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99202. * @param depth defines the current depth of this block in the octree
  99203. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99204. * @param creationFunc defines a callback to call when an element is added to the block
  99205. */
  99206. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99207. /**
  99208. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99209. */
  99210. readonly capacity: number;
  99211. /**
  99212. * Gets the minimum vector (in world space) of the block's bounding box
  99213. */
  99214. readonly minPoint: Vector3;
  99215. /**
  99216. * Gets the maximum vector (in world space) of the block's bounding box
  99217. */
  99218. readonly maxPoint: Vector3;
  99219. /**
  99220. * Add a new element to this block
  99221. * @param entry defines the element to add
  99222. */
  99223. addEntry(entry: T): void;
  99224. /**
  99225. * Remove an element from this block
  99226. * @param entry defines the element to remove
  99227. */
  99228. removeEntry(entry: T): void;
  99229. /**
  99230. * Add an array of elements to this block
  99231. * @param entries defines the array of elements to add
  99232. */
  99233. addEntries(entries: T[]): void;
  99234. /**
  99235. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99236. * @param frustumPlanes defines the frustum planes to test
  99237. * @param selection defines the array to store current content if selection is positive
  99238. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99239. */
  99240. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99241. /**
  99242. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99243. * @param sphereCenter defines the bounding sphere center
  99244. * @param sphereRadius defines the bounding sphere radius
  99245. * @param selection defines the array to store current content if selection is positive
  99246. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99247. */
  99248. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99249. /**
  99250. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99251. * @param ray defines the ray to test with
  99252. * @param selection defines the array to store current content if selection is positive
  99253. */
  99254. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99255. /**
  99256. * Subdivide the content into child blocks (this block will then be empty)
  99257. */
  99258. createInnerBlocks(): void;
  99259. /**
  99260. * @hidden
  99261. */
  99262. 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;
  99263. }
  99264. }
  99265. declare module BABYLON {
  99266. /**
  99267. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99268. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99269. */
  99270. export class Octree<T> {
  99271. /** 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.) */
  99272. maxDepth: number;
  99273. /**
  99274. * Blocks within the octree containing objects
  99275. */
  99276. blocks: Array<OctreeBlock<T>>;
  99277. /**
  99278. * Content stored in the octree
  99279. */
  99280. dynamicContent: T[];
  99281. private _maxBlockCapacity;
  99282. private _selectionContent;
  99283. private _creationFunc;
  99284. /**
  99285. * Creates a octree
  99286. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99287. * @param creationFunc function to be used to instatiate the octree
  99288. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99289. * @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.)
  99290. */
  99291. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99292. /** 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.) */
  99293. maxDepth?: number);
  99294. /**
  99295. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99296. * @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);
  99297. * @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);
  99298. * @param entries meshes to be added to the octree blocks
  99299. */
  99300. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99301. /**
  99302. * Adds a mesh to the octree
  99303. * @param entry Mesh to add to the octree
  99304. */
  99305. addMesh(entry: T): void;
  99306. /**
  99307. * Remove an element from the octree
  99308. * @param entry defines the element to remove
  99309. */
  99310. removeMesh(entry: T): void;
  99311. /**
  99312. * Selects an array of meshes within the frustum
  99313. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99314. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99315. * @returns array of meshes within the frustum
  99316. */
  99317. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99318. /**
  99319. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99320. * @param sphereCenter defines the bounding sphere center
  99321. * @param sphereRadius defines the bounding sphere radius
  99322. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99323. * @returns an array of objects that intersect the sphere
  99324. */
  99325. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99326. /**
  99327. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99328. * @param ray defines the ray to test with
  99329. * @returns array of intersected objects
  99330. */
  99331. intersectsRay(ray: Ray): SmartArray<T>;
  99332. /**
  99333. * Adds a mesh into the octree block if it intersects the block
  99334. */
  99335. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99336. /**
  99337. * Adds a submesh into the octree block if it intersects the block
  99338. */
  99339. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99340. }
  99341. }
  99342. declare module BABYLON {
  99343. interface Scene {
  99344. /**
  99345. * @hidden
  99346. * Backing Filed
  99347. */
  99348. _selectionOctree: Octree<AbstractMesh>;
  99349. /**
  99350. * Gets the octree used to boost mesh selection (picking)
  99351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99352. */
  99353. selectionOctree: Octree<AbstractMesh>;
  99354. /**
  99355. * Creates or updates the octree used to boost selection (picking)
  99356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99357. * @param maxCapacity defines the maximum capacity per leaf
  99358. * @param maxDepth defines the maximum depth of the octree
  99359. * @returns an octree of AbstractMesh
  99360. */
  99361. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99362. }
  99363. interface AbstractMesh {
  99364. /**
  99365. * @hidden
  99366. * Backing Field
  99367. */
  99368. _submeshesOctree: Octree<SubMesh>;
  99369. /**
  99370. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99371. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99372. * @param maxCapacity defines the maximum size of each block (64 by default)
  99373. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99374. * @returns the new octree
  99375. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99377. */
  99378. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99379. }
  99380. /**
  99381. * Defines the octree scene component responsible to manage any octrees
  99382. * in a given scene.
  99383. */
  99384. export class OctreeSceneComponent {
  99385. /**
  99386. * The component name helpfull to identify the component in the list of scene components.
  99387. */
  99388. readonly name: string;
  99389. /**
  99390. * The scene the component belongs to.
  99391. */
  99392. scene: Scene;
  99393. /**
  99394. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99395. */
  99396. readonly checksIsEnabled: boolean;
  99397. /**
  99398. * Creates a new instance of the component for the given scene
  99399. * @param scene Defines the scene to register the component in
  99400. */
  99401. constructor(scene: Scene);
  99402. /**
  99403. * Registers the component in a given scene
  99404. */
  99405. register(): void;
  99406. /**
  99407. * Return the list of active meshes
  99408. * @returns the list of active meshes
  99409. */
  99410. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99411. /**
  99412. * Return the list of active sub meshes
  99413. * @param mesh The mesh to get the candidates sub meshes from
  99414. * @returns the list of active sub meshes
  99415. */
  99416. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99417. private _tempRay;
  99418. /**
  99419. * Return the list of sub meshes intersecting with a given local ray
  99420. * @param mesh defines the mesh to find the submesh for
  99421. * @param localRay defines the ray in local space
  99422. * @returns the list of intersecting sub meshes
  99423. */
  99424. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99425. /**
  99426. * Return the list of sub meshes colliding with a collider
  99427. * @param mesh defines the mesh to find the submesh for
  99428. * @param collider defines the collider to evaluate the collision against
  99429. * @returns the list of colliding sub meshes
  99430. */
  99431. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99432. /**
  99433. * Rebuilds the elements related to this component in case of
  99434. * context lost for instance.
  99435. */
  99436. rebuild(): void;
  99437. /**
  99438. * Disposes the component and the associated ressources.
  99439. */
  99440. dispose(): void;
  99441. }
  99442. }
  99443. declare module BABYLON {
  99444. /**
  99445. * Renders a layer on top of an existing scene
  99446. */
  99447. export class UtilityLayerRenderer implements IDisposable {
  99448. /** the original scene that will be rendered on top of */
  99449. originalScene: Scene;
  99450. private _pointerCaptures;
  99451. private _lastPointerEvents;
  99452. private static _DefaultUtilityLayer;
  99453. private static _DefaultKeepDepthUtilityLayer;
  99454. private _sharedGizmoLight;
  99455. /**
  99456. * @hidden
  99457. * Light which used by gizmos to get light shading
  99458. */
  99459. _getSharedGizmoLight(): HemisphericLight;
  99460. /**
  99461. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99462. */
  99463. pickUtilitySceneFirst: boolean;
  99464. /**
  99465. * 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)
  99466. */
  99467. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99468. /**
  99469. * 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)
  99470. */
  99471. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99472. /**
  99473. * The scene that is rendered on top of the original scene
  99474. */
  99475. utilityLayerScene: Scene;
  99476. /**
  99477. * If the utility layer should automatically be rendered on top of existing scene
  99478. */
  99479. shouldRender: boolean;
  99480. /**
  99481. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99482. */
  99483. onlyCheckPointerDownEvents: boolean;
  99484. /**
  99485. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99486. */
  99487. processAllEvents: boolean;
  99488. /**
  99489. * Observable raised when the pointer move from the utility layer scene to the main scene
  99490. */
  99491. onPointerOutObservable: Observable<number>;
  99492. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99493. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99494. private _afterRenderObserver;
  99495. private _sceneDisposeObserver;
  99496. private _originalPointerObserver;
  99497. /**
  99498. * Instantiates a UtilityLayerRenderer
  99499. * @param originalScene the original scene that will be rendered on top of
  99500. * @param handleEvents boolean indicating if the utility layer should handle events
  99501. */
  99502. constructor(
  99503. /** the original scene that will be rendered on top of */
  99504. originalScene: Scene, handleEvents?: boolean);
  99505. private _notifyObservers;
  99506. /**
  99507. * Renders the utility layers scene on top of the original scene
  99508. */
  99509. render(): void;
  99510. /**
  99511. * Disposes of the renderer
  99512. */
  99513. dispose(): void;
  99514. private _updateCamera;
  99515. }
  99516. }
  99517. declare module BABYLON {
  99518. /**
  99519. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99520. */
  99521. export class Gizmo implements IDisposable {
  99522. /** The utility layer the gizmo will be added to */
  99523. gizmoLayer: UtilityLayerRenderer;
  99524. /**
  99525. * The root mesh of the gizmo
  99526. */
  99527. _rootMesh: Mesh;
  99528. private _attachedMesh;
  99529. /**
  99530. * Ratio for the scale of the gizmo (Default: 1)
  99531. */
  99532. scaleRatio: number;
  99533. private _tmpMatrix;
  99534. /**
  99535. * If a custom mesh has been set (Default: false)
  99536. */
  99537. protected _customMeshSet: boolean;
  99538. /**
  99539. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99540. * * When set, interactions will be enabled
  99541. */
  99542. attachedMesh: Nullable<AbstractMesh>;
  99543. /**
  99544. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99545. * @param mesh The mesh to replace the default mesh of the gizmo
  99546. */
  99547. setCustomMesh(mesh: Mesh): void;
  99548. /**
  99549. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99550. */
  99551. updateGizmoRotationToMatchAttachedMesh: boolean;
  99552. /**
  99553. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99554. */
  99555. updateGizmoPositionToMatchAttachedMesh: boolean;
  99556. /**
  99557. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99558. */
  99559. protected _updateScale: boolean;
  99560. protected _interactionsEnabled: boolean;
  99561. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99562. private _beforeRenderObserver;
  99563. /**
  99564. * Creates a gizmo
  99565. * @param gizmoLayer The utility layer the gizmo will be added to
  99566. */
  99567. constructor(
  99568. /** The utility layer the gizmo will be added to */
  99569. gizmoLayer?: UtilityLayerRenderer);
  99570. private _tempVector;
  99571. /**
  99572. * @hidden
  99573. * Updates the gizmo to match the attached mesh's position/rotation
  99574. */
  99575. protected _update(): void;
  99576. /**
  99577. * Disposes of the gizmo
  99578. */
  99579. dispose(): void;
  99580. }
  99581. }
  99582. declare module BABYLON {
  99583. /**
  99584. * Single axis drag gizmo
  99585. */
  99586. export class AxisDragGizmo extends Gizmo {
  99587. /**
  99588. * Drag behavior responsible for the gizmos dragging interactions
  99589. */
  99590. dragBehavior: PointerDragBehavior;
  99591. private _pointerObserver;
  99592. /**
  99593. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99594. */
  99595. snapDistance: number;
  99596. /**
  99597. * Event that fires each time the gizmo snaps to a new location.
  99598. * * snapDistance is the the change in distance
  99599. */
  99600. onSnapObservable: Observable<{
  99601. snapDistance: number;
  99602. }>;
  99603. /** @hidden */
  99604. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99605. /** @hidden */
  99606. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99607. /**
  99608. * Creates an AxisDragGizmo
  99609. * @param gizmoLayer The utility layer the gizmo will be added to
  99610. * @param dragAxis The axis which the gizmo will be able to drag on
  99611. * @param color The color of the gizmo
  99612. */
  99613. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99614. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99615. /**
  99616. * Disposes of the gizmo
  99617. */
  99618. dispose(): void;
  99619. }
  99620. }
  99621. declare module BABYLON.Debug {
  99622. /**
  99623. * The Axes viewer will show 3 axes in a specific point in space
  99624. */
  99625. export class AxesViewer {
  99626. private _xAxis;
  99627. private _yAxis;
  99628. private _zAxis;
  99629. private _scaleLinesFactor;
  99630. private _instanced;
  99631. /**
  99632. * Gets the hosting scene
  99633. */
  99634. scene: Scene;
  99635. /**
  99636. * Gets or sets a number used to scale line length
  99637. */
  99638. scaleLines: number;
  99639. /** Gets the node hierarchy used to render x-axis */
  99640. readonly xAxis: TransformNode;
  99641. /** Gets the node hierarchy used to render y-axis */
  99642. readonly yAxis: TransformNode;
  99643. /** Gets the node hierarchy used to render z-axis */
  99644. readonly zAxis: TransformNode;
  99645. /**
  99646. * Creates a new AxesViewer
  99647. * @param scene defines the hosting scene
  99648. * @param scaleLines defines a number used to scale line length (1 by default)
  99649. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99650. * @param xAxis defines the node hierarchy used to render the x-axis
  99651. * @param yAxis defines the node hierarchy used to render the y-axis
  99652. * @param zAxis defines the node hierarchy used to render the z-axis
  99653. */
  99654. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99655. /**
  99656. * Force the viewer to update
  99657. * @param position defines the position of the viewer
  99658. * @param xaxis defines the x axis of the viewer
  99659. * @param yaxis defines the y axis of the viewer
  99660. * @param zaxis defines the z axis of the viewer
  99661. */
  99662. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99663. /**
  99664. * Creates an instance of this axes viewer.
  99665. * @returns a new axes viewer with instanced meshes
  99666. */
  99667. createInstance(): AxesViewer;
  99668. /** Releases resources */
  99669. dispose(): void;
  99670. private static _SetRenderingGroupId;
  99671. }
  99672. }
  99673. declare module BABYLON.Debug {
  99674. /**
  99675. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99676. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99677. */
  99678. export class BoneAxesViewer extends AxesViewer {
  99679. /**
  99680. * Gets or sets the target mesh where to display the axes viewer
  99681. */
  99682. mesh: Nullable<Mesh>;
  99683. /**
  99684. * Gets or sets the target bone where to display the axes viewer
  99685. */
  99686. bone: Nullable<Bone>;
  99687. /** Gets current position */
  99688. pos: Vector3;
  99689. /** Gets direction of X axis */
  99690. xaxis: Vector3;
  99691. /** Gets direction of Y axis */
  99692. yaxis: Vector3;
  99693. /** Gets direction of Z axis */
  99694. zaxis: Vector3;
  99695. /**
  99696. * Creates a new BoneAxesViewer
  99697. * @param scene defines the hosting scene
  99698. * @param bone defines the target bone
  99699. * @param mesh defines the target mesh
  99700. * @param scaleLines defines a scaling factor for line length (1 by default)
  99701. */
  99702. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99703. /**
  99704. * Force the viewer to update
  99705. */
  99706. update(): void;
  99707. /** Releases resources */
  99708. dispose(): void;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * Interface used to define scene explorer extensibility option
  99714. */
  99715. export interface IExplorerExtensibilityOption {
  99716. /**
  99717. * Define the option label
  99718. */
  99719. label: string;
  99720. /**
  99721. * Defines the action to execute on click
  99722. */
  99723. action: (entity: any) => void;
  99724. }
  99725. /**
  99726. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99727. */
  99728. export interface IExplorerExtensibilityGroup {
  99729. /**
  99730. * Defines a predicate to test if a given type mut be extended
  99731. */
  99732. predicate: (entity: any) => boolean;
  99733. /**
  99734. * Gets the list of options added to a type
  99735. */
  99736. entries: IExplorerExtensibilityOption[];
  99737. }
  99738. /**
  99739. * Interface used to define the options to use to create the Inspector
  99740. */
  99741. export interface IInspectorOptions {
  99742. /**
  99743. * Display in overlay mode (default: false)
  99744. */
  99745. overlay?: boolean;
  99746. /**
  99747. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99748. */
  99749. globalRoot?: HTMLElement;
  99750. /**
  99751. * Display the Scene explorer
  99752. */
  99753. showExplorer?: boolean;
  99754. /**
  99755. * Display the property inspector
  99756. */
  99757. showInspector?: boolean;
  99758. /**
  99759. * Display in embed mode (both panes on the right)
  99760. */
  99761. embedMode?: boolean;
  99762. /**
  99763. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99764. */
  99765. handleResize?: boolean;
  99766. /**
  99767. * Allow the panes to popup (default: true)
  99768. */
  99769. enablePopup?: boolean;
  99770. /**
  99771. * Allow the panes to be closed by users (default: true)
  99772. */
  99773. enableClose?: boolean;
  99774. /**
  99775. * Optional list of extensibility entries
  99776. */
  99777. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99778. /**
  99779. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99780. */
  99781. inspectorURL?: string;
  99782. }
  99783. interface Scene {
  99784. /**
  99785. * @hidden
  99786. * Backing field
  99787. */
  99788. _debugLayer: DebugLayer;
  99789. /**
  99790. * Gets the debug layer (aka Inspector) associated with the scene
  99791. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99792. */
  99793. debugLayer: DebugLayer;
  99794. }
  99795. /**
  99796. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99797. * what is happening in your scene
  99798. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99799. */
  99800. export class DebugLayer {
  99801. /**
  99802. * Define the url to get the inspector script from.
  99803. * By default it uses the babylonjs CDN.
  99804. * @ignoreNaming
  99805. */
  99806. static InspectorURL: string;
  99807. private _scene;
  99808. private BJSINSPECTOR;
  99809. /**
  99810. * Observable triggered when a property is changed through the inspector.
  99811. */
  99812. onPropertyChangedObservable: Observable<{
  99813. object: any;
  99814. property: string;
  99815. value: any;
  99816. initialValue: any;
  99817. }>;
  99818. /**
  99819. * Instantiates a new debug layer.
  99820. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99821. * what is happening in your scene
  99822. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99823. * @param scene Defines the scene to inspect
  99824. */
  99825. constructor(scene: Scene);
  99826. /** Creates the inspector window. */
  99827. private _createInspector;
  99828. /**
  99829. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99830. * @param entity defines the entity to select
  99831. * @param lineContainerTitle defines the specific block to highlight
  99832. */
  99833. select(entity: any, lineContainerTitle?: string): void;
  99834. /** Get the inspector from bundle or global */
  99835. private _getGlobalInspector;
  99836. /**
  99837. * Get if the inspector is visible or not.
  99838. * @returns true if visible otherwise, false
  99839. */
  99840. isVisible(): boolean;
  99841. /**
  99842. * Hide the inspector and close its window.
  99843. */
  99844. hide(): void;
  99845. /**
  99846. * Launch the debugLayer.
  99847. * @param config Define the configuration of the inspector
  99848. * @return a promise fulfilled when the debug layer is visible
  99849. */
  99850. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99851. }
  99852. }
  99853. declare module BABYLON {
  99854. /**
  99855. * Class containing static functions to help procedurally build meshes
  99856. */
  99857. export class BoxBuilder {
  99858. /**
  99859. * Creates a box mesh
  99860. * * The parameter `size` sets the size (float) of each box side (default 1)
  99861. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99862. * * 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)
  99863. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99867. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99868. * @param name defines the name of the mesh
  99869. * @param options defines the options used to create the mesh
  99870. * @param scene defines the hosting scene
  99871. * @returns the box mesh
  99872. */
  99873. static CreateBox(name: string, options: {
  99874. size?: number;
  99875. width?: number;
  99876. height?: number;
  99877. depth?: number;
  99878. faceUV?: Vector4[];
  99879. faceColors?: Color4[];
  99880. sideOrientation?: number;
  99881. frontUVs?: Vector4;
  99882. backUVs?: Vector4;
  99883. updatable?: boolean;
  99884. }, scene?: Nullable<Scene>): Mesh;
  99885. }
  99886. }
  99887. declare module BABYLON {
  99888. /**
  99889. * Class containing static functions to help procedurally build meshes
  99890. */
  99891. export class SphereBuilder {
  99892. /**
  99893. * Creates a sphere mesh
  99894. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99895. * * 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`)
  99896. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99897. * * 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
  99898. * * 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)
  99899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99902. * @param name defines the name of the mesh
  99903. * @param options defines the options used to create the mesh
  99904. * @param scene defines the hosting scene
  99905. * @returns the sphere mesh
  99906. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99907. */
  99908. static CreateSphere(name: string, options: {
  99909. segments?: number;
  99910. diameter?: number;
  99911. diameterX?: number;
  99912. diameterY?: number;
  99913. diameterZ?: number;
  99914. arc?: number;
  99915. slice?: number;
  99916. sideOrientation?: number;
  99917. frontUVs?: Vector4;
  99918. backUVs?: Vector4;
  99919. updatable?: boolean;
  99920. }, scene: any): Mesh;
  99921. }
  99922. }
  99923. declare module BABYLON.Debug {
  99924. /**
  99925. * Used to show the physics impostor around the specific mesh
  99926. */
  99927. export class PhysicsViewer {
  99928. /** @hidden */
  99929. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99930. /** @hidden */
  99931. protected _meshes: Array<Nullable<AbstractMesh>>;
  99932. /** @hidden */
  99933. protected _scene: Nullable<Scene>;
  99934. /** @hidden */
  99935. protected _numMeshes: number;
  99936. /** @hidden */
  99937. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99938. private _renderFunction;
  99939. private _utilityLayer;
  99940. private _debugBoxMesh;
  99941. private _debugSphereMesh;
  99942. private _debugMaterial;
  99943. private _debugMeshMeshes;
  99944. /**
  99945. * Creates a new PhysicsViewer
  99946. * @param scene defines the hosting scene
  99947. */
  99948. constructor(scene: Scene);
  99949. /** @hidden */
  99950. protected _updateDebugMeshes(): void;
  99951. /**
  99952. * Renders a specified physic impostor
  99953. * @param impostor defines the impostor to render
  99954. * @param targetMesh defines the mesh represented by the impostor
  99955. * @returns the new debug mesh used to render the impostor
  99956. */
  99957. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  99958. /**
  99959. * Hides a specified physic impostor
  99960. * @param impostor defines the impostor to hide
  99961. */
  99962. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99963. private _getDebugMaterial;
  99964. private _getDebugBoxMesh;
  99965. private _getDebugSphereMesh;
  99966. private _getDebugMeshMesh;
  99967. private _getDebugMesh;
  99968. /** Releases all resources */
  99969. dispose(): void;
  99970. }
  99971. }
  99972. declare module BABYLON {
  99973. /**
  99974. * Class containing static functions to help procedurally build meshes
  99975. */
  99976. export class LinesBuilder {
  99977. /**
  99978. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  99979. * * 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
  99980. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  99981. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  99982. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  99983. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  99984. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  99985. * * 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
  99986. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  99987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  99989. * @param name defines the name of the new line system
  99990. * @param options defines the options used to create the line system
  99991. * @param scene defines the hosting scene
  99992. * @returns a new line system mesh
  99993. */
  99994. static CreateLineSystem(name: string, options: {
  99995. lines: Vector3[][];
  99996. updatable?: boolean;
  99997. instance?: Nullable<LinesMesh>;
  99998. colors?: Nullable<Color4[][]>;
  99999. useVertexAlpha?: boolean;
  100000. }, scene: Nullable<Scene>): LinesMesh;
  100001. /**
  100002. * Creates a line mesh
  100003. * 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
  100004. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100005. * * The parameter `points` is an array successive Vector3
  100006. * * 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
  100007. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100008. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100009. * * When updating an instance, remember that only point positions can change, not the number of points
  100010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100012. * @param name defines the name of the new line system
  100013. * @param options defines the options used to create the line system
  100014. * @param scene defines the hosting scene
  100015. * @returns a new line mesh
  100016. */
  100017. static CreateLines(name: string, options: {
  100018. points: Vector3[];
  100019. updatable?: boolean;
  100020. instance?: Nullable<LinesMesh>;
  100021. colors?: Color4[];
  100022. useVertexAlpha?: boolean;
  100023. }, scene?: Nullable<Scene>): LinesMesh;
  100024. /**
  100025. * Creates a dashed line mesh
  100026. * * 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
  100027. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100028. * * The parameter `points` is an array successive Vector3
  100029. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100030. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100031. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100032. * * 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
  100033. * * When updating an instance, remember that only point positions can change, not the number of points
  100034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100035. * @param name defines the name of the mesh
  100036. * @param options defines the options used to create the mesh
  100037. * @param scene defines the hosting scene
  100038. * @returns the dashed line mesh
  100039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100040. */
  100041. static CreateDashedLines(name: string, options: {
  100042. points: Vector3[];
  100043. dashSize?: number;
  100044. gapSize?: number;
  100045. dashNb?: number;
  100046. updatable?: boolean;
  100047. instance?: LinesMesh;
  100048. }, scene?: Nullable<Scene>): LinesMesh;
  100049. }
  100050. }
  100051. declare module BABYLON {
  100052. /**
  100053. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100054. * in order to better appreciate the issue one might have.
  100055. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100056. */
  100057. export class RayHelper {
  100058. /**
  100059. * Defines the ray we are currently tryin to visualize.
  100060. */
  100061. ray: Nullable<Ray>;
  100062. private _renderPoints;
  100063. private _renderLine;
  100064. private _renderFunction;
  100065. private _scene;
  100066. private _updateToMeshFunction;
  100067. private _attachedToMesh;
  100068. private _meshSpaceDirection;
  100069. private _meshSpaceOrigin;
  100070. /**
  100071. * Helper function to create a colored helper in a scene in one line.
  100072. * @param ray Defines the ray we are currently tryin to visualize
  100073. * @param scene Defines the scene the ray is used in
  100074. * @param color Defines the color we want to see the ray in
  100075. * @returns The newly created ray helper.
  100076. */
  100077. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100078. /**
  100079. * Instantiate a new ray helper.
  100080. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100081. * in order to better appreciate the issue one might have.
  100082. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100083. * @param ray Defines the ray we are currently tryin to visualize
  100084. */
  100085. constructor(ray: Ray);
  100086. /**
  100087. * Shows the ray we are willing to debug.
  100088. * @param scene Defines the scene the ray needs to be rendered in
  100089. * @param color Defines the color the ray needs to be rendered in
  100090. */
  100091. show(scene: Scene, color?: Color3): void;
  100092. /**
  100093. * Hides the ray we are debugging.
  100094. */
  100095. hide(): void;
  100096. private _render;
  100097. /**
  100098. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100099. * @param mesh Defines the mesh we want the helper attached to
  100100. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100101. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100102. * @param length Defines the length of the ray
  100103. */
  100104. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100105. /**
  100106. * Detach the ray helper from the mesh it has previously been attached to.
  100107. */
  100108. detachFromMesh(): void;
  100109. private _updateToMesh;
  100110. /**
  100111. * Dispose the helper and release its associated resources.
  100112. */
  100113. dispose(): void;
  100114. }
  100115. }
  100116. declare module BABYLON.Debug {
  100117. /**
  100118. * Class used to render a debug view of a given skeleton
  100119. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100120. */
  100121. export class SkeletonViewer {
  100122. /** defines the skeleton to render */
  100123. skeleton: Skeleton;
  100124. /** defines the mesh attached to the skeleton */
  100125. mesh: AbstractMesh;
  100126. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100127. autoUpdateBonesMatrices: boolean;
  100128. /** defines the rendering group id to use with the viewer */
  100129. renderingGroupId: number;
  100130. /** Gets or sets the color used to render the skeleton */
  100131. color: Color3;
  100132. private _scene;
  100133. private _debugLines;
  100134. private _debugMesh;
  100135. private _isEnabled;
  100136. private _renderFunction;
  100137. private _utilityLayer;
  100138. /**
  100139. * Returns the mesh used to render the bones
  100140. */
  100141. readonly debugMesh: Nullable<LinesMesh>;
  100142. /**
  100143. * Creates a new SkeletonViewer
  100144. * @param skeleton defines the skeleton to render
  100145. * @param mesh defines the mesh attached to the skeleton
  100146. * @param scene defines the hosting scene
  100147. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100148. * @param renderingGroupId defines the rendering group id to use with the viewer
  100149. */
  100150. constructor(
  100151. /** defines the skeleton to render */
  100152. skeleton: Skeleton,
  100153. /** defines the mesh attached to the skeleton */
  100154. mesh: AbstractMesh, scene: Scene,
  100155. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100156. autoUpdateBonesMatrices?: boolean,
  100157. /** defines the rendering group id to use with the viewer */
  100158. renderingGroupId?: number);
  100159. /** Gets or sets a boolean indicating if the viewer is enabled */
  100160. isEnabled: boolean;
  100161. private _getBonePosition;
  100162. private _getLinesForBonesWithLength;
  100163. private _getLinesForBonesNoLength;
  100164. /** Update the viewer to sync with current skeleton state */
  100165. update(): void;
  100166. /** Release associated resources */
  100167. dispose(): void;
  100168. }
  100169. }
  100170. declare module BABYLON {
  100171. /**
  100172. * Options to create the null engine
  100173. */
  100174. export class NullEngineOptions {
  100175. /**
  100176. * Render width (Default: 512)
  100177. */
  100178. renderWidth: number;
  100179. /**
  100180. * Render height (Default: 256)
  100181. */
  100182. renderHeight: number;
  100183. /**
  100184. * Texture size (Default: 512)
  100185. */
  100186. textureSize: number;
  100187. /**
  100188. * If delta time between frames should be constant
  100189. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100190. */
  100191. deterministicLockstep: boolean;
  100192. /**
  100193. * Maximum about of steps between frames (Default: 4)
  100194. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100195. */
  100196. lockstepMaxSteps: number;
  100197. }
  100198. /**
  100199. * The null engine class provides support for headless version of babylon.js.
  100200. * This can be used in server side scenario or for testing purposes
  100201. */
  100202. export class NullEngine extends Engine {
  100203. private _options;
  100204. /**
  100205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100206. */
  100207. isDeterministicLockStep(): boolean;
  100208. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100209. getLockstepMaxSteps(): number;
  100210. /**
  100211. * Sets hardware scaling, used to save performance if needed
  100212. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100213. */
  100214. getHardwareScalingLevel(): number;
  100215. constructor(options?: NullEngineOptions);
  100216. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100217. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100218. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100219. getRenderWidth(useScreen?: boolean): number;
  100220. getRenderHeight(useScreen?: boolean): number;
  100221. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100222. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100223. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100224. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100225. bindSamplers(effect: Effect): void;
  100226. enableEffect(effect: Effect): void;
  100227. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100228. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100229. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100230. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100231. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100232. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100233. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100234. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100235. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100236. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100237. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100238. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100239. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100240. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100241. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100242. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100243. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100244. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100245. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100246. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100247. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100248. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100249. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100250. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100251. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100252. bindBuffers(vertexBuffers: {
  100253. [key: string]: VertexBuffer;
  100254. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100255. wipeCaches(bruteForce?: boolean): void;
  100256. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100258. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100259. /** @hidden */
  100260. _createTexture(): WebGLTexture;
  100261. /** @hidden */
  100262. _releaseTexture(texture: InternalTexture): void;
  100263. 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;
  100264. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100265. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100266. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100267. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100268. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100269. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100270. areAllEffectsReady(): boolean;
  100271. /**
  100272. * @hidden
  100273. * Get the current error code of the webGL context
  100274. * @returns the error code
  100275. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100276. */
  100277. getError(): number;
  100278. /** @hidden */
  100279. _getUnpackAlignement(): number;
  100280. /** @hidden */
  100281. _unpackFlipY(value: boolean): void;
  100282. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100283. /**
  100284. * Updates a dynamic vertex buffer.
  100285. * @param vertexBuffer the vertex buffer to update
  100286. * @param data the data used to update the vertex buffer
  100287. * @param byteOffset the byte offset of the data (optional)
  100288. * @param byteLength the byte length of the data (optional)
  100289. */
  100290. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100291. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100292. /** @hidden */
  100293. _bindTexture(channel: number, texture: InternalTexture): void;
  100294. /** @hidden */
  100295. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100296. releaseEffects(): void;
  100297. displayLoadingUI(): void;
  100298. hideLoadingUI(): void;
  100299. /** @hidden */
  100300. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100301. /** @hidden */
  100302. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100303. /** @hidden */
  100304. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100305. /** @hidden */
  100306. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100307. }
  100308. }
  100309. declare module BABYLON {
  100310. /** @hidden */
  100311. export class _OcclusionDataStorage {
  100312. /** @hidden */
  100313. occlusionInternalRetryCounter: number;
  100314. /** @hidden */
  100315. isOcclusionQueryInProgress: boolean;
  100316. /** @hidden */
  100317. isOccluded: boolean;
  100318. /** @hidden */
  100319. occlusionRetryCount: number;
  100320. /** @hidden */
  100321. occlusionType: number;
  100322. /** @hidden */
  100323. occlusionQueryAlgorithmType: number;
  100324. }
  100325. interface Engine {
  100326. /**
  100327. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100328. * @return the new query
  100329. */
  100330. createQuery(): WebGLQuery;
  100331. /**
  100332. * Delete and release a webGL query
  100333. * @param query defines the query to delete
  100334. * @return the current engine
  100335. */
  100336. deleteQuery(query: WebGLQuery): Engine;
  100337. /**
  100338. * Check if a given query has resolved and got its value
  100339. * @param query defines the query to check
  100340. * @returns true if the query got its value
  100341. */
  100342. isQueryResultAvailable(query: WebGLQuery): boolean;
  100343. /**
  100344. * Gets the value of a given query
  100345. * @param query defines the query to check
  100346. * @returns the value of the query
  100347. */
  100348. getQueryResult(query: WebGLQuery): number;
  100349. /**
  100350. * Initiates an occlusion query
  100351. * @param algorithmType defines the algorithm to use
  100352. * @param query defines the query to use
  100353. * @returns the current engine
  100354. * @see http://doc.babylonjs.com/features/occlusionquery
  100355. */
  100356. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100357. /**
  100358. * Ends an occlusion query
  100359. * @see http://doc.babylonjs.com/features/occlusionquery
  100360. * @param algorithmType defines the algorithm to use
  100361. * @returns the current engine
  100362. */
  100363. endOcclusionQuery(algorithmType: number): Engine;
  100364. /**
  100365. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100366. * Please note that only one query can be issued at a time
  100367. * @returns a time token used to track the time span
  100368. */
  100369. startTimeQuery(): Nullable<_TimeToken>;
  100370. /**
  100371. * Ends a time query
  100372. * @param token defines the token used to measure the time span
  100373. * @returns the time spent (in ns)
  100374. */
  100375. endTimeQuery(token: _TimeToken): int;
  100376. /** @hidden */
  100377. _currentNonTimestampToken: Nullable<_TimeToken>;
  100378. /** @hidden */
  100379. _createTimeQuery(): WebGLQuery;
  100380. /** @hidden */
  100381. _deleteTimeQuery(query: WebGLQuery): void;
  100382. /** @hidden */
  100383. _getGlAlgorithmType(algorithmType: number): number;
  100384. /** @hidden */
  100385. _getTimeQueryResult(query: WebGLQuery): any;
  100386. /** @hidden */
  100387. _getTimeQueryAvailability(query: WebGLQuery): any;
  100388. }
  100389. interface AbstractMesh {
  100390. /**
  100391. * Backing filed
  100392. * @hidden
  100393. */
  100394. __occlusionDataStorage: _OcclusionDataStorage;
  100395. /**
  100396. * Access property
  100397. * @hidden
  100398. */
  100399. _occlusionDataStorage: _OcclusionDataStorage;
  100400. /**
  100401. * 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.
  100402. * The default value is -1 which means don't break the query and wait till the result
  100403. * @see http://doc.babylonjs.com/features/occlusionquery
  100404. */
  100405. occlusionRetryCount: number;
  100406. /**
  100407. * 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:
  100408. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100409. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100410. * * 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.
  100411. * @see http://doc.babylonjs.com/features/occlusionquery
  100412. */
  100413. occlusionType: number;
  100414. /**
  100415. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100416. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100417. * * 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.
  100418. * @see http://doc.babylonjs.com/features/occlusionquery
  100419. */
  100420. occlusionQueryAlgorithmType: number;
  100421. /**
  100422. * 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
  100423. * @see http://doc.babylonjs.com/features/occlusionquery
  100424. */
  100425. isOccluded: boolean;
  100426. /**
  100427. * Flag to check the progress status of the query
  100428. * @see http://doc.babylonjs.com/features/occlusionquery
  100429. */
  100430. isOcclusionQueryInProgress: boolean;
  100431. }
  100432. }
  100433. declare module BABYLON {
  100434. /** @hidden */
  100435. export var _forceTransformFeedbackToBundle: boolean;
  100436. interface Engine {
  100437. /**
  100438. * Creates a webGL transform feedback object
  100439. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100440. * @returns the webGL transform feedback object
  100441. */
  100442. createTransformFeedback(): WebGLTransformFeedback;
  100443. /**
  100444. * Delete a webGL transform feedback object
  100445. * @param value defines the webGL transform feedback object to delete
  100446. */
  100447. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100448. /**
  100449. * Bind a webGL transform feedback object to the webgl context
  100450. * @param value defines the webGL transform feedback object to bind
  100451. */
  100452. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100453. /**
  100454. * Begins a transform feedback operation
  100455. * @param usePoints defines if points or triangles must be used
  100456. */
  100457. beginTransformFeedback(usePoints: boolean): void;
  100458. /**
  100459. * Ends a transform feedback operation
  100460. */
  100461. endTransformFeedback(): void;
  100462. /**
  100463. * Specify the varyings to use with transform feedback
  100464. * @param program defines the associated webGL program
  100465. * @param value defines the list of strings representing the varying names
  100466. */
  100467. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100468. /**
  100469. * Bind a webGL buffer for a transform feedback operation
  100470. * @param value defines the webGL buffer to bind
  100471. */
  100472. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100473. }
  100474. }
  100475. declare module BABYLON {
  100476. /**
  100477. * Gather the list of clipboard event types as constants.
  100478. */
  100479. export class ClipboardEventTypes {
  100480. /**
  100481. * The clipboard event is fired when a copy command is active (pressed).
  100482. */
  100483. static readonly COPY: number;
  100484. /**
  100485. * The clipboard event is fired when a cut command is active (pressed).
  100486. */
  100487. static readonly CUT: number;
  100488. /**
  100489. * The clipboard event is fired when a paste command is active (pressed).
  100490. */
  100491. static readonly PASTE: number;
  100492. }
  100493. /**
  100494. * This class is used to store clipboard related info for the onClipboardObservable event.
  100495. */
  100496. export class ClipboardInfo {
  100497. /**
  100498. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100499. */
  100500. type: number;
  100501. /**
  100502. * Defines the related dom event
  100503. */
  100504. event: ClipboardEvent;
  100505. /**
  100506. *Creates an instance of ClipboardInfo.
  100507. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100508. * @param event Defines the related dom event
  100509. */
  100510. constructor(
  100511. /**
  100512. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100513. */
  100514. type: number,
  100515. /**
  100516. * Defines the related dom event
  100517. */
  100518. event: ClipboardEvent);
  100519. /**
  100520. * Get the clipboard event's type from the keycode.
  100521. * @param keyCode Defines the keyCode for the current keyboard event.
  100522. * @return {number}
  100523. */
  100524. static GetTypeFromCharacter(keyCode: number): number;
  100525. }
  100526. }
  100527. declare module BABYLON {
  100528. /**
  100529. * Class used to represent data loading progression
  100530. */
  100531. export class SceneLoaderProgressEvent {
  100532. /** defines if data length to load can be evaluated */
  100533. readonly lengthComputable: boolean;
  100534. /** defines the loaded data length */
  100535. readonly loaded: number;
  100536. /** defines the data length to load */
  100537. readonly total: number;
  100538. /**
  100539. * Create a new progress event
  100540. * @param lengthComputable defines if data length to load can be evaluated
  100541. * @param loaded defines the loaded data length
  100542. * @param total defines the data length to load
  100543. */
  100544. constructor(
  100545. /** defines if data length to load can be evaluated */
  100546. lengthComputable: boolean,
  100547. /** defines the loaded data length */
  100548. loaded: number,
  100549. /** defines the data length to load */
  100550. total: number);
  100551. /**
  100552. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100553. * @param event defines the source event
  100554. * @returns a new SceneLoaderProgressEvent
  100555. */
  100556. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100557. }
  100558. /**
  100559. * Interface used by SceneLoader plugins to define supported file extensions
  100560. */
  100561. export interface ISceneLoaderPluginExtensions {
  100562. /**
  100563. * Defines the list of supported extensions
  100564. */
  100565. [extension: string]: {
  100566. isBinary: boolean;
  100567. };
  100568. }
  100569. /**
  100570. * Interface used by SceneLoader plugin factory
  100571. */
  100572. export interface ISceneLoaderPluginFactory {
  100573. /**
  100574. * Defines the name of the factory
  100575. */
  100576. name: string;
  100577. /**
  100578. * Function called to create a new plugin
  100579. * @return the new plugin
  100580. */
  100581. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100582. /**
  100583. * Boolean indicating if the plugin can direct load specific data
  100584. */
  100585. canDirectLoad?: (data: string) => boolean;
  100586. }
  100587. /**
  100588. * Interface used to define a SceneLoader plugin
  100589. */
  100590. export interface ISceneLoaderPlugin {
  100591. /**
  100592. * The friendly name of this plugin.
  100593. */
  100594. name: string;
  100595. /**
  100596. * The file extensions supported by this plugin.
  100597. */
  100598. extensions: string | ISceneLoaderPluginExtensions;
  100599. /**
  100600. * Import meshes into a scene.
  100601. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100602. * @param scene The scene to import into
  100603. * @param data The data to import
  100604. * @param rootUrl The root url for scene and resources
  100605. * @param meshes The meshes array to import into
  100606. * @param particleSystems The particle systems array to import into
  100607. * @param skeletons The skeletons array to import into
  100608. * @param onError The callback when import fails
  100609. * @returns True if successful or false otherwise
  100610. */
  100611. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100612. /**
  100613. * Load into a scene.
  100614. * @param scene The scene to load into
  100615. * @param data The data to import
  100616. * @param rootUrl The root url for scene and resources
  100617. * @param onError The callback when import fails
  100618. * @returns true if successful or false otherwise
  100619. */
  100620. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100621. /**
  100622. * The callback that returns true if the data can be directly loaded.
  100623. */
  100624. canDirectLoad?: (data: string) => boolean;
  100625. /**
  100626. * The callback that allows custom handling of the root url based on the response url.
  100627. */
  100628. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100629. /**
  100630. * Load into an asset container.
  100631. * @param scene The scene to load into
  100632. * @param data The data to import
  100633. * @param rootUrl The root url for scene and resources
  100634. * @param onError The callback when import fails
  100635. * @returns The loaded asset container
  100636. */
  100637. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100638. }
  100639. /**
  100640. * Interface used to define an async SceneLoader plugin
  100641. */
  100642. export interface ISceneLoaderPluginAsync {
  100643. /**
  100644. * The friendly name of this plugin.
  100645. */
  100646. name: string;
  100647. /**
  100648. * The file extensions supported by this plugin.
  100649. */
  100650. extensions: string | ISceneLoaderPluginExtensions;
  100651. /**
  100652. * Import meshes into a scene.
  100653. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100654. * @param scene The scene to import into
  100655. * @param data The data to import
  100656. * @param rootUrl The root url for scene and resources
  100657. * @param onProgress The callback when the load progresses
  100658. * @param fileName Defines the name of the file to load
  100659. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100660. */
  100661. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100662. meshes: AbstractMesh[];
  100663. particleSystems: IParticleSystem[];
  100664. skeletons: Skeleton[];
  100665. animationGroups: AnimationGroup[];
  100666. }>;
  100667. /**
  100668. * Load into a scene.
  100669. * @param scene The scene to load into
  100670. * @param data The data to import
  100671. * @param rootUrl The root url for scene and resources
  100672. * @param onProgress The callback when the load progresses
  100673. * @param fileName Defines the name of the file to load
  100674. * @returns Nothing
  100675. */
  100676. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100677. /**
  100678. * The callback that returns true if the data can be directly loaded.
  100679. */
  100680. canDirectLoad?: (data: string) => boolean;
  100681. /**
  100682. * The callback that allows custom handling of the root url based on the response url.
  100683. */
  100684. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100685. /**
  100686. * Load into an asset container.
  100687. * @param scene The scene to load into
  100688. * @param data The data to import
  100689. * @param rootUrl The root url for scene and resources
  100690. * @param onProgress The callback when the load progresses
  100691. * @param fileName Defines the name of the file to load
  100692. * @returns The loaded asset container
  100693. */
  100694. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100695. }
  100696. /**
  100697. * Class used to load scene from various file formats using registered plugins
  100698. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100699. */
  100700. export class SceneLoader {
  100701. /**
  100702. * No logging while loading
  100703. */
  100704. static readonly NO_LOGGING: number;
  100705. /**
  100706. * Minimal logging while loading
  100707. */
  100708. static readonly MINIMAL_LOGGING: number;
  100709. /**
  100710. * Summary logging while loading
  100711. */
  100712. static readonly SUMMARY_LOGGING: number;
  100713. /**
  100714. * Detailled logging while loading
  100715. */
  100716. static readonly DETAILED_LOGGING: number;
  100717. /**
  100718. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100719. */
  100720. static ForceFullSceneLoadingForIncremental: boolean;
  100721. /**
  100722. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100723. */
  100724. static ShowLoadingScreen: boolean;
  100725. /**
  100726. * Defines the current logging level (while loading the scene)
  100727. * @ignorenaming
  100728. */
  100729. static loggingLevel: number;
  100730. /**
  100731. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100732. */
  100733. static CleanBoneMatrixWeights: boolean;
  100734. /**
  100735. * Event raised when a plugin is used to load a scene
  100736. */
  100737. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100738. private static _registeredPlugins;
  100739. private static _getDefaultPlugin;
  100740. private static _getPluginForExtension;
  100741. private static _getPluginForDirectLoad;
  100742. private static _getPluginForFilename;
  100743. private static _getDirectLoad;
  100744. private static _loadData;
  100745. private static _getFileInfo;
  100746. /**
  100747. * Gets a plugin that can load the given extension
  100748. * @param extension defines the extension to load
  100749. * @returns a plugin or null if none works
  100750. */
  100751. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100752. /**
  100753. * Gets a boolean indicating that the given extension can be loaded
  100754. * @param extension defines the extension to load
  100755. * @returns true if the extension is supported
  100756. */
  100757. static IsPluginForExtensionAvailable(extension: string): boolean;
  100758. /**
  100759. * Adds a new plugin to the list of registered plugins
  100760. * @param plugin defines the plugin to add
  100761. */
  100762. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  100763. /**
  100764. * Import meshes into a scene
  100765. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100766. * @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)
  100767. * @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)
  100768. * @param scene the instance of BABYLON.Scene to append to
  100769. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  100770. * @param onProgress a callback with a progress event for each file being loaded
  100771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100772. * @param pluginExtension the extension used to determine the plugin
  100773. * @returns The loaded plugin
  100774. */
  100775. 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>;
  100776. /**
  100777. * Import meshes into a scene
  100778. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100779. * @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)
  100780. * @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)
  100781. * @param scene the instance of BABYLON.Scene to append to
  100782. * @param onProgress a callback with a progress event for each file being loaded
  100783. * @param pluginExtension the extension used to determine the plugin
  100784. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  100785. */
  100786. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  100787. meshes: AbstractMesh[];
  100788. particleSystems: IParticleSystem[];
  100789. skeletons: Skeleton[];
  100790. animationGroups: AnimationGroup[];
  100791. }>;
  100792. /**
  100793. * Load a scene
  100794. * @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)
  100795. * @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)
  100796. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100797. * @param onSuccess a callback with the scene when import succeeds
  100798. * @param onProgress a callback with a progress event for each file being loaded
  100799. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100800. * @param pluginExtension the extension used to determine the plugin
  100801. * @returns The loaded plugin
  100802. */
  100803. 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>;
  100804. /**
  100805. * Load a scene
  100806. * @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)
  100807. * @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)
  100808. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100809. * @param onProgress a callback with a progress event for each file being loaded
  100810. * @param pluginExtension the extension used to determine the plugin
  100811. * @returns The loaded scene
  100812. */
  100813. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100814. /**
  100815. * Append a scene
  100816. * @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)
  100817. * @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)
  100818. * @param scene is the instance of BABYLON.Scene to append to
  100819. * @param onSuccess a callback with the scene when import succeeds
  100820. * @param onProgress a callback with a progress event for each file being loaded
  100821. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100822. * @param pluginExtension the extension used to determine the plugin
  100823. * @returns The loaded plugin
  100824. */
  100825. 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>;
  100826. /**
  100827. * Append a scene
  100828. * @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)
  100829. * @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)
  100830. * @param scene is the instance of BABYLON.Scene to append to
  100831. * @param onProgress a callback with a progress event for each file being loaded
  100832. * @param pluginExtension the extension used to determine the plugin
  100833. * @returns The given scene
  100834. */
  100835. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100836. /**
  100837. * Load a scene into an asset container
  100838. * @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)
  100839. * @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)
  100840. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100841. * @param onSuccess a callback with the scene when import succeeds
  100842. * @param onProgress a callback with a progress event for each file being loaded
  100843. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100844. * @param pluginExtension the extension used to determine the plugin
  100845. * @returns The loaded plugin
  100846. */
  100847. 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>;
  100848. /**
  100849. * Load a scene into an asset container
  100850. * @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)
  100851. * @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)
  100852. * @param scene is the instance of Scene to append to
  100853. * @param onProgress a callback with a progress event for each file being loaded
  100854. * @param pluginExtension the extension used to determine the plugin
  100855. * @returns The loaded asset container
  100856. */
  100857. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100858. }
  100859. }
  100860. declare module BABYLON {
  100861. /**
  100862. * Google Daydream controller
  100863. */
  100864. export class DaydreamController extends WebVRController {
  100865. /**
  100866. * Base Url for the controller model.
  100867. */
  100868. static MODEL_BASE_URL: string;
  100869. /**
  100870. * File name for the controller model.
  100871. */
  100872. static MODEL_FILENAME: string;
  100873. /**
  100874. * Gamepad Id prefix used to identify Daydream Controller.
  100875. */
  100876. static readonly GAMEPAD_ID_PREFIX: string;
  100877. /**
  100878. * Creates a new DaydreamController from a gamepad
  100879. * @param vrGamepad the gamepad that the controller should be created from
  100880. */
  100881. constructor(vrGamepad: any);
  100882. /**
  100883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100884. * @param scene scene in which to add meshes
  100885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100886. */
  100887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100888. /**
  100889. * Called once for each button that changed state since the last frame
  100890. * @param buttonIdx Which button index changed
  100891. * @param state New state of the button
  100892. * @param changes Which properties on the state changed since last frame
  100893. */
  100894. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100895. }
  100896. }
  100897. declare module BABYLON {
  100898. /**
  100899. * Gear VR Controller
  100900. */
  100901. export class GearVRController extends WebVRController {
  100902. /**
  100903. * Base Url for the controller model.
  100904. */
  100905. static MODEL_BASE_URL: string;
  100906. /**
  100907. * File name for the controller model.
  100908. */
  100909. static MODEL_FILENAME: string;
  100910. /**
  100911. * Gamepad Id prefix used to identify this controller.
  100912. */
  100913. static readonly GAMEPAD_ID_PREFIX: string;
  100914. private readonly _buttonIndexToObservableNameMap;
  100915. /**
  100916. * Creates a new GearVRController from a gamepad
  100917. * @param vrGamepad the gamepad that the controller should be created from
  100918. */
  100919. constructor(vrGamepad: any);
  100920. /**
  100921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100922. * @param scene scene in which to add meshes
  100923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100924. */
  100925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100926. /**
  100927. * Called once for each button that changed state since the last frame
  100928. * @param buttonIdx Which button index changed
  100929. * @param state New state of the button
  100930. * @param changes Which properties on the state changed since last frame
  100931. */
  100932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100933. }
  100934. }
  100935. declare module BABYLON {
  100936. /**
  100937. * Generic Controller
  100938. */
  100939. export class GenericController extends WebVRController {
  100940. /**
  100941. * Base Url for the controller model.
  100942. */
  100943. static readonly MODEL_BASE_URL: string;
  100944. /**
  100945. * File name for the controller model.
  100946. */
  100947. static readonly MODEL_FILENAME: string;
  100948. /**
  100949. * Creates a new GenericController from a gamepad
  100950. * @param vrGamepad the gamepad that the controller should be created from
  100951. */
  100952. constructor(vrGamepad: any);
  100953. /**
  100954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100955. * @param scene scene in which to add meshes
  100956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100957. */
  100958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100959. /**
  100960. * Called once for each button that changed state since the last frame
  100961. * @param buttonIdx Which button index changed
  100962. * @param state New state of the button
  100963. * @param changes Which properties on the state changed since last frame
  100964. */
  100965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100966. }
  100967. }
  100968. declare module BABYLON {
  100969. /**
  100970. * Oculus Touch Controller
  100971. */
  100972. export class OculusTouchController extends WebVRController {
  100973. /**
  100974. * Base Url for the controller model.
  100975. */
  100976. static MODEL_BASE_URL: string;
  100977. /**
  100978. * File name for the left controller model.
  100979. */
  100980. static MODEL_LEFT_FILENAME: string;
  100981. /**
  100982. * File name for the right controller model.
  100983. */
  100984. static MODEL_RIGHT_FILENAME: string;
  100985. /**
  100986. * Fired when the secondary trigger on this controller is modified
  100987. */
  100988. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100989. /**
  100990. * Fired when the thumb rest on this controller is modified
  100991. */
  100992. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100993. /**
  100994. * Creates a new OculusTouchController from a gamepad
  100995. * @param vrGamepad the gamepad that the controller should be created from
  100996. */
  100997. constructor(vrGamepad: any);
  100998. /**
  100999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101000. * @param scene scene in which to add meshes
  101001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101002. */
  101003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101004. /**
  101005. * Fired when the A button on this controller is modified
  101006. */
  101007. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101008. /**
  101009. * Fired when the B button on this controller is modified
  101010. */
  101011. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101012. /**
  101013. * Fired when the X button on this controller is modified
  101014. */
  101015. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101016. /**
  101017. * Fired when the Y button on this controller is modified
  101018. */
  101019. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101020. /**
  101021. * Called once for each button that changed state since the last frame
  101022. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101023. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101024. * 2) secondary trigger (same)
  101025. * 3) A (right) X (left), touch, pressed = value
  101026. * 4) B / Y
  101027. * 5) thumb rest
  101028. * @param buttonIdx Which button index changed
  101029. * @param state New state of the button
  101030. * @param changes Which properties on the state changed since last frame
  101031. */
  101032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101033. }
  101034. }
  101035. declare module BABYLON {
  101036. /**
  101037. * Vive Controller
  101038. */
  101039. export class ViveController extends WebVRController {
  101040. /**
  101041. * Base Url for the controller model.
  101042. */
  101043. static MODEL_BASE_URL: string;
  101044. /**
  101045. * File name for the controller model.
  101046. */
  101047. static MODEL_FILENAME: string;
  101048. /**
  101049. * Creates a new ViveController from a gamepad
  101050. * @param vrGamepad the gamepad that the controller should be created from
  101051. */
  101052. constructor(vrGamepad: any);
  101053. /**
  101054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101055. * @param scene scene in which to add meshes
  101056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101057. */
  101058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101059. /**
  101060. * Fired when the left button on this controller is modified
  101061. */
  101062. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101063. /**
  101064. * Fired when the right button on this controller is modified
  101065. */
  101066. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101067. /**
  101068. * Fired when the menu button on this controller is modified
  101069. */
  101070. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101071. /**
  101072. * Called once for each button that changed state since the last frame
  101073. * Vive mapping:
  101074. * 0: touchpad
  101075. * 1: trigger
  101076. * 2: left AND right buttons
  101077. * 3: menu button
  101078. * @param buttonIdx Which button index changed
  101079. * @param state New state of the button
  101080. * @param changes Which properties on the state changed since last frame
  101081. */
  101082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101083. }
  101084. }
  101085. declare module BABYLON {
  101086. /**
  101087. * Defines the WindowsMotionController object that the state of the windows motion controller
  101088. */
  101089. export class WindowsMotionController extends WebVRController {
  101090. /**
  101091. * The base url used to load the left and right controller models
  101092. */
  101093. static MODEL_BASE_URL: string;
  101094. /**
  101095. * The name of the left controller model file
  101096. */
  101097. static MODEL_LEFT_FILENAME: string;
  101098. /**
  101099. * The name of the right controller model file
  101100. */
  101101. static MODEL_RIGHT_FILENAME: string;
  101102. /**
  101103. * The controller name prefix for this controller type
  101104. */
  101105. static readonly GAMEPAD_ID_PREFIX: string;
  101106. /**
  101107. * The controller id pattern for this controller type
  101108. */
  101109. private static readonly GAMEPAD_ID_PATTERN;
  101110. private _loadedMeshInfo;
  101111. private readonly _mapping;
  101112. /**
  101113. * Fired when the trackpad on this controller is clicked
  101114. */
  101115. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101116. /**
  101117. * Fired when the trackpad on this controller is modified
  101118. */
  101119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101120. /**
  101121. * The current x and y values of this controller's trackpad
  101122. */
  101123. trackpad: StickValues;
  101124. /**
  101125. * Creates a new WindowsMotionController from a gamepad
  101126. * @param vrGamepad the gamepad that the controller should be created from
  101127. */
  101128. constructor(vrGamepad: any);
  101129. /**
  101130. * Fired when the trigger on this controller is modified
  101131. */
  101132. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101133. /**
  101134. * Fired when the menu button on this controller is modified
  101135. */
  101136. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101137. /**
  101138. * Fired when the grip button on this controller is modified
  101139. */
  101140. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101141. /**
  101142. * Fired when the thumbstick button on this controller is modified
  101143. */
  101144. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101145. /**
  101146. * Fired when the touchpad button on this controller is modified
  101147. */
  101148. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101149. /**
  101150. * Fired when the touchpad values on this controller are modified
  101151. */
  101152. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101153. private _updateTrackpad;
  101154. /**
  101155. * Called once per frame by the engine.
  101156. */
  101157. update(): void;
  101158. /**
  101159. * Called once for each button that changed state since the last frame
  101160. * @param buttonIdx Which button index changed
  101161. * @param state New state of the button
  101162. * @param changes Which properties on the state changed since last frame
  101163. */
  101164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101165. /**
  101166. * Moves the buttons on the controller mesh based on their current state
  101167. * @param buttonName the name of the button to move
  101168. * @param buttonValue the value of the button which determines the buttons new position
  101169. */
  101170. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101171. /**
  101172. * Moves the axis on the controller mesh based on its current state
  101173. * @param axis the index of the axis
  101174. * @param axisValue the value of the axis which determines the meshes new position
  101175. * @hidden
  101176. */
  101177. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101178. /**
  101179. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101180. * @param scene scene in which to add meshes
  101181. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101182. */
  101183. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101184. /**
  101185. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101186. * can be transformed by button presses and axes values, based on this._mapping.
  101187. *
  101188. * @param scene scene in which the meshes exist
  101189. * @param meshes list of meshes that make up the controller model to process
  101190. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101191. */
  101192. private processModel;
  101193. private createMeshInfo;
  101194. /**
  101195. * Gets the ray of the controller in the direction the controller is pointing
  101196. * @param length the length the resulting ray should be
  101197. * @returns a ray in the direction the controller is pointing
  101198. */
  101199. getForwardRay(length?: number): Ray;
  101200. /**
  101201. * Disposes of the controller
  101202. */
  101203. dispose(): void;
  101204. }
  101205. }
  101206. declare module BABYLON {
  101207. /**
  101208. * Single axis scale gizmo
  101209. */
  101210. export class AxisScaleGizmo extends Gizmo {
  101211. private _coloredMaterial;
  101212. /**
  101213. * Drag behavior responsible for the gizmos dragging interactions
  101214. */
  101215. dragBehavior: PointerDragBehavior;
  101216. private _pointerObserver;
  101217. /**
  101218. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101219. */
  101220. snapDistance: number;
  101221. /**
  101222. * Event that fires each time the gizmo snaps to a new location.
  101223. * * snapDistance is the the change in distance
  101224. */
  101225. onSnapObservable: Observable<{
  101226. snapDistance: number;
  101227. }>;
  101228. /**
  101229. * If the scaling operation should be done on all axis (default: false)
  101230. */
  101231. uniformScaling: boolean;
  101232. /**
  101233. * Creates an AxisScaleGizmo
  101234. * @param gizmoLayer The utility layer the gizmo will be added to
  101235. * @param dragAxis The axis which the gizmo will be able to scale on
  101236. * @param color The color of the gizmo
  101237. */
  101238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101240. /**
  101241. * Disposes of the gizmo
  101242. */
  101243. dispose(): void;
  101244. /**
  101245. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101246. * @param mesh The mesh to replace the default mesh of the gizmo
  101247. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101248. */
  101249. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101250. }
  101251. }
  101252. declare module BABYLON {
  101253. /**
  101254. * Bounding box gizmo
  101255. */
  101256. export class BoundingBoxGizmo extends Gizmo {
  101257. private _lineBoundingBox;
  101258. private _rotateSpheresParent;
  101259. private _scaleBoxesParent;
  101260. private _boundingDimensions;
  101261. private _renderObserver;
  101262. private _pointerObserver;
  101263. private _scaleDragSpeed;
  101264. private _tmpQuaternion;
  101265. private _tmpVector;
  101266. private _tmpRotationMatrix;
  101267. /**
  101268. * 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)
  101269. */
  101270. ignoreChildren: boolean;
  101271. /**
  101272. * 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)
  101273. */
  101274. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101275. /**
  101276. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101277. */
  101278. rotationSphereSize: number;
  101279. /**
  101280. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101281. */
  101282. scaleBoxSize: number;
  101283. /**
  101284. * 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)
  101285. */
  101286. fixedDragMeshScreenSize: boolean;
  101287. /**
  101288. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101289. */
  101290. fixedDragMeshScreenSizeDistanceFactor: number;
  101291. /**
  101292. * Fired when a rotation sphere or scale box is dragged
  101293. */
  101294. onDragStartObservable: Observable<{}>;
  101295. /**
  101296. * Fired when a scale box is dragged
  101297. */
  101298. onScaleBoxDragObservable: Observable<{}>;
  101299. /**
  101300. * Fired when a scale box drag is ended
  101301. */
  101302. onScaleBoxDragEndObservable: Observable<{}>;
  101303. /**
  101304. * Fired when a rotation sphere is dragged
  101305. */
  101306. onRotationSphereDragObservable: Observable<{}>;
  101307. /**
  101308. * Fired when a rotation sphere drag is ended
  101309. */
  101310. onRotationSphereDragEndObservable: Observable<{}>;
  101311. /**
  101312. * 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)
  101313. */
  101314. scalePivot: Nullable<Vector3>;
  101315. private _anchorMesh;
  101316. private _existingMeshScale;
  101317. private _dragMesh;
  101318. private pointerDragBehavior;
  101319. private coloredMaterial;
  101320. private hoverColoredMaterial;
  101321. /**
  101322. * Sets the color of the bounding box gizmo
  101323. * @param color the color to set
  101324. */
  101325. setColor(color: Color3): void;
  101326. /**
  101327. * Creates an BoundingBoxGizmo
  101328. * @param gizmoLayer The utility layer the gizmo will be added to
  101329. * @param color The color of the gizmo
  101330. */
  101331. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101332. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101333. private _selectNode;
  101334. /**
  101335. * Updates the bounding box information for the Gizmo
  101336. */
  101337. updateBoundingBox(): void;
  101338. private _updateRotationSpheres;
  101339. private _updateScaleBoxes;
  101340. /**
  101341. * Enables rotation on the specified axis and disables rotation on the others
  101342. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101343. */
  101344. setEnabledRotationAxis(axis: string): void;
  101345. /**
  101346. * Enables/disables scaling
  101347. * @param enable if scaling should be enabled
  101348. */
  101349. setEnabledScaling(enable: boolean): void;
  101350. private _updateDummy;
  101351. /**
  101352. * Enables a pointer drag behavior on the bounding box of the gizmo
  101353. */
  101354. enableDragBehavior(): void;
  101355. /**
  101356. * Disposes of the gizmo
  101357. */
  101358. dispose(): void;
  101359. /**
  101360. * 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)
  101361. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101362. * @returns the bounding box mesh with the passed in mesh as a child
  101363. */
  101364. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101365. /**
  101366. * CustomMeshes are not supported by this gizmo
  101367. * @param mesh The mesh to replace the default mesh of the gizmo
  101368. */
  101369. setCustomMesh(mesh: Mesh): void;
  101370. }
  101371. }
  101372. declare module BABYLON {
  101373. /**
  101374. * Single plane rotation gizmo
  101375. */
  101376. export class PlaneRotationGizmo extends Gizmo {
  101377. /**
  101378. * Drag behavior responsible for the gizmos dragging interactions
  101379. */
  101380. dragBehavior: PointerDragBehavior;
  101381. private _pointerObserver;
  101382. /**
  101383. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101384. */
  101385. snapDistance: number;
  101386. /**
  101387. * Event that fires each time the gizmo snaps to a new location.
  101388. * * snapDistance is the the change in distance
  101389. */
  101390. onSnapObservable: Observable<{
  101391. snapDistance: number;
  101392. }>;
  101393. /**
  101394. * Creates a PlaneRotationGizmo
  101395. * @param gizmoLayer The utility layer the gizmo will be added to
  101396. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101397. * @param color The color of the gizmo
  101398. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101399. */
  101400. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101401. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101402. /**
  101403. * Disposes of the gizmo
  101404. */
  101405. dispose(): void;
  101406. }
  101407. }
  101408. declare module BABYLON {
  101409. /**
  101410. * Gizmo that enables rotating a mesh along 3 axis
  101411. */
  101412. export class RotationGizmo extends Gizmo {
  101413. /**
  101414. * Internal gizmo used for interactions on the x axis
  101415. */
  101416. xGizmo: PlaneRotationGizmo;
  101417. /**
  101418. * Internal gizmo used for interactions on the y axis
  101419. */
  101420. yGizmo: PlaneRotationGizmo;
  101421. /**
  101422. * Internal gizmo used for interactions on the z axis
  101423. */
  101424. zGizmo: PlaneRotationGizmo;
  101425. /** Fires an event when any of it's sub gizmos are dragged */
  101426. onDragStartObservable: Observable<{}>;
  101427. /** Fires an event when any of it's sub gizmos are released from dragging */
  101428. onDragEndObservable: Observable<{}>;
  101429. attachedMesh: Nullable<AbstractMesh>;
  101430. /**
  101431. * Creates a RotationGizmo
  101432. * @param gizmoLayer The utility layer the gizmo will be added to
  101433. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101434. */
  101435. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101436. updateGizmoRotationToMatchAttachedMesh: boolean;
  101437. /**
  101438. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101439. */
  101440. snapDistance: number;
  101441. /**
  101442. * Ratio for the scale of the gizmo (Default: 1)
  101443. */
  101444. scaleRatio: number;
  101445. /**
  101446. * Disposes of the gizmo
  101447. */
  101448. dispose(): void;
  101449. /**
  101450. * CustomMeshes are not supported by this gizmo
  101451. * @param mesh The mesh to replace the default mesh of the gizmo
  101452. */
  101453. setCustomMesh(mesh: Mesh): void;
  101454. }
  101455. }
  101456. declare module BABYLON {
  101457. /**
  101458. * Gizmo that enables dragging a mesh along 3 axis
  101459. */
  101460. export class PositionGizmo extends Gizmo {
  101461. /**
  101462. * Internal gizmo used for interactions on the x axis
  101463. */
  101464. xGizmo: AxisDragGizmo;
  101465. /**
  101466. * Internal gizmo used for interactions on the y axis
  101467. */
  101468. yGizmo: AxisDragGizmo;
  101469. /**
  101470. * Internal gizmo used for interactions on the z axis
  101471. */
  101472. zGizmo: AxisDragGizmo;
  101473. /** Fires an event when any of it's sub gizmos are dragged */
  101474. onDragStartObservable: Observable<{}>;
  101475. /** Fires an event when any of it's sub gizmos are released from dragging */
  101476. onDragEndObservable: Observable<{}>;
  101477. attachedMesh: Nullable<AbstractMesh>;
  101478. /**
  101479. * Creates a PositionGizmo
  101480. * @param gizmoLayer The utility layer the gizmo will be added to
  101481. */
  101482. constructor(gizmoLayer?: UtilityLayerRenderer);
  101483. updateGizmoRotationToMatchAttachedMesh: boolean;
  101484. /**
  101485. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101486. */
  101487. snapDistance: number;
  101488. /**
  101489. * Ratio for the scale of the gizmo (Default: 1)
  101490. */
  101491. scaleRatio: number;
  101492. /**
  101493. * Disposes of the gizmo
  101494. */
  101495. dispose(): void;
  101496. /**
  101497. * CustomMeshes are not supported by this gizmo
  101498. * @param mesh The mesh to replace the default mesh of the gizmo
  101499. */
  101500. setCustomMesh(mesh: Mesh): void;
  101501. }
  101502. }
  101503. declare module BABYLON {
  101504. /**
  101505. * Class containing static functions to help procedurally build meshes
  101506. */
  101507. export class PolyhedronBuilder {
  101508. /**
  101509. * Creates a polyhedron mesh
  101510. * * 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
  101511. * * The parameter `size` (positive float, default 1) sets the polygon size
  101512. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101513. * * 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`
  101514. * * 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
  101515. * * 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)`)
  101516. * * 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
  101517. * * 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
  101518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101521. * @param name defines the name of the mesh
  101522. * @param options defines the options used to create the mesh
  101523. * @param scene defines the hosting scene
  101524. * @returns the polyhedron mesh
  101525. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101526. */
  101527. static CreatePolyhedron(name: string, options: {
  101528. type?: number;
  101529. size?: number;
  101530. sizeX?: number;
  101531. sizeY?: number;
  101532. sizeZ?: number;
  101533. custom?: any;
  101534. faceUV?: Vector4[];
  101535. faceColors?: Color4[];
  101536. flat?: boolean;
  101537. updatable?: boolean;
  101538. sideOrientation?: number;
  101539. frontUVs?: Vector4;
  101540. backUVs?: Vector4;
  101541. }, scene: Scene): Mesh;
  101542. }
  101543. }
  101544. declare module BABYLON {
  101545. /**
  101546. * Gizmo that enables scaling a mesh along 3 axis
  101547. */
  101548. export class ScaleGizmo extends Gizmo {
  101549. /**
  101550. * Internal gizmo used for interactions on the x axis
  101551. */
  101552. xGizmo: AxisScaleGizmo;
  101553. /**
  101554. * Internal gizmo used for interactions on the y axis
  101555. */
  101556. yGizmo: AxisScaleGizmo;
  101557. /**
  101558. * Internal gizmo used for interactions on the z axis
  101559. */
  101560. zGizmo: AxisScaleGizmo;
  101561. /**
  101562. * Internal gizmo used to scale all axis equally
  101563. */
  101564. uniformScaleGizmo: AxisScaleGizmo;
  101565. /** Fires an event when any of it's sub gizmos are dragged */
  101566. onDragStartObservable: Observable<{}>;
  101567. /** Fires an event when any of it's sub gizmos are released from dragging */
  101568. onDragEndObservable: Observable<{}>;
  101569. attachedMesh: Nullable<AbstractMesh>;
  101570. /**
  101571. * Creates a ScaleGizmo
  101572. * @param gizmoLayer The utility layer the gizmo will be added to
  101573. */
  101574. constructor(gizmoLayer?: UtilityLayerRenderer);
  101575. updateGizmoRotationToMatchAttachedMesh: boolean;
  101576. /**
  101577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101578. */
  101579. snapDistance: number;
  101580. /**
  101581. * Ratio for the scale of the gizmo (Default: 1)
  101582. */
  101583. scaleRatio: number;
  101584. /**
  101585. * Disposes of the gizmo
  101586. */
  101587. dispose(): void;
  101588. }
  101589. }
  101590. declare module BABYLON {
  101591. /**
  101592. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101593. */
  101594. export class GizmoManager implements IDisposable {
  101595. private scene;
  101596. /**
  101597. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101598. */
  101599. gizmos: {
  101600. positionGizmo: Nullable<PositionGizmo>;
  101601. rotationGizmo: Nullable<RotationGizmo>;
  101602. scaleGizmo: Nullable<ScaleGizmo>;
  101603. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101604. };
  101605. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101606. clearGizmoOnEmptyPointerEvent: boolean;
  101607. /** Fires an event when the manager is attached to a mesh */
  101608. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101609. private _gizmosEnabled;
  101610. private _pointerObserver;
  101611. private _attachedMesh;
  101612. private _boundingBoxColor;
  101613. private _defaultUtilityLayer;
  101614. private _defaultKeepDepthUtilityLayer;
  101615. /**
  101616. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101617. */
  101618. boundingBoxDragBehavior: SixDofDragBehavior;
  101619. /**
  101620. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101621. */
  101622. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101623. /**
  101624. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101625. */
  101626. usePointerToAttachGizmos: boolean;
  101627. /**
  101628. * Instatiates a gizmo manager
  101629. * @param scene the scene to overlay the gizmos on top of
  101630. */
  101631. constructor(scene: Scene);
  101632. /**
  101633. * Attaches a set of gizmos to the specified mesh
  101634. * @param mesh The mesh the gizmo's should be attached to
  101635. */
  101636. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101637. /**
  101638. * If the position gizmo is enabled
  101639. */
  101640. positionGizmoEnabled: boolean;
  101641. /**
  101642. * If the rotation gizmo is enabled
  101643. */
  101644. rotationGizmoEnabled: boolean;
  101645. /**
  101646. * If the scale gizmo is enabled
  101647. */
  101648. scaleGizmoEnabled: boolean;
  101649. /**
  101650. * If the boundingBox gizmo is enabled
  101651. */
  101652. boundingBoxGizmoEnabled: boolean;
  101653. /**
  101654. * Disposes of the gizmo manager
  101655. */
  101656. dispose(): void;
  101657. }
  101658. }
  101659. declare module BABYLON {
  101660. /**
  101661. * A directional light is defined by a direction (what a surprise!).
  101662. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101663. * 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.
  101664. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101665. */
  101666. export class DirectionalLight extends ShadowLight {
  101667. private _shadowFrustumSize;
  101668. /**
  101669. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101670. */
  101671. /**
  101672. * Specifies a fix frustum size for the shadow generation.
  101673. */
  101674. shadowFrustumSize: number;
  101675. private _shadowOrthoScale;
  101676. /**
  101677. * Gets the shadow projection scale against the optimal computed one.
  101678. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101679. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101680. */
  101681. /**
  101682. * Sets the shadow projection scale against the optimal computed one.
  101683. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101684. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101685. */
  101686. shadowOrthoScale: number;
  101687. /**
  101688. * Automatically compute the projection matrix to best fit (including all the casters)
  101689. * on each frame.
  101690. */
  101691. autoUpdateExtends: boolean;
  101692. private _orthoLeft;
  101693. private _orthoRight;
  101694. private _orthoTop;
  101695. private _orthoBottom;
  101696. /**
  101697. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101698. * The directional light is emitted from everywhere in the given direction.
  101699. * It can cast shadows.
  101700. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101701. * @param name The friendly name of the light
  101702. * @param direction The direction of the light
  101703. * @param scene The scene the light belongs to
  101704. */
  101705. constructor(name: string, direction: Vector3, scene: Scene);
  101706. /**
  101707. * Returns the string "DirectionalLight".
  101708. * @return The class name
  101709. */
  101710. getClassName(): string;
  101711. /**
  101712. * Returns the integer 1.
  101713. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101714. */
  101715. getTypeID(): number;
  101716. /**
  101717. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101718. * Returns the DirectionalLight Shadow projection matrix.
  101719. */
  101720. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101721. /**
  101722. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101723. * Returns the DirectionalLight Shadow projection matrix.
  101724. */
  101725. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101726. /**
  101727. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101728. * Returns the DirectionalLight Shadow projection matrix.
  101729. */
  101730. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101731. protected _buildUniformLayout(): void;
  101732. /**
  101733. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101734. * @param effect The effect to update
  101735. * @param lightIndex The index of the light in the effect to update
  101736. * @returns The directional light
  101737. */
  101738. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101739. /**
  101740. * Gets the minZ used for shadow according to both the scene and the light.
  101741. *
  101742. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101743. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101744. * @param activeCamera The camera we are returning the min for
  101745. * @returns the depth min z
  101746. */
  101747. getDepthMinZ(activeCamera: Camera): number;
  101748. /**
  101749. * Gets the maxZ used for shadow according to both the scene and the light.
  101750. *
  101751. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101752. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101753. * @param activeCamera The camera we are returning the max for
  101754. * @returns the depth max z
  101755. */
  101756. getDepthMaxZ(activeCamera: Camera): number;
  101757. /**
  101758. * Prepares the list of defines specific to the light type.
  101759. * @param defines the list of defines
  101760. * @param lightIndex defines the index of the light for the effect
  101761. */
  101762. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101763. }
  101764. }
  101765. declare module BABYLON {
  101766. /**
  101767. * Class containing static functions to help procedurally build meshes
  101768. */
  101769. export class HemisphereBuilder {
  101770. /**
  101771. * Creates a hemisphere mesh
  101772. * @param name defines the name of the mesh
  101773. * @param options defines the options used to create the mesh
  101774. * @param scene defines the hosting scene
  101775. * @returns the hemisphere mesh
  101776. */
  101777. static CreateHemisphere(name: string, options: {
  101778. segments?: number;
  101779. diameter?: number;
  101780. sideOrientation?: number;
  101781. }, scene: any): Mesh;
  101782. }
  101783. }
  101784. declare module BABYLON {
  101785. /**
  101786. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101787. * These values define a cone of light starting from the position, emitting toward the direction.
  101788. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101789. * and the exponent defines the speed of the decay of the light with distance (reach).
  101790. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101791. */
  101792. export class SpotLight extends ShadowLight {
  101793. private _angle;
  101794. private _innerAngle;
  101795. private _cosHalfAngle;
  101796. private _lightAngleScale;
  101797. private _lightAngleOffset;
  101798. /**
  101799. * Gets the cone angle of the spot light in Radians.
  101800. */
  101801. /**
  101802. * Sets the cone angle of the spot light in Radians.
  101803. */
  101804. angle: number;
  101805. /**
  101806. * Only used in gltf falloff mode, this defines the angle where
  101807. * the directional falloff will start before cutting at angle which could be seen
  101808. * as outer angle.
  101809. */
  101810. /**
  101811. * Only used in gltf falloff mode, this defines the angle where
  101812. * the directional falloff will start before cutting at angle which could be seen
  101813. * as outer angle.
  101814. */
  101815. innerAngle: number;
  101816. private _shadowAngleScale;
  101817. /**
  101818. * Allows scaling the angle of the light for shadow generation only.
  101819. */
  101820. /**
  101821. * Allows scaling the angle of the light for shadow generation only.
  101822. */
  101823. shadowAngleScale: number;
  101824. /**
  101825. * The light decay speed with the distance from the emission spot.
  101826. */
  101827. exponent: number;
  101828. private _projectionTextureMatrix;
  101829. /**
  101830. * Allows reading the projecton texture
  101831. */
  101832. readonly projectionTextureMatrix: Matrix;
  101833. protected _projectionTextureLightNear: number;
  101834. /**
  101835. * Gets the near clip of the Spotlight for texture projection.
  101836. */
  101837. /**
  101838. * Sets the near clip of the Spotlight for texture projection.
  101839. */
  101840. projectionTextureLightNear: number;
  101841. protected _projectionTextureLightFar: number;
  101842. /**
  101843. * Gets the far clip of the Spotlight for texture projection.
  101844. */
  101845. /**
  101846. * Sets the far clip of the Spotlight for texture projection.
  101847. */
  101848. projectionTextureLightFar: number;
  101849. protected _projectionTextureUpDirection: Vector3;
  101850. /**
  101851. * Gets the Up vector of the Spotlight for texture projection.
  101852. */
  101853. /**
  101854. * Sets the Up vector of the Spotlight for texture projection.
  101855. */
  101856. projectionTextureUpDirection: Vector3;
  101857. private _projectionTexture;
  101858. /**
  101859. * Gets the projection texture of the light.
  101860. */
  101861. /**
  101862. * Sets the projection texture of the light.
  101863. */
  101864. projectionTexture: Nullable<BaseTexture>;
  101865. private _projectionTextureViewLightDirty;
  101866. private _projectionTextureProjectionLightDirty;
  101867. private _projectionTextureDirty;
  101868. private _projectionTextureViewTargetVector;
  101869. private _projectionTextureViewLightMatrix;
  101870. private _projectionTextureProjectionLightMatrix;
  101871. private _projectionTextureScalingMatrix;
  101872. /**
  101873. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101874. * It can cast shadows.
  101875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101876. * @param name The light friendly name
  101877. * @param position The position of the spot light in the scene
  101878. * @param direction The direction of the light in the scene
  101879. * @param angle The cone angle of the light in Radians
  101880. * @param exponent The light decay speed with the distance from the emission spot
  101881. * @param scene The scene the lights belongs to
  101882. */
  101883. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101884. /**
  101885. * Returns the string "SpotLight".
  101886. * @returns the class name
  101887. */
  101888. getClassName(): string;
  101889. /**
  101890. * Returns the integer 2.
  101891. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101892. */
  101893. getTypeID(): number;
  101894. /**
  101895. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101896. */
  101897. protected _setDirection(value: Vector3): void;
  101898. /**
  101899. * Overrides the position setter to recompute the projection texture view light Matrix.
  101900. */
  101901. protected _setPosition(value: Vector3): void;
  101902. /**
  101903. * 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.
  101904. * Returns the SpotLight.
  101905. */
  101906. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101907. protected _computeProjectionTextureViewLightMatrix(): void;
  101908. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101909. /**
  101910. * Main function for light texture projection matrix computing.
  101911. */
  101912. protected _computeProjectionTextureMatrix(): void;
  101913. protected _buildUniformLayout(): void;
  101914. private _computeAngleValues;
  101915. /**
  101916. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101917. * @param effect The effect to update
  101918. * @param lightIndex The index of the light in the effect to update
  101919. * @returns The spot light
  101920. */
  101921. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101922. /**
  101923. * Disposes the light and the associated resources.
  101924. */
  101925. dispose(): void;
  101926. /**
  101927. * Prepares the list of defines specific to the light type.
  101928. * @param defines the list of defines
  101929. * @param lightIndex defines the index of the light for the effect
  101930. */
  101931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101932. }
  101933. }
  101934. declare module BABYLON {
  101935. /**
  101936. * Gizmo that enables viewing a light
  101937. */
  101938. export class LightGizmo extends Gizmo {
  101939. private _lightMesh;
  101940. private _material;
  101941. /**
  101942. * Creates a LightGizmo
  101943. * @param gizmoLayer The utility layer the gizmo will be added to
  101944. */
  101945. constructor(gizmoLayer?: UtilityLayerRenderer);
  101946. private _light;
  101947. /**
  101948. * The light that the gizmo is attached to
  101949. */
  101950. light: Nullable<Light>;
  101951. /**
  101952. * @hidden
  101953. * Updates the gizmo to match the attached mesh's position/rotation
  101954. */
  101955. protected _update(): void;
  101956. private static _Scale;
  101957. /**
  101958. * Creates the lines for a light mesh
  101959. */
  101960. private static _createLightLines;
  101961. private static _CreateHemisphericLightMesh;
  101962. private static _CreatePointLightMesh;
  101963. private static _CreateSpotLightMesh;
  101964. private static _CreateDirectionalLightMesh;
  101965. }
  101966. }
  101967. declare module BABYLON {
  101968. /** @hidden */
  101969. export var backgroundFragmentDeclaration: {
  101970. name: string;
  101971. shader: string;
  101972. };
  101973. }
  101974. declare module BABYLON {
  101975. /** @hidden */
  101976. export var backgroundUboDeclaration: {
  101977. name: string;
  101978. shader: string;
  101979. };
  101980. }
  101981. declare module BABYLON {
  101982. /** @hidden */
  101983. export var backgroundPixelShader: {
  101984. name: string;
  101985. shader: string;
  101986. };
  101987. }
  101988. declare module BABYLON {
  101989. /** @hidden */
  101990. export var backgroundVertexDeclaration: {
  101991. name: string;
  101992. shader: string;
  101993. };
  101994. }
  101995. declare module BABYLON {
  101996. /** @hidden */
  101997. export var backgroundVertexShader: {
  101998. name: string;
  101999. shader: string;
  102000. };
  102001. }
  102002. declare module BABYLON {
  102003. /**
  102004. * Background material used to create an efficient environement around your scene.
  102005. */
  102006. export class BackgroundMaterial extends PushMaterial {
  102007. /**
  102008. * Standard reflectance value at parallel view angle.
  102009. */
  102010. static StandardReflectance0: number;
  102011. /**
  102012. * Standard reflectance value at grazing angle.
  102013. */
  102014. static StandardReflectance90: number;
  102015. protected _primaryColor: Color3;
  102016. /**
  102017. * Key light Color (multiply against the environement texture)
  102018. */
  102019. primaryColor: Color3;
  102020. protected __perceptualColor: Nullable<Color3>;
  102021. /**
  102022. * Experimental Internal Use Only.
  102023. *
  102024. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102025. * This acts as a helper to set the primary color to a more "human friendly" value.
  102026. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102027. * output color as close as possible from the chosen value.
  102028. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102029. * part of lighting setup.)
  102030. */
  102031. _perceptualColor: Nullable<Color3>;
  102032. protected _primaryColorShadowLevel: float;
  102033. /**
  102034. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102035. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102036. */
  102037. primaryColorShadowLevel: float;
  102038. protected _primaryColorHighlightLevel: float;
  102039. /**
  102040. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102041. * The primary color is used at the level chosen to define what the white area would look.
  102042. */
  102043. primaryColorHighlightLevel: float;
  102044. protected _reflectionTexture: Nullable<BaseTexture>;
  102045. /**
  102046. * Reflection Texture used in the material.
  102047. * Should be author in a specific way for the best result (refer to the documentation).
  102048. */
  102049. reflectionTexture: Nullable<BaseTexture>;
  102050. protected _reflectionBlur: float;
  102051. /**
  102052. * Reflection Texture level of blur.
  102053. *
  102054. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102055. * texture twice.
  102056. */
  102057. reflectionBlur: float;
  102058. protected _diffuseTexture: Nullable<BaseTexture>;
  102059. /**
  102060. * Diffuse Texture used in the material.
  102061. * Should be author in a specific way for the best result (refer to the documentation).
  102062. */
  102063. diffuseTexture: Nullable<BaseTexture>;
  102064. protected _shadowLights: Nullable<IShadowLight[]>;
  102065. /**
  102066. * Specify the list of lights casting shadow on the material.
  102067. * All scene shadow lights will be included if null.
  102068. */
  102069. shadowLights: Nullable<IShadowLight[]>;
  102070. protected _shadowLevel: float;
  102071. /**
  102072. * Helps adjusting the shadow to a softer level if required.
  102073. * 0 means black shadows and 1 means no shadows.
  102074. */
  102075. shadowLevel: float;
  102076. protected _sceneCenter: Vector3;
  102077. /**
  102078. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102079. * It is usually zero but might be interesting to modify according to your setup.
  102080. */
  102081. sceneCenter: Vector3;
  102082. protected _opacityFresnel: boolean;
  102083. /**
  102084. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102085. * This helps ensuring a nice transition when the camera goes under the ground.
  102086. */
  102087. opacityFresnel: boolean;
  102088. protected _reflectionFresnel: boolean;
  102089. /**
  102090. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102091. * This helps adding a mirror texture on the ground.
  102092. */
  102093. reflectionFresnel: boolean;
  102094. protected _reflectionFalloffDistance: number;
  102095. /**
  102096. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102097. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102098. */
  102099. reflectionFalloffDistance: number;
  102100. protected _reflectionAmount: number;
  102101. /**
  102102. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102103. */
  102104. reflectionAmount: number;
  102105. protected _reflectionReflectance0: number;
  102106. /**
  102107. * This specifies the weight of the reflection at grazing angle.
  102108. */
  102109. reflectionReflectance0: number;
  102110. protected _reflectionReflectance90: number;
  102111. /**
  102112. * This specifies the weight of the reflection at a perpendicular point of view.
  102113. */
  102114. reflectionReflectance90: number;
  102115. /**
  102116. * Sets the reflection reflectance fresnel values according to the default standard
  102117. * empirically know to work well :-)
  102118. */
  102119. reflectionStandardFresnelWeight: number;
  102120. protected _useRGBColor: boolean;
  102121. /**
  102122. * Helps to directly use the maps channels instead of their level.
  102123. */
  102124. useRGBColor: boolean;
  102125. protected _enableNoise: boolean;
  102126. /**
  102127. * This helps reducing the banding effect that could occur on the background.
  102128. */
  102129. enableNoise: boolean;
  102130. /**
  102131. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102132. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102133. * Recommended to be keep at 1.0 except for special cases.
  102134. */
  102135. fovMultiplier: number;
  102136. private _fovMultiplier;
  102137. /**
  102138. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102139. */
  102140. useEquirectangularFOV: boolean;
  102141. private _maxSimultaneousLights;
  102142. /**
  102143. * Number of Simultaneous lights allowed on the material.
  102144. */
  102145. maxSimultaneousLights: int;
  102146. /**
  102147. * Default configuration related to image processing available in the Background Material.
  102148. */
  102149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102150. /**
  102151. * Keep track of the image processing observer to allow dispose and replace.
  102152. */
  102153. private _imageProcessingObserver;
  102154. /**
  102155. * Attaches a new image processing configuration to the PBR Material.
  102156. * @param configuration (if null the scene configuration will be use)
  102157. */
  102158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102159. /**
  102160. * Gets the image processing configuration used either in this material.
  102161. */
  102162. /**
  102163. * Sets the Default image processing configuration used either in the this material.
  102164. *
  102165. * If sets to null, the scene one is in use.
  102166. */
  102167. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102168. /**
  102169. * Gets wether the color curves effect is enabled.
  102170. */
  102171. /**
  102172. * Sets wether the color curves effect is enabled.
  102173. */
  102174. cameraColorCurvesEnabled: boolean;
  102175. /**
  102176. * Gets wether the color grading effect is enabled.
  102177. */
  102178. /**
  102179. * Gets wether the color grading effect is enabled.
  102180. */
  102181. cameraColorGradingEnabled: boolean;
  102182. /**
  102183. * Gets wether tonemapping is enabled or not.
  102184. */
  102185. /**
  102186. * Sets wether tonemapping is enabled or not
  102187. */
  102188. cameraToneMappingEnabled: boolean;
  102189. /**
  102190. * The camera exposure used on this material.
  102191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102192. * This corresponds to a photographic exposure.
  102193. */
  102194. /**
  102195. * The camera exposure used on this material.
  102196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102197. * This corresponds to a photographic exposure.
  102198. */
  102199. cameraExposure: float;
  102200. /**
  102201. * Gets The camera contrast used on this material.
  102202. */
  102203. /**
  102204. * Sets The camera contrast used on this material.
  102205. */
  102206. cameraContrast: float;
  102207. /**
  102208. * Gets the Color Grading 2D Lookup Texture.
  102209. */
  102210. /**
  102211. * Sets the Color Grading 2D Lookup Texture.
  102212. */
  102213. cameraColorGradingTexture: Nullable<BaseTexture>;
  102214. /**
  102215. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102216. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102217. * 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;
  102218. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102219. */
  102220. /**
  102221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102223. * 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;
  102224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102225. */
  102226. cameraColorCurves: Nullable<ColorCurves>;
  102227. /**
  102228. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102229. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102230. */
  102231. switchToBGR: boolean;
  102232. private _renderTargets;
  102233. private _reflectionControls;
  102234. private _white;
  102235. private _primaryShadowColor;
  102236. private _primaryHighlightColor;
  102237. /**
  102238. * Instantiates a Background Material in the given scene
  102239. * @param name The friendly name of the material
  102240. * @param scene The scene to add the material to
  102241. */
  102242. constructor(name: string, scene: Scene);
  102243. /**
  102244. * Gets a boolean indicating that current material needs to register RTT
  102245. */
  102246. readonly hasRenderTargetTextures: boolean;
  102247. /**
  102248. * The entire material has been created in order to prevent overdraw.
  102249. * @returns false
  102250. */
  102251. needAlphaTesting(): boolean;
  102252. /**
  102253. * The entire material has been created in order to prevent overdraw.
  102254. * @returns true if blending is enable
  102255. */
  102256. needAlphaBlending(): boolean;
  102257. /**
  102258. * Checks wether the material is ready to be rendered for a given mesh.
  102259. * @param mesh The mesh to render
  102260. * @param subMesh The submesh to check against
  102261. * @param useInstances Specify wether or not the material is used with instances
  102262. * @returns true if all the dependencies are ready (Textures, Effects...)
  102263. */
  102264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102265. /**
  102266. * Compute the primary color according to the chosen perceptual color.
  102267. */
  102268. private _computePrimaryColorFromPerceptualColor;
  102269. /**
  102270. * Compute the highlights and shadow colors according to their chosen levels.
  102271. */
  102272. private _computePrimaryColors;
  102273. /**
  102274. * Build the uniform buffer used in the material.
  102275. */
  102276. buildUniformLayout(): void;
  102277. /**
  102278. * Unbind the material.
  102279. */
  102280. unbind(): void;
  102281. /**
  102282. * Bind only the world matrix to the material.
  102283. * @param world The world matrix to bind.
  102284. */
  102285. bindOnlyWorldMatrix(world: Matrix): void;
  102286. /**
  102287. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102288. * @param world The world matrix to bind.
  102289. * @param subMesh The submesh to bind for.
  102290. */
  102291. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102292. /**
  102293. * Dispose the material.
  102294. * @param forceDisposeEffect Force disposal of the associated effect.
  102295. * @param forceDisposeTextures Force disposal of the associated textures.
  102296. */
  102297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102298. /**
  102299. * Clones the material.
  102300. * @param name The cloned name.
  102301. * @returns The cloned material.
  102302. */
  102303. clone(name: string): BackgroundMaterial;
  102304. /**
  102305. * Serializes the current material to its JSON representation.
  102306. * @returns The JSON representation.
  102307. */
  102308. serialize(): any;
  102309. /**
  102310. * Gets the class name of the material
  102311. * @returns "BackgroundMaterial"
  102312. */
  102313. getClassName(): string;
  102314. /**
  102315. * Parse a JSON input to create back a background material.
  102316. * @param source The JSON data to parse
  102317. * @param scene The scene to create the parsed material in
  102318. * @param rootUrl The root url of the assets the material depends upon
  102319. * @returns the instantiated BackgroundMaterial.
  102320. */
  102321. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102322. }
  102323. }
  102324. declare module BABYLON {
  102325. /**
  102326. * Represents the different options available during the creation of
  102327. * a Environment helper.
  102328. *
  102329. * This can control the default ground, skybox and image processing setup of your scene.
  102330. */
  102331. export interface IEnvironmentHelperOptions {
  102332. /**
  102333. * Specifies wether or not to create a ground.
  102334. * True by default.
  102335. */
  102336. createGround: boolean;
  102337. /**
  102338. * Specifies the ground size.
  102339. * 15 by default.
  102340. */
  102341. groundSize: number;
  102342. /**
  102343. * The texture used on the ground for the main color.
  102344. * Comes from the BabylonJS CDN by default.
  102345. *
  102346. * Remarks: Can be either a texture or a url.
  102347. */
  102348. groundTexture: string | BaseTexture;
  102349. /**
  102350. * The color mixed in the ground texture by default.
  102351. * BabylonJS clearColor by default.
  102352. */
  102353. groundColor: Color3;
  102354. /**
  102355. * Specifies the ground opacity.
  102356. * 1 by default.
  102357. */
  102358. groundOpacity: number;
  102359. /**
  102360. * Enables the ground to receive shadows.
  102361. * True by default.
  102362. */
  102363. enableGroundShadow: boolean;
  102364. /**
  102365. * Helps preventing the shadow to be fully black on the ground.
  102366. * 0.5 by default.
  102367. */
  102368. groundShadowLevel: number;
  102369. /**
  102370. * Creates a mirror texture attach to the ground.
  102371. * false by default.
  102372. */
  102373. enableGroundMirror: boolean;
  102374. /**
  102375. * Specifies the ground mirror size ratio.
  102376. * 0.3 by default as the default kernel is 64.
  102377. */
  102378. groundMirrorSizeRatio: number;
  102379. /**
  102380. * Specifies the ground mirror blur kernel size.
  102381. * 64 by default.
  102382. */
  102383. groundMirrorBlurKernel: number;
  102384. /**
  102385. * Specifies the ground mirror visibility amount.
  102386. * 1 by default
  102387. */
  102388. groundMirrorAmount: number;
  102389. /**
  102390. * Specifies the ground mirror reflectance weight.
  102391. * This uses the standard weight of the background material to setup the fresnel effect
  102392. * of the mirror.
  102393. * 1 by default.
  102394. */
  102395. groundMirrorFresnelWeight: number;
  102396. /**
  102397. * Specifies the ground mirror Falloff distance.
  102398. * This can helps reducing the size of the reflection.
  102399. * 0 by Default.
  102400. */
  102401. groundMirrorFallOffDistance: number;
  102402. /**
  102403. * Specifies the ground mirror texture type.
  102404. * Unsigned Int by Default.
  102405. */
  102406. groundMirrorTextureType: number;
  102407. /**
  102408. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102409. * the shown objects.
  102410. */
  102411. groundYBias: number;
  102412. /**
  102413. * Specifies wether or not to create a skybox.
  102414. * True by default.
  102415. */
  102416. createSkybox: boolean;
  102417. /**
  102418. * Specifies the skybox size.
  102419. * 20 by default.
  102420. */
  102421. skyboxSize: number;
  102422. /**
  102423. * The texture used on the skybox for the main color.
  102424. * Comes from the BabylonJS CDN by default.
  102425. *
  102426. * Remarks: Can be either a texture or a url.
  102427. */
  102428. skyboxTexture: string | BaseTexture;
  102429. /**
  102430. * The color mixed in the skybox texture by default.
  102431. * BabylonJS clearColor by default.
  102432. */
  102433. skyboxColor: Color3;
  102434. /**
  102435. * The background rotation around the Y axis of the scene.
  102436. * This helps aligning the key lights of your scene with the background.
  102437. * 0 by default.
  102438. */
  102439. backgroundYRotation: number;
  102440. /**
  102441. * Compute automatically the size of the elements to best fit with the scene.
  102442. */
  102443. sizeAuto: boolean;
  102444. /**
  102445. * Default position of the rootMesh if autoSize is not true.
  102446. */
  102447. rootPosition: Vector3;
  102448. /**
  102449. * Sets up the image processing in the scene.
  102450. * true by default.
  102451. */
  102452. setupImageProcessing: boolean;
  102453. /**
  102454. * The texture used as your environment texture in the scene.
  102455. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102456. *
  102457. * Remarks: Can be either a texture or a url.
  102458. */
  102459. environmentTexture: string | BaseTexture;
  102460. /**
  102461. * The value of the exposure to apply to the scene.
  102462. * 0.6 by default if setupImageProcessing is true.
  102463. */
  102464. cameraExposure: number;
  102465. /**
  102466. * The value of the contrast to apply to the scene.
  102467. * 1.6 by default if setupImageProcessing is true.
  102468. */
  102469. cameraContrast: number;
  102470. /**
  102471. * Specifies wether or not tonemapping should be enabled in the scene.
  102472. * true by default if setupImageProcessing is true.
  102473. */
  102474. toneMappingEnabled: boolean;
  102475. }
  102476. /**
  102477. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102478. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102479. * It also helps with the default setup of your imageProcessing configuration.
  102480. */
  102481. export class EnvironmentHelper {
  102482. /**
  102483. * Default ground texture URL.
  102484. */
  102485. private static _groundTextureCDNUrl;
  102486. /**
  102487. * Default skybox texture URL.
  102488. */
  102489. private static _skyboxTextureCDNUrl;
  102490. /**
  102491. * Default environment texture URL.
  102492. */
  102493. private static _environmentTextureCDNUrl;
  102494. /**
  102495. * Creates the default options for the helper.
  102496. */
  102497. private static _getDefaultOptions;
  102498. private _rootMesh;
  102499. /**
  102500. * Gets the root mesh created by the helper.
  102501. */
  102502. readonly rootMesh: Mesh;
  102503. private _skybox;
  102504. /**
  102505. * Gets the skybox created by the helper.
  102506. */
  102507. readonly skybox: Nullable<Mesh>;
  102508. private _skyboxTexture;
  102509. /**
  102510. * Gets the skybox texture created by the helper.
  102511. */
  102512. readonly skyboxTexture: Nullable<BaseTexture>;
  102513. private _skyboxMaterial;
  102514. /**
  102515. * Gets the skybox material created by the helper.
  102516. */
  102517. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102518. private _ground;
  102519. /**
  102520. * Gets the ground mesh created by the helper.
  102521. */
  102522. readonly ground: Nullable<Mesh>;
  102523. private _groundTexture;
  102524. /**
  102525. * Gets the ground texture created by the helper.
  102526. */
  102527. readonly groundTexture: Nullable<BaseTexture>;
  102528. private _groundMirror;
  102529. /**
  102530. * Gets the ground mirror created by the helper.
  102531. */
  102532. readonly groundMirror: Nullable<MirrorTexture>;
  102533. /**
  102534. * Gets the ground mirror render list to helps pushing the meshes
  102535. * you wish in the ground reflection.
  102536. */
  102537. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102538. private _groundMaterial;
  102539. /**
  102540. * Gets the ground material created by the helper.
  102541. */
  102542. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102543. /**
  102544. * Stores the creation options.
  102545. */
  102546. private readonly _scene;
  102547. private _options;
  102548. /**
  102549. * This observable will be notified with any error during the creation of the environment,
  102550. * mainly texture creation errors.
  102551. */
  102552. onErrorObservable: Observable<{
  102553. message?: string;
  102554. exception?: any;
  102555. }>;
  102556. /**
  102557. * constructor
  102558. * @param options Defines the options we want to customize the helper
  102559. * @param scene The scene to add the material to
  102560. */
  102561. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102562. /**
  102563. * Updates the background according to the new options
  102564. * @param options
  102565. */
  102566. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102567. /**
  102568. * Sets the primary color of all the available elements.
  102569. * @param color the main color to affect to the ground and the background
  102570. */
  102571. setMainColor(color: Color3): void;
  102572. /**
  102573. * Setup the image processing according to the specified options.
  102574. */
  102575. private _setupImageProcessing;
  102576. /**
  102577. * Setup the environment texture according to the specified options.
  102578. */
  102579. private _setupEnvironmentTexture;
  102580. /**
  102581. * Setup the background according to the specified options.
  102582. */
  102583. private _setupBackground;
  102584. /**
  102585. * Get the scene sizes according to the setup.
  102586. */
  102587. private _getSceneSize;
  102588. /**
  102589. * Setup the ground according to the specified options.
  102590. */
  102591. private _setupGround;
  102592. /**
  102593. * Setup the ground material according to the specified options.
  102594. */
  102595. private _setupGroundMaterial;
  102596. /**
  102597. * Setup the ground diffuse texture according to the specified options.
  102598. */
  102599. private _setupGroundDiffuseTexture;
  102600. /**
  102601. * Setup the ground mirror texture according to the specified options.
  102602. */
  102603. private _setupGroundMirrorTexture;
  102604. /**
  102605. * Setup the ground to receive the mirror texture.
  102606. */
  102607. private _setupMirrorInGroundMaterial;
  102608. /**
  102609. * Setup the skybox according to the specified options.
  102610. */
  102611. private _setupSkybox;
  102612. /**
  102613. * Setup the skybox material according to the specified options.
  102614. */
  102615. private _setupSkyboxMaterial;
  102616. /**
  102617. * Setup the skybox reflection texture according to the specified options.
  102618. */
  102619. private _setupSkyboxReflectionTexture;
  102620. private _errorHandler;
  102621. /**
  102622. * Dispose all the elements created by the Helper.
  102623. */
  102624. dispose(): void;
  102625. }
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102630. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102631. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102632. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102633. */
  102634. export class PhotoDome extends TransformNode {
  102635. private _useDirectMapping;
  102636. /**
  102637. * The texture being displayed on the sphere
  102638. */
  102639. protected _photoTexture: Texture;
  102640. /**
  102641. * Gets or sets the texture being displayed on the sphere
  102642. */
  102643. photoTexture: Texture;
  102644. /**
  102645. * Observable raised when an error occured while loading the 360 image
  102646. */
  102647. onLoadErrorObservable: Observable<string>;
  102648. /**
  102649. * The skybox material
  102650. */
  102651. protected _material: BackgroundMaterial;
  102652. /**
  102653. * The surface used for the skybox
  102654. */
  102655. protected _mesh: Mesh;
  102656. /**
  102657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102658. * Also see the options.resolution property.
  102659. */
  102660. fovMultiplier: number;
  102661. /**
  102662. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102663. * @param name Element's name, child elements will append suffixes for their own names.
  102664. * @param urlsOfPhoto defines the url of the photo to display
  102665. * @param options defines an object containing optional or exposed sub element properties
  102666. * @param onError defines a callback called when an error occured while loading the texture
  102667. */
  102668. constructor(name: string, urlOfPhoto: string, options: {
  102669. resolution?: number;
  102670. size?: number;
  102671. useDirectMapping?: boolean;
  102672. faceForward?: boolean;
  102673. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102674. /**
  102675. * Releases resources associated with this node.
  102676. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102677. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102678. */
  102679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102680. }
  102681. }
  102682. declare module BABYLON {
  102683. /**
  102684. * Class used to host texture specific utilities
  102685. */
  102686. export class BRDFTextureTools {
  102687. /**
  102688. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102689. * @param texture the texture to expand.
  102690. */
  102691. private static _ExpandDefaultBRDFTexture;
  102692. /**
  102693. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102694. * @param scene defines the hosting scene
  102695. * @returns the environment BRDF texture
  102696. */
  102697. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102698. private static _environmentBRDFBase64Texture;
  102699. }
  102700. }
  102701. declare module BABYLON {
  102702. /**
  102703. * @hidden
  102704. */
  102705. export interface IMaterialClearCoatDefines {
  102706. CLEARCOAT: boolean;
  102707. CLEARCOAT_DEFAULTIOR: boolean;
  102708. CLEARCOAT_TEXTURE: boolean;
  102709. CLEARCOAT_TEXTUREDIRECTUV: number;
  102710. CLEARCOAT_BUMP: boolean;
  102711. CLEARCOAT_BUMPDIRECTUV: number;
  102712. CLEARCOAT_TINT: boolean;
  102713. CLEARCOAT_TINT_TEXTURE: boolean;
  102714. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102715. /** @hidden */
  102716. _areTexturesDirty: boolean;
  102717. }
  102718. /**
  102719. * Define the code related to the clear coat parameters of the pbr material.
  102720. */
  102721. export class PBRClearCoatConfiguration {
  102722. /**
  102723. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102724. * The default fits with a polyurethane material.
  102725. */
  102726. private static readonly _DefaultIndiceOfRefraction;
  102727. private _isEnabled;
  102728. /**
  102729. * Defines if the clear coat is enabled in the material.
  102730. */
  102731. isEnabled: boolean;
  102732. /**
  102733. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  102734. */
  102735. intensity: number;
  102736. /**
  102737. * Defines the clear coat layer roughness.
  102738. */
  102739. roughness: number;
  102740. private _indiceOfRefraction;
  102741. /**
  102742. * Defines the indice of refraction of the clear coat.
  102743. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102744. * The default fits with a polyurethane material.
  102745. * Changing the default value is more performance intensive.
  102746. */
  102747. indiceOfRefraction: number;
  102748. private _texture;
  102749. /**
  102750. * Stores the clear coat values in a texture.
  102751. */
  102752. texture: Nullable<BaseTexture>;
  102753. private _bumpTexture;
  102754. /**
  102755. * Define the clear coat specific bump texture.
  102756. */
  102757. bumpTexture: Nullable<BaseTexture>;
  102758. private _isTintEnabled;
  102759. /**
  102760. * Defines if the clear coat tint is enabled in the material.
  102761. */
  102762. isTintEnabled: boolean;
  102763. /**
  102764. * Defines if the clear coat tint is enabled in the material.
  102765. * This is only use if tint is enabled
  102766. */
  102767. tintColor: Color3;
  102768. /**
  102769. * Defines if the distance at which the tint color should be found in the
  102770. * clear coat media.
  102771. * This is only use if tint is enabled
  102772. */
  102773. tintColorAtDistance: number;
  102774. /**
  102775. * Defines the clear coat layer thickness.
  102776. * This is only use if tint is enabled
  102777. */
  102778. tintThickness: number;
  102779. private _tintTexture;
  102780. /**
  102781. * Stores the clear tint values in a texture.
  102782. * rgb is tint
  102783. * a is a thickness factor
  102784. */
  102785. tintTexture: Nullable<BaseTexture>;
  102786. /** @hidden */
  102787. private _internalMarkAllSubMeshesAsTexturesDirty;
  102788. /** @hidden */
  102789. _markAllSubMeshesAsTexturesDirty(): void;
  102790. /**
  102791. * Instantiate a new istance of clear coat configuration.
  102792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102793. */
  102794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102795. /**
  102796. * Specifies that the submesh is ready to be used.
  102797. * @param defines the list of "defines" to update.
  102798. * @param scene defines the scene the material belongs to.
  102799. * @param engine defines the engine the material belongs to.
  102800. * @param disableBumpMap defines wether the material disables bump or not.
  102801. * @returns - boolean indicating that the submesh is ready or not.
  102802. */
  102803. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  102804. /**
  102805. * Checks to see if a texture is used in the material.
  102806. * @param defines the list of "defines" to update.
  102807. * @param scene defines the scene to the material belongs to.
  102808. */
  102809. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  102810. /**
  102811. * Binds the material data.
  102812. * @param uniformBuffer defines the Uniform buffer to fill in.
  102813. * @param scene defines the scene the material belongs to.
  102814. * @param engine defines the engine the material belongs to.
  102815. * @param disableBumpMap defines wether the material disables bump or not.
  102816. * @param isFrozen defines wether the material is frozen or not.
  102817. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102818. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102819. */
  102820. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  102821. /**
  102822. * Checks to see if a texture is used in the material.
  102823. * @param texture - Base texture to use.
  102824. * @returns - Boolean specifying if a texture is used in the material.
  102825. */
  102826. hasTexture(texture: BaseTexture): boolean;
  102827. /**
  102828. * Returns an array of the actively used textures.
  102829. * @param activeTextures Array of BaseTextures
  102830. */
  102831. getActiveTextures(activeTextures: BaseTexture[]): void;
  102832. /**
  102833. * Returns the animatable textures.
  102834. * @param animatables Array of animatable textures.
  102835. */
  102836. getAnimatables(animatables: IAnimatable[]): void;
  102837. /**
  102838. * Disposes the resources of the material.
  102839. * @param forceDisposeTextures - Forces the disposal of all textures.
  102840. */
  102841. dispose(forceDisposeTextures?: boolean): void;
  102842. /**
  102843. * Get the current class name of the texture useful for serialization or dynamic coding.
  102844. * @returns "PBRClearCoatConfiguration"
  102845. */
  102846. getClassName(): string;
  102847. /**
  102848. * Add fallbacks to the effect fallbacks list.
  102849. * @param defines defines the Base texture to use.
  102850. * @param fallbacks defines the current fallback list.
  102851. * @param currentRank defines the current fallback rank.
  102852. * @returns the new fallback rank.
  102853. */
  102854. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102855. /**
  102856. * Add the required uniforms to the current list.
  102857. * @param uniforms defines the current uniform list.
  102858. */
  102859. static AddUniforms(uniforms: string[]): void;
  102860. /**
  102861. * Add the required samplers to the current list.
  102862. * @param samplers defines the current sampler list.
  102863. */
  102864. static AddSamplers(samplers: string[]): void;
  102865. /**
  102866. * Add the required uniforms to the current buffer.
  102867. * @param uniformBuffer defines the current uniform buffer.
  102868. */
  102869. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102870. /**
  102871. * Makes a duplicate of the current configuration into another one.
  102872. * @param clearCoatConfiguration define the config where to copy the info
  102873. */
  102874. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  102875. /**
  102876. * Serializes this clear coat configuration.
  102877. * @returns - An object with the serialized config.
  102878. */
  102879. serialize(): any;
  102880. /**
  102881. * Parses a Clear Coat Configuration from a serialized object.
  102882. * @param source - Serialized object.
  102883. */
  102884. parse(source: any): void;
  102885. }
  102886. }
  102887. declare module BABYLON {
  102888. /**
  102889. * @hidden
  102890. */
  102891. export interface IMaterialAnisotropicDefines {
  102892. ANISOTROPIC: boolean;
  102893. ANISOTROPIC_TEXTURE: boolean;
  102894. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102895. MAINUV1: boolean;
  102896. _areTexturesDirty: boolean;
  102897. _needUVs: boolean;
  102898. }
  102899. /**
  102900. * Define the code related to the anisotropic parameters of the pbr material.
  102901. */
  102902. export class PBRAnisotropicConfiguration {
  102903. private _isEnabled;
  102904. /**
  102905. * Defines if the anisotropy is enabled in the material.
  102906. */
  102907. isEnabled: boolean;
  102908. /**
  102909. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  102910. */
  102911. intensity: number;
  102912. /**
  102913. * Defines if the effect is along the tangents, bitangents or in between.
  102914. * By default, the effect is "strectching" the highlights along the tangents.
  102915. */
  102916. direction: Vector2;
  102917. private _texture;
  102918. /**
  102919. * Stores the anisotropy values in a texture.
  102920. * rg is direction (like normal from -1 to 1)
  102921. * b is a intensity
  102922. */
  102923. texture: Nullable<BaseTexture>;
  102924. /** @hidden */
  102925. private _internalMarkAllSubMeshesAsTexturesDirty;
  102926. /** @hidden */
  102927. _markAllSubMeshesAsTexturesDirty(): void;
  102928. /**
  102929. * Instantiate a new istance of anisotropy configuration.
  102930. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102931. */
  102932. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102933. /**
  102934. * Specifies that the submesh is ready to be used.
  102935. * @param defines the list of "defines" to update.
  102936. * @param scene defines the scene the material belongs to.
  102937. * @returns - boolean indicating that the submesh is ready or not.
  102938. */
  102939. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  102940. /**
  102941. * Checks to see if a texture is used in the material.
  102942. * @param defines the list of "defines" to update.
  102943. * @param mesh the mesh we are preparing the defines for.
  102944. * @param scene defines the scene the material belongs to.
  102945. */
  102946. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  102947. /**
  102948. * Binds the material data.
  102949. * @param uniformBuffer defines the Uniform buffer to fill in.
  102950. * @param scene defines the scene the material belongs to.
  102951. * @param isFrozen defines wether the material is frozen or not.
  102952. */
  102953. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102954. /**
  102955. * Checks to see if a texture is used in the material.
  102956. * @param texture - Base texture to use.
  102957. * @returns - Boolean specifying if a texture is used in the material.
  102958. */
  102959. hasTexture(texture: BaseTexture): boolean;
  102960. /**
  102961. * Returns an array of the actively used textures.
  102962. * @param activeTextures Array of BaseTextures
  102963. */
  102964. getActiveTextures(activeTextures: BaseTexture[]): void;
  102965. /**
  102966. * Returns the animatable textures.
  102967. * @param animatables Array of animatable textures.
  102968. */
  102969. getAnimatables(animatables: IAnimatable[]): void;
  102970. /**
  102971. * Disposes the resources of the material.
  102972. * @param forceDisposeTextures - Forces the disposal of all textures.
  102973. */
  102974. dispose(forceDisposeTextures?: boolean): void;
  102975. /**
  102976. * Get the current class name of the texture useful for serialization or dynamic coding.
  102977. * @returns "PBRAnisotropicConfiguration"
  102978. */
  102979. getClassName(): string;
  102980. /**
  102981. * Add fallbacks to the effect fallbacks list.
  102982. * @param defines defines the Base texture to use.
  102983. * @param fallbacks defines the current fallback list.
  102984. * @param currentRank defines the current fallback rank.
  102985. * @returns the new fallback rank.
  102986. */
  102987. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102988. /**
  102989. * Add the required uniforms to the current list.
  102990. * @param uniforms defines the current uniform list.
  102991. */
  102992. static AddUniforms(uniforms: string[]): void;
  102993. /**
  102994. * Add the required uniforms to the current buffer.
  102995. * @param uniformBuffer defines the current uniform buffer.
  102996. */
  102997. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102998. /**
  102999. * Add the required samplers to the current list.
  103000. * @param samplers defines the current sampler list.
  103001. */
  103002. static AddSamplers(samplers: string[]): void;
  103003. /**
  103004. * Makes a duplicate of the current configuration into another one.
  103005. * @param anisotropicConfiguration define the config where to copy the info
  103006. */
  103007. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103008. /**
  103009. * Serializes this anisotropy configuration.
  103010. * @returns - An object with the serialized config.
  103011. */
  103012. serialize(): any;
  103013. /**
  103014. * Parses a anisotropy Configuration from a serialized object.
  103015. * @param source - Serialized object.
  103016. */
  103017. parse(source: any): void;
  103018. }
  103019. }
  103020. declare module BABYLON {
  103021. /**
  103022. * @hidden
  103023. */
  103024. export interface IMaterialBRDFDefines {
  103025. BRDF_V_HEIGHT_CORRELATED: boolean;
  103026. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103027. /** @hidden */
  103028. _areMiscDirty: boolean;
  103029. }
  103030. /**
  103031. * Define the code related to the BRDF parameters of the pbr material.
  103032. */
  103033. export class PBRBRDFConfiguration {
  103034. /**
  103035. * Default value used for the energy conservation.
  103036. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103037. */
  103038. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103039. /**
  103040. * Default value used for the Smith Visibility Height Correlated mode.
  103041. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103042. */
  103043. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103044. private _useEnergyConservation;
  103045. /**
  103046. * Defines if the material uses energy conservation.
  103047. */
  103048. useEnergyConservation: boolean;
  103049. private _useSmithVisibilityHeightCorrelated;
  103050. /**
  103051. * LEGACY Mode set to false
  103052. * Defines if the material uses height smith correlated visibility term.
  103053. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103054. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103055. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103056. * Not relying on height correlated will also disable energy conservation.
  103057. */
  103058. useSmithVisibilityHeightCorrelated: boolean;
  103059. /** @hidden */
  103060. private _internalMarkAllSubMeshesAsMiscDirty;
  103061. /** @hidden */
  103062. _markAllSubMeshesAsMiscDirty(): void;
  103063. /**
  103064. * Instantiate a new istance of clear coat configuration.
  103065. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103066. */
  103067. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103068. /**
  103069. * Checks to see if a texture is used in the material.
  103070. * @param defines the list of "defines" to update.
  103071. */
  103072. prepareDefines(defines: IMaterialBRDFDefines): void;
  103073. /**
  103074. * Get the current class name of the texture useful for serialization or dynamic coding.
  103075. * @returns "PBRClearCoatConfiguration"
  103076. */
  103077. getClassName(): string;
  103078. /**
  103079. * Makes a duplicate of the current configuration into another one.
  103080. * @param brdfConfiguration define the config where to copy the info
  103081. */
  103082. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103083. /**
  103084. * Serializes this BRDF configuration.
  103085. * @returns - An object with the serialized config.
  103086. */
  103087. serialize(): any;
  103088. /**
  103089. * Parses a BRDF Configuration from a serialized object.
  103090. * @param source - Serialized object.
  103091. */
  103092. parse(source: any): void;
  103093. }
  103094. }
  103095. declare module BABYLON {
  103096. /**
  103097. * @hidden
  103098. */
  103099. export interface IMaterialSheenDefines {
  103100. SHEEN: boolean;
  103101. SHEEN_TEXTURE: boolean;
  103102. SHEEN_TEXTUREDIRECTUV: number;
  103103. SHEEN_LINKWITHALBEDO: boolean;
  103104. /** @hidden */
  103105. _areTexturesDirty: boolean;
  103106. }
  103107. /**
  103108. * Define the code related to the Sheen parameters of the pbr material.
  103109. */
  103110. export class PBRSheenConfiguration {
  103111. private _isEnabled;
  103112. /**
  103113. * Defines if the material uses sheen.
  103114. */
  103115. isEnabled: boolean;
  103116. private _linkSheenWithAlbedo;
  103117. /**
  103118. * Defines if the sheen is linked to the sheen color.
  103119. */
  103120. linkSheenWithAlbedo: boolean;
  103121. /**
  103122. * Defines the sheen intensity.
  103123. */
  103124. intensity: number;
  103125. /**
  103126. * Defines the sheen color.
  103127. */
  103128. color: Color3;
  103129. private _texture;
  103130. /**
  103131. * Stores the sheen tint values in a texture.
  103132. * rgb is tint
  103133. * a is a intensity
  103134. */
  103135. texture: Nullable<BaseTexture>;
  103136. /** @hidden */
  103137. private _internalMarkAllSubMeshesAsTexturesDirty;
  103138. /** @hidden */
  103139. _markAllSubMeshesAsTexturesDirty(): void;
  103140. /**
  103141. * Instantiate a new istance of clear coat configuration.
  103142. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103143. */
  103144. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103145. /**
  103146. * Specifies that the submesh is ready to be used.
  103147. * @param defines the list of "defines" to update.
  103148. * @param scene defines the scene the material belongs to.
  103149. * @returns - boolean indicating that the submesh is ready or not.
  103150. */
  103151. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103152. /**
  103153. * Checks to see if a texture is used in the material.
  103154. * @param defines the list of "defines" to update.
  103155. * @param scene defines the scene the material belongs to.
  103156. */
  103157. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103158. /**
  103159. * Binds the material data.
  103160. * @param uniformBuffer defines the Uniform buffer to fill in.
  103161. * @param scene defines the scene the material belongs to.
  103162. * @param isFrozen defines wether the material is frozen or not.
  103163. */
  103164. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103165. /**
  103166. * Checks to see if a texture is used in the material.
  103167. * @param texture - Base texture to use.
  103168. * @returns - Boolean specifying if a texture is used in the material.
  103169. */
  103170. hasTexture(texture: BaseTexture): boolean;
  103171. /**
  103172. * Returns an array of the actively used textures.
  103173. * @param activeTextures Array of BaseTextures
  103174. */
  103175. getActiveTextures(activeTextures: BaseTexture[]): void;
  103176. /**
  103177. * Returns the animatable textures.
  103178. * @param animatables Array of animatable textures.
  103179. */
  103180. getAnimatables(animatables: IAnimatable[]): void;
  103181. /**
  103182. * Disposes the resources of the material.
  103183. * @param forceDisposeTextures - Forces the disposal of all textures.
  103184. */
  103185. dispose(forceDisposeTextures?: boolean): void;
  103186. /**
  103187. * Get the current class name of the texture useful for serialization or dynamic coding.
  103188. * @returns "PBRSheenConfiguration"
  103189. */
  103190. getClassName(): string;
  103191. /**
  103192. * Add fallbacks to the effect fallbacks list.
  103193. * @param defines defines the Base texture to use.
  103194. * @param fallbacks defines the current fallback list.
  103195. * @param currentRank defines the current fallback rank.
  103196. * @returns the new fallback rank.
  103197. */
  103198. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103199. /**
  103200. * Add the required uniforms to the current list.
  103201. * @param uniforms defines the current uniform list.
  103202. */
  103203. static AddUniforms(uniforms: string[]): void;
  103204. /**
  103205. * Add the required uniforms to the current buffer.
  103206. * @param uniformBuffer defines the current uniform buffer.
  103207. */
  103208. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103209. /**
  103210. * Add the required samplers to the current list.
  103211. * @param samplers defines the current sampler list.
  103212. */
  103213. static AddSamplers(samplers: string[]): void;
  103214. /**
  103215. * Makes a duplicate of the current configuration into another one.
  103216. * @param sheenConfiguration define the config where to copy the info
  103217. */
  103218. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103219. /**
  103220. * Serializes this BRDF configuration.
  103221. * @returns - An object with the serialized config.
  103222. */
  103223. serialize(): any;
  103224. /**
  103225. * Parses a Sheen Configuration from a serialized object.
  103226. * @param source - Serialized object.
  103227. */
  103228. parse(source: any): void;
  103229. }
  103230. }
  103231. declare module BABYLON {
  103232. /** @hidden */
  103233. export var pbrFragmentDeclaration: {
  103234. name: string;
  103235. shader: string;
  103236. };
  103237. }
  103238. declare module BABYLON {
  103239. /** @hidden */
  103240. export var pbrUboDeclaration: {
  103241. name: string;
  103242. shader: string;
  103243. };
  103244. }
  103245. declare module BABYLON {
  103246. /** @hidden */
  103247. export var pbrFragmentExtraDeclaration: {
  103248. name: string;
  103249. shader: string;
  103250. };
  103251. }
  103252. declare module BABYLON {
  103253. /** @hidden */
  103254. export var pbrFragmentSamplersDeclaration: {
  103255. name: string;
  103256. shader: string;
  103257. };
  103258. }
  103259. declare module BABYLON {
  103260. /** @hidden */
  103261. export var pbrHelperFunctions: {
  103262. name: string;
  103263. shader: string;
  103264. };
  103265. }
  103266. declare module BABYLON {
  103267. /** @hidden */
  103268. export var harmonicsFunctions: {
  103269. name: string;
  103270. shader: string;
  103271. };
  103272. }
  103273. declare module BABYLON {
  103274. /** @hidden */
  103275. export var pbrDirectLightingSetupFunctions: {
  103276. name: string;
  103277. shader: string;
  103278. };
  103279. }
  103280. declare module BABYLON {
  103281. /** @hidden */
  103282. export var pbrDirectLightingFalloffFunctions: {
  103283. name: string;
  103284. shader: string;
  103285. };
  103286. }
  103287. declare module BABYLON {
  103288. /** @hidden */
  103289. export var pbrBRDFFunctions: {
  103290. name: string;
  103291. shader: string;
  103292. };
  103293. }
  103294. declare module BABYLON {
  103295. /** @hidden */
  103296. export var pbrDirectLightingFunctions: {
  103297. name: string;
  103298. shader: string;
  103299. };
  103300. }
  103301. declare module BABYLON {
  103302. /** @hidden */
  103303. export var pbrIBLFunctions: {
  103304. name: string;
  103305. shader: string;
  103306. };
  103307. }
  103308. declare module BABYLON {
  103309. /** @hidden */
  103310. export var pbrDebug: {
  103311. name: string;
  103312. shader: string;
  103313. };
  103314. }
  103315. declare module BABYLON {
  103316. /** @hidden */
  103317. export var pbrPixelShader: {
  103318. name: string;
  103319. shader: string;
  103320. };
  103321. }
  103322. declare module BABYLON {
  103323. /** @hidden */
  103324. export var pbrVertexDeclaration: {
  103325. name: string;
  103326. shader: string;
  103327. };
  103328. }
  103329. declare module BABYLON {
  103330. /** @hidden */
  103331. export var pbrVertexShader: {
  103332. name: string;
  103333. shader: string;
  103334. };
  103335. }
  103336. declare module BABYLON {
  103337. /**
  103338. * Manages the defines for the PBR Material.
  103339. * @hidden
  103340. */
  103341. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  103342. PBR: boolean;
  103343. MAINUV1: boolean;
  103344. MAINUV2: boolean;
  103345. UV1: boolean;
  103346. UV2: boolean;
  103347. ALBEDO: boolean;
  103348. ALBEDODIRECTUV: number;
  103349. VERTEXCOLOR: boolean;
  103350. AMBIENT: boolean;
  103351. AMBIENTDIRECTUV: number;
  103352. AMBIENTINGRAYSCALE: boolean;
  103353. OPACITY: boolean;
  103354. VERTEXALPHA: boolean;
  103355. OPACITYDIRECTUV: number;
  103356. OPACITYRGB: boolean;
  103357. ALPHATEST: boolean;
  103358. DEPTHPREPASS: boolean;
  103359. ALPHABLEND: boolean;
  103360. ALPHAFROMALBEDO: boolean;
  103361. ALPHATESTVALUE: string;
  103362. SPECULAROVERALPHA: boolean;
  103363. RADIANCEOVERALPHA: boolean;
  103364. ALPHAFRESNEL: boolean;
  103365. LINEARALPHAFRESNEL: boolean;
  103366. PREMULTIPLYALPHA: boolean;
  103367. EMISSIVE: boolean;
  103368. EMISSIVEDIRECTUV: number;
  103369. REFLECTIVITY: boolean;
  103370. REFLECTIVITYDIRECTUV: number;
  103371. SPECULARTERM: boolean;
  103372. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103373. MICROSURFACEAUTOMATIC: boolean;
  103374. LODBASEDMICROSFURACE: boolean;
  103375. MICROSURFACEMAP: boolean;
  103376. MICROSURFACEMAPDIRECTUV: number;
  103377. METALLICWORKFLOW: boolean;
  103378. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103379. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103380. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103381. AOSTOREINMETALMAPRED: boolean;
  103382. ENVIRONMENTBRDF: boolean;
  103383. ENVIRONMENTBRDF_RGBD: boolean;
  103384. NORMAL: boolean;
  103385. TANGENT: boolean;
  103386. BUMP: boolean;
  103387. BUMPDIRECTUV: number;
  103388. OBJECTSPACE_NORMALMAP: boolean;
  103389. PARALLAX: boolean;
  103390. PARALLAXOCCLUSION: boolean;
  103391. NORMALXYSCALE: boolean;
  103392. LIGHTMAP: boolean;
  103393. LIGHTMAPDIRECTUV: number;
  103394. USELIGHTMAPASSHADOWMAP: boolean;
  103395. GAMMALIGHTMAP: boolean;
  103396. REFLECTION: boolean;
  103397. REFLECTIONMAP_3D: boolean;
  103398. REFLECTIONMAP_SPHERICAL: boolean;
  103399. REFLECTIONMAP_PLANAR: boolean;
  103400. REFLECTIONMAP_CUBIC: boolean;
  103401. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103402. REFLECTIONMAP_PROJECTION: boolean;
  103403. REFLECTIONMAP_SKYBOX: boolean;
  103404. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103405. REFLECTIONMAP_EXPLICIT: boolean;
  103406. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103407. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103408. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103409. INVERTCUBICMAP: boolean;
  103410. USESPHERICALFROMREFLECTIONMAP: boolean;
  103411. USESPHERICALINVERTEX: boolean;
  103412. REFLECTIONMAP_OPPOSITEZ: boolean;
  103413. LODINREFLECTIONALPHA: boolean;
  103414. GAMMAREFLECTION: boolean;
  103415. RGBDREFLECTION: boolean;
  103416. RADIANCEOCCLUSION: boolean;
  103417. HORIZONOCCLUSION: boolean;
  103418. REFRACTION: boolean;
  103419. REFRACTIONMAP_3D: boolean;
  103420. REFRACTIONMAP_OPPOSITEZ: boolean;
  103421. LODINREFRACTIONALPHA: boolean;
  103422. GAMMAREFRACTION: boolean;
  103423. RGBDREFRACTION: boolean;
  103424. LINKREFRACTIONTOTRANSPARENCY: boolean;
  103425. INSTANCES: boolean;
  103426. NUM_BONE_INFLUENCERS: number;
  103427. BonesPerMesh: number;
  103428. BONETEXTURE: boolean;
  103429. NONUNIFORMSCALING: boolean;
  103430. MORPHTARGETS: boolean;
  103431. MORPHTARGETS_NORMAL: boolean;
  103432. MORPHTARGETS_TANGENT: boolean;
  103433. NUM_MORPH_INFLUENCERS: number;
  103434. IMAGEPROCESSING: boolean;
  103435. VIGNETTE: boolean;
  103436. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103437. VIGNETTEBLENDMODEOPAQUE: boolean;
  103438. TONEMAPPING: boolean;
  103439. TONEMAPPING_ACES: boolean;
  103440. CONTRAST: boolean;
  103441. COLORCURVES: boolean;
  103442. COLORGRADING: boolean;
  103443. COLORGRADING3D: boolean;
  103444. SAMPLER3DGREENDEPTH: boolean;
  103445. SAMPLER3DBGRMAP: boolean;
  103446. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103447. EXPOSURE: boolean;
  103448. MULTIVIEW: boolean;
  103449. USEPHYSICALLIGHTFALLOFF: boolean;
  103450. USEGLTFLIGHTFALLOFF: boolean;
  103451. TWOSIDEDLIGHTING: boolean;
  103452. SHADOWFLOAT: boolean;
  103453. CLIPPLANE: boolean;
  103454. CLIPPLANE2: boolean;
  103455. CLIPPLANE3: boolean;
  103456. CLIPPLANE4: boolean;
  103457. POINTSIZE: boolean;
  103458. FOG: boolean;
  103459. LOGARITHMICDEPTH: boolean;
  103460. FORCENORMALFORWARD: boolean;
  103461. SPECULARAA: boolean;
  103462. CLEARCOAT: boolean;
  103463. CLEARCOAT_DEFAULTIOR: boolean;
  103464. CLEARCOAT_TEXTURE: boolean;
  103465. CLEARCOAT_TEXTUREDIRECTUV: number;
  103466. CLEARCOAT_BUMP: boolean;
  103467. CLEARCOAT_BUMPDIRECTUV: number;
  103468. CLEARCOAT_TINT: boolean;
  103469. CLEARCOAT_TINT_TEXTURE: boolean;
  103470. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103471. ANISOTROPIC: boolean;
  103472. ANISOTROPIC_TEXTURE: boolean;
  103473. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103474. BRDF_V_HEIGHT_CORRELATED: boolean;
  103475. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103476. SHEEN: boolean;
  103477. SHEEN_TEXTURE: boolean;
  103478. SHEEN_TEXTUREDIRECTUV: number;
  103479. SHEEN_LINKWITHALBEDO: boolean;
  103480. UNLIT: boolean;
  103481. DEBUGMODE: number;
  103482. /**
  103483. * Initializes the PBR Material defines.
  103484. */
  103485. constructor();
  103486. /**
  103487. * Resets the PBR Material defines.
  103488. */
  103489. reset(): void;
  103490. }
  103491. /**
  103492. * The Physically based material base class of BJS.
  103493. *
  103494. * This offers the main features of a standard PBR material.
  103495. * For more information, please refer to the documentation :
  103496. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  103497. */
  103498. export abstract class PBRBaseMaterial extends PushMaterial {
  103499. /**
  103500. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103501. */
  103502. static readonly PBRMATERIAL_OPAQUE: number;
  103503. /**
  103504. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103505. */
  103506. static readonly PBRMATERIAL_ALPHATEST: number;
  103507. /**
  103508. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103509. */
  103510. static readonly PBRMATERIAL_ALPHABLEND: number;
  103511. /**
  103512. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103513. * They are also discarded below the alpha cutoff threshold to improve performances.
  103514. */
  103515. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103516. /**
  103517. * Defines the default value of how much AO map is occluding the analytical lights
  103518. * (point spot...).
  103519. */
  103520. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103521. /**
  103522. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  103523. */
  103524. static readonly LIGHTFALLOFF_PHYSICAL: number;
  103525. /**
  103526. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  103527. * to enhance interoperability with other engines.
  103528. */
  103529. static readonly LIGHTFALLOFF_GLTF: number;
  103530. /**
  103531. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  103532. * to enhance interoperability with other materials.
  103533. */
  103534. static readonly LIGHTFALLOFF_STANDARD: number;
  103535. /**
  103536. * Intensity of the direct lights e.g. the four lights available in your scene.
  103537. * This impacts both the direct diffuse and specular highlights.
  103538. */
  103539. protected _directIntensity: number;
  103540. /**
  103541. * Intensity of the emissive part of the material.
  103542. * This helps controlling the emissive effect without modifying the emissive color.
  103543. */
  103544. protected _emissiveIntensity: number;
  103545. /**
  103546. * Intensity of the environment e.g. how much the environment will light the object
  103547. * either through harmonics for rough material or through the refelction for shiny ones.
  103548. */
  103549. protected _environmentIntensity: number;
  103550. /**
  103551. * This is a special control allowing the reduction of the specular highlights coming from the
  103552. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103553. */
  103554. protected _specularIntensity: number;
  103555. /**
  103556. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  103557. */
  103558. private _lightingInfos;
  103559. /**
  103560. * Debug Control allowing disabling the bump map on this material.
  103561. */
  103562. protected _disableBumpMap: boolean;
  103563. /**
  103564. * AKA Diffuse Texture in standard nomenclature.
  103565. */
  103566. protected _albedoTexture: BaseTexture;
  103567. /**
  103568. * AKA Occlusion Texture in other nomenclature.
  103569. */
  103570. protected _ambientTexture: BaseTexture;
  103571. /**
  103572. * AKA Occlusion Texture Intensity in other nomenclature.
  103573. */
  103574. protected _ambientTextureStrength: number;
  103575. /**
  103576. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103577. * 1 means it completely occludes it
  103578. * 0 mean it has no impact
  103579. */
  103580. protected _ambientTextureImpactOnAnalyticalLights: number;
  103581. /**
  103582. * Stores the alpha values in a texture.
  103583. */
  103584. protected _opacityTexture: BaseTexture;
  103585. /**
  103586. * Stores the reflection values in a texture.
  103587. */
  103588. protected _reflectionTexture: BaseTexture;
  103589. /**
  103590. * Stores the refraction values in a texture.
  103591. */
  103592. protected _refractionTexture: BaseTexture;
  103593. /**
  103594. * Stores the emissive values in a texture.
  103595. */
  103596. protected _emissiveTexture: BaseTexture;
  103597. /**
  103598. * AKA Specular texture in other nomenclature.
  103599. */
  103600. protected _reflectivityTexture: BaseTexture;
  103601. /**
  103602. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103603. */
  103604. protected _metallicTexture: BaseTexture;
  103605. /**
  103606. * Specifies the metallic scalar of the metallic/roughness workflow.
  103607. * Can also be used to scale the metalness values of the metallic texture.
  103608. */
  103609. protected _metallic: Nullable<number>;
  103610. /**
  103611. * Specifies the roughness scalar of the metallic/roughness workflow.
  103612. * Can also be used to scale the roughness values of the metallic texture.
  103613. */
  103614. protected _roughness: Nullable<number>;
  103615. /**
  103616. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103617. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103618. */
  103619. protected _microSurfaceTexture: BaseTexture;
  103620. /**
  103621. * Stores surface normal data used to displace a mesh in a texture.
  103622. */
  103623. protected _bumpTexture: BaseTexture;
  103624. /**
  103625. * Stores the pre-calculated light information of a mesh in a texture.
  103626. */
  103627. protected _lightmapTexture: BaseTexture;
  103628. /**
  103629. * The color of a material in ambient lighting.
  103630. */
  103631. protected _ambientColor: Color3;
  103632. /**
  103633. * AKA Diffuse Color in other nomenclature.
  103634. */
  103635. protected _albedoColor: Color3;
  103636. /**
  103637. * AKA Specular Color in other nomenclature.
  103638. */
  103639. protected _reflectivityColor: Color3;
  103640. /**
  103641. * The color applied when light is reflected from a material.
  103642. */
  103643. protected _reflectionColor: Color3;
  103644. /**
  103645. * The color applied when light is emitted from a material.
  103646. */
  103647. protected _emissiveColor: Color3;
  103648. /**
  103649. * AKA Glossiness in other nomenclature.
  103650. */
  103651. protected _microSurface: number;
  103652. /**
  103653. * source material index of refraction (IOR)' / 'destination material IOR.
  103654. */
  103655. protected _indexOfRefraction: number;
  103656. /**
  103657. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103658. */
  103659. protected _invertRefractionY: boolean;
  103660. /**
  103661. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103662. * Materials half opaque for instance using refraction could benefit from this control.
  103663. */
  103664. protected _linkRefractionWithTransparency: boolean;
  103665. /**
  103666. * Specifies that the material will use the light map as a show map.
  103667. */
  103668. protected _useLightmapAsShadowmap: boolean;
  103669. /**
  103670. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103671. * makes the reflect vector face the model (under horizon).
  103672. */
  103673. protected _useHorizonOcclusion: boolean;
  103674. /**
  103675. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103676. * too much the area relying on ambient texture to define their ambient occlusion.
  103677. */
  103678. protected _useRadianceOcclusion: boolean;
  103679. /**
  103680. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103681. */
  103682. protected _useAlphaFromAlbedoTexture: boolean;
  103683. /**
  103684. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  103685. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103686. */
  103687. protected _useSpecularOverAlpha: boolean;
  103688. /**
  103689. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103690. */
  103691. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103692. /**
  103693. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103694. */
  103695. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  103696. /**
  103697. * Specifies if the metallic texture contains the roughness information in its green channel.
  103698. */
  103699. protected _useRoughnessFromMetallicTextureGreen: boolean;
  103700. /**
  103701. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103702. */
  103703. protected _useMetallnessFromMetallicTextureBlue: boolean;
  103704. /**
  103705. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103706. */
  103707. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  103708. /**
  103709. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103710. */
  103711. protected _useAmbientInGrayScale: boolean;
  103712. /**
  103713. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103714. * The material will try to infer what glossiness each pixel should be.
  103715. */
  103716. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  103717. /**
  103718. * Defines the falloff type used in this material.
  103719. * It by default is Physical.
  103720. */
  103721. protected _lightFalloff: number;
  103722. /**
  103723. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103724. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103725. */
  103726. protected _useRadianceOverAlpha: boolean;
  103727. /**
  103728. * Allows using an object space normal map (instead of tangent space).
  103729. */
  103730. protected _useObjectSpaceNormalMap: boolean;
  103731. /**
  103732. * Allows using the bump map in parallax mode.
  103733. */
  103734. protected _useParallax: boolean;
  103735. /**
  103736. * Allows using the bump map in parallax occlusion mode.
  103737. */
  103738. protected _useParallaxOcclusion: boolean;
  103739. /**
  103740. * Controls the scale bias of the parallax mode.
  103741. */
  103742. protected _parallaxScaleBias: number;
  103743. /**
  103744. * If sets to true, disables all the lights affecting the material.
  103745. */
  103746. protected _disableLighting: boolean;
  103747. /**
  103748. * Number of Simultaneous lights allowed on the material.
  103749. */
  103750. protected _maxSimultaneousLights: number;
  103751. /**
  103752. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103753. */
  103754. protected _invertNormalMapX: boolean;
  103755. /**
  103756. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103757. */
  103758. protected _invertNormalMapY: boolean;
  103759. /**
  103760. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103761. */
  103762. protected _twoSidedLighting: boolean;
  103763. /**
  103764. * Defines the alpha limits in alpha test mode.
  103765. */
  103766. protected _alphaCutOff: number;
  103767. /**
  103768. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103769. */
  103770. protected _forceAlphaTest: boolean;
  103771. /**
  103772. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103773. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103774. */
  103775. protected _useAlphaFresnel: boolean;
  103776. /**
  103777. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103778. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103779. */
  103780. protected _useLinearAlphaFresnel: boolean;
  103781. /**
  103782. * The transparency mode of the material.
  103783. */
  103784. protected _transparencyMode: Nullable<number>;
  103785. /**
  103786. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  103787. * from cos thetav and roughness:
  103788. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  103789. */
  103790. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  103791. /**
  103792. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103793. */
  103794. protected _forceIrradianceInFragment: boolean;
  103795. /**
  103796. * Force normal to face away from face.
  103797. */
  103798. protected _forceNormalForward: boolean;
  103799. /**
  103800. * Enables specular anti aliasing in the PBR shader.
  103801. * It will both interacts on the Geometry for analytical and IBL lighting.
  103802. * It also prefilter the roughness map based on the bump values.
  103803. */
  103804. protected _enableSpecularAntiAliasing: boolean;
  103805. /**
  103806. * Default configuration related to image processing available in the PBR Material.
  103807. */
  103808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103809. /**
  103810. * Keep track of the image processing observer to allow dispose and replace.
  103811. */
  103812. private _imageProcessingObserver;
  103813. /**
  103814. * Attaches a new image processing configuration to the PBR Material.
  103815. * @param configuration
  103816. */
  103817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103818. /**
  103819. * Stores the available render targets.
  103820. */
  103821. private _renderTargets;
  103822. /**
  103823. * Sets the global ambient color for the material used in lighting calculations.
  103824. */
  103825. private _globalAmbientColor;
  103826. /**
  103827. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  103828. */
  103829. private _useLogarithmicDepth;
  103830. /**
  103831. * If set to true, no lighting calculations will be applied.
  103832. */
  103833. private _unlit;
  103834. private _debugMode;
  103835. /**
  103836. * @hidden
  103837. * This is reserved for the inspector.
  103838. * Defines the material debug mode.
  103839. * It helps seeing only some components of the material while troubleshooting.
  103840. */
  103841. debugMode: number;
  103842. /**
  103843. * @hidden
  103844. * This is reserved for the inspector.
  103845. * Specify from where on screen the debug mode should start.
  103846. * The value goes from -1 (full screen) to 1 (not visible)
  103847. * It helps with side by side comparison against the final render
  103848. * This defaults to -1
  103849. */
  103850. private debugLimit;
  103851. /**
  103852. * @hidden
  103853. * This is reserved for the inspector.
  103854. * As the default viewing range might not be enough (if the ambient is really small for instance)
  103855. * You can use the factor to better multiply the final value.
  103856. */
  103857. private debugFactor;
  103858. /**
  103859. * Defines the clear coat layer parameters for the material.
  103860. */
  103861. readonly clearCoat: PBRClearCoatConfiguration;
  103862. /**
  103863. * Defines the anisotropic parameters for the material.
  103864. */
  103865. readonly anisotropy: PBRAnisotropicConfiguration;
  103866. /**
  103867. * Defines the BRDF parameters for the material.
  103868. */
  103869. readonly brdf: PBRBRDFConfiguration;
  103870. /**
  103871. * Defines the Sheen parameters for the material.
  103872. */
  103873. readonly sheen: PBRSheenConfiguration;
  103874. /**
  103875. * Custom callback helping to override the default shader used in the material.
  103876. */
  103877. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  103878. /**
  103879. * Instantiates a new PBRMaterial instance.
  103880. *
  103881. * @param name The material name
  103882. * @param scene The scene the material will be use in.
  103883. */
  103884. constructor(name: string, scene: Scene);
  103885. /**
  103886. * Gets a boolean indicating that current material needs to register RTT
  103887. */
  103888. readonly hasRenderTargetTextures: boolean;
  103889. /**
  103890. * Gets the name of the material class.
  103891. */
  103892. getClassName(): string;
  103893. /**
  103894. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103895. */
  103896. /**
  103897. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103898. */
  103899. useLogarithmicDepth: boolean;
  103900. /**
  103901. * Gets the current transparency mode.
  103902. */
  103903. /**
  103904. * Sets the transparency mode of the material.
  103905. *
  103906. * | Value | Type | Description |
  103907. * | ----- | ----------------------------------- | ----------- |
  103908. * | 0 | OPAQUE | |
  103909. * | 1 | ALPHATEST | |
  103910. * | 2 | ALPHABLEND | |
  103911. * | 3 | ALPHATESTANDBLEND | |
  103912. *
  103913. */
  103914. transparencyMode: Nullable<number>;
  103915. /**
  103916. * Returns true if alpha blending should be disabled.
  103917. */
  103918. private readonly _disableAlphaBlending;
  103919. /**
  103920. * Specifies whether or not this material should be rendered in alpha blend mode.
  103921. */
  103922. needAlphaBlending(): boolean;
  103923. /**
  103924. * Specifies if the mesh will require alpha blending.
  103925. * @param mesh - BJS mesh.
  103926. */
  103927. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103928. /**
  103929. * Specifies whether or not this material should be rendered in alpha test mode.
  103930. */
  103931. needAlphaTesting(): boolean;
  103932. /**
  103933. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103934. */
  103935. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103936. /**
  103937. * Gets the texture used for the alpha test.
  103938. */
  103939. getAlphaTestTexture(): BaseTexture;
  103940. /**
  103941. * Specifies that the submesh is ready to be used.
  103942. * @param mesh - BJS mesh.
  103943. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103944. * @param useInstances - Specifies that instances should be used.
  103945. * @returns - boolean indicating that the submesh is ready or not.
  103946. */
  103947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103948. /**
  103949. * Specifies if the material uses metallic roughness workflow.
  103950. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103951. */
  103952. isMetallicWorkflow(): boolean;
  103953. private _prepareEffect;
  103954. private _prepareDefines;
  103955. /**
  103956. * Force shader compilation
  103957. */
  103958. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  103959. clipPlane: boolean;
  103960. }>): void;
  103961. /**
  103962. * Initializes the uniform buffer layout for the shader.
  103963. */
  103964. buildUniformLayout(): void;
  103965. /**
  103966. * Unbinds the textures.
  103967. */
  103968. unbind(): void;
  103969. /**
  103970. * Binds the submesh data.
  103971. * @param world - The world matrix.
  103972. * @param mesh - The BJS mesh.
  103973. * @param subMesh - A submesh of the BJS mesh.
  103974. */
  103975. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103976. /**
  103977. * Returns the animatable textures.
  103978. * @returns - Array of animatable textures.
  103979. */
  103980. getAnimatables(): IAnimatable[];
  103981. /**
  103982. * Returns the texture used for reflections.
  103983. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103984. */
  103985. private _getReflectionTexture;
  103986. /**
  103987. * Returns the texture used for refraction or null if none is used.
  103988. * @returns - Refection texture if present. If no refraction texture and refraction
  103989. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103990. */
  103991. private _getRefractionTexture;
  103992. /**
  103993. * Returns an array of the actively used textures.
  103994. * @returns - Array of BaseTextures
  103995. */
  103996. getActiveTextures(): BaseTexture[];
  103997. /**
  103998. * Checks to see if a texture is used in the material.
  103999. * @param texture - Base texture to use.
  104000. * @returns - Boolean specifying if a texture is used in the material.
  104001. */
  104002. hasTexture(texture: BaseTexture): boolean;
  104003. /**
  104004. * Disposes the resources of the material.
  104005. * @param forceDisposeEffect - Forces the disposal of effects.
  104006. * @param forceDisposeTextures - Forces the disposal of all textures.
  104007. */
  104008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104009. }
  104010. }
  104011. declare module BABYLON {
  104012. /**
  104013. * The Physically based material of BJS.
  104014. *
  104015. * This offers the main features of a standard PBR material.
  104016. * For more information, please refer to the documentation :
  104017. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104018. */
  104019. export class PBRMaterial extends PBRBaseMaterial {
  104020. /**
  104021. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104022. */
  104023. static readonly PBRMATERIAL_OPAQUE: number;
  104024. /**
  104025. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104026. */
  104027. static readonly PBRMATERIAL_ALPHATEST: number;
  104028. /**
  104029. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104030. */
  104031. static readonly PBRMATERIAL_ALPHABLEND: number;
  104032. /**
  104033. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104034. * They are also discarded below the alpha cutoff threshold to improve performances.
  104035. */
  104036. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104037. /**
  104038. * Defines the default value of how much AO map is occluding the analytical lights
  104039. * (point spot...).
  104040. */
  104041. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104042. /**
  104043. * Intensity of the direct lights e.g. the four lights available in your scene.
  104044. * This impacts both the direct diffuse and specular highlights.
  104045. */
  104046. directIntensity: number;
  104047. /**
  104048. * Intensity of the emissive part of the material.
  104049. * This helps controlling the emissive effect without modifying the emissive color.
  104050. */
  104051. emissiveIntensity: number;
  104052. /**
  104053. * Intensity of the environment e.g. how much the environment will light the object
  104054. * either through harmonics for rough material or through the refelction for shiny ones.
  104055. */
  104056. environmentIntensity: number;
  104057. /**
  104058. * This is a special control allowing the reduction of the specular highlights coming from the
  104059. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104060. */
  104061. specularIntensity: number;
  104062. /**
  104063. * Debug Control allowing disabling the bump map on this material.
  104064. */
  104065. disableBumpMap: boolean;
  104066. /**
  104067. * AKA Diffuse Texture in standard nomenclature.
  104068. */
  104069. albedoTexture: BaseTexture;
  104070. /**
  104071. * AKA Occlusion Texture in other nomenclature.
  104072. */
  104073. ambientTexture: BaseTexture;
  104074. /**
  104075. * AKA Occlusion Texture Intensity in other nomenclature.
  104076. */
  104077. ambientTextureStrength: number;
  104078. /**
  104079. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104080. * 1 means it completely occludes it
  104081. * 0 mean it has no impact
  104082. */
  104083. ambientTextureImpactOnAnalyticalLights: number;
  104084. /**
  104085. * Stores the alpha values in a texture.
  104086. */
  104087. opacityTexture: BaseTexture;
  104088. /**
  104089. * Stores the reflection values in a texture.
  104090. */
  104091. reflectionTexture: Nullable<BaseTexture>;
  104092. /**
  104093. * Stores the emissive values in a texture.
  104094. */
  104095. emissiveTexture: BaseTexture;
  104096. /**
  104097. * AKA Specular texture in other nomenclature.
  104098. */
  104099. reflectivityTexture: BaseTexture;
  104100. /**
  104101. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104102. */
  104103. metallicTexture: BaseTexture;
  104104. /**
  104105. * Specifies the metallic scalar of the metallic/roughness workflow.
  104106. * Can also be used to scale the metalness values of the metallic texture.
  104107. */
  104108. metallic: Nullable<number>;
  104109. /**
  104110. * Specifies the roughness scalar of the metallic/roughness workflow.
  104111. * Can also be used to scale the roughness values of the metallic texture.
  104112. */
  104113. roughness: Nullable<number>;
  104114. /**
  104115. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104116. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104117. */
  104118. microSurfaceTexture: BaseTexture;
  104119. /**
  104120. * Stores surface normal data used to displace a mesh in a texture.
  104121. */
  104122. bumpTexture: BaseTexture;
  104123. /**
  104124. * Stores the pre-calculated light information of a mesh in a texture.
  104125. */
  104126. lightmapTexture: BaseTexture;
  104127. /**
  104128. * Stores the refracted light information in a texture.
  104129. */
  104130. refractionTexture: BaseTexture;
  104131. /**
  104132. * The color of a material in ambient lighting.
  104133. */
  104134. ambientColor: Color3;
  104135. /**
  104136. * AKA Diffuse Color in other nomenclature.
  104137. */
  104138. albedoColor: Color3;
  104139. /**
  104140. * AKA Specular Color in other nomenclature.
  104141. */
  104142. reflectivityColor: Color3;
  104143. /**
  104144. * The color reflected from the material.
  104145. */
  104146. reflectionColor: Color3;
  104147. /**
  104148. * The color emitted from the material.
  104149. */
  104150. emissiveColor: Color3;
  104151. /**
  104152. * AKA Glossiness in other nomenclature.
  104153. */
  104154. microSurface: number;
  104155. /**
  104156. * source material index of refraction (IOR)' / 'destination material IOR.
  104157. */
  104158. indexOfRefraction: number;
  104159. /**
  104160. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104161. */
  104162. invertRefractionY: boolean;
  104163. /**
  104164. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104165. * Materials half opaque for instance using refraction could benefit from this control.
  104166. */
  104167. linkRefractionWithTransparency: boolean;
  104168. /**
  104169. * If true, the light map contains occlusion information instead of lighting info.
  104170. */
  104171. useLightmapAsShadowmap: boolean;
  104172. /**
  104173. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104174. */
  104175. useAlphaFromAlbedoTexture: boolean;
  104176. /**
  104177. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104178. */
  104179. forceAlphaTest: boolean;
  104180. /**
  104181. * Defines the alpha limits in alpha test mode.
  104182. */
  104183. alphaCutOff: number;
  104184. /**
  104185. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104186. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104187. */
  104188. useSpecularOverAlpha: boolean;
  104189. /**
  104190. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104191. */
  104192. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104193. /**
  104194. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104195. */
  104196. useRoughnessFromMetallicTextureAlpha: boolean;
  104197. /**
  104198. * Specifies if the metallic texture contains the roughness information in its green channel.
  104199. */
  104200. useRoughnessFromMetallicTextureGreen: boolean;
  104201. /**
  104202. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104203. */
  104204. useMetallnessFromMetallicTextureBlue: boolean;
  104205. /**
  104206. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104207. */
  104208. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104209. /**
  104210. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104211. */
  104212. useAmbientInGrayScale: boolean;
  104213. /**
  104214. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104215. * The material will try to infer what glossiness each pixel should be.
  104216. */
  104217. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104218. /**
  104219. * BJS is using an harcoded light falloff based on a manually sets up range.
  104220. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104221. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104222. */
  104223. /**
  104224. * BJS is using an harcoded light falloff based on a manually sets up range.
  104225. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104226. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104227. */
  104228. usePhysicalLightFalloff: boolean;
  104229. /**
  104230. * In order to support the falloff compatibility with gltf, a special mode has been added
  104231. * to reproduce the gltf light falloff.
  104232. */
  104233. /**
  104234. * In order to support the falloff compatibility with gltf, a special mode has been added
  104235. * to reproduce the gltf light falloff.
  104236. */
  104237. useGLTFLightFalloff: boolean;
  104238. /**
  104239. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104240. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104241. */
  104242. useRadianceOverAlpha: boolean;
  104243. /**
  104244. * Allows using an object space normal map (instead of tangent space).
  104245. */
  104246. useObjectSpaceNormalMap: boolean;
  104247. /**
  104248. * Allows using the bump map in parallax mode.
  104249. */
  104250. useParallax: boolean;
  104251. /**
  104252. * Allows using the bump map in parallax occlusion mode.
  104253. */
  104254. useParallaxOcclusion: boolean;
  104255. /**
  104256. * Controls the scale bias of the parallax mode.
  104257. */
  104258. parallaxScaleBias: number;
  104259. /**
  104260. * If sets to true, disables all the lights affecting the material.
  104261. */
  104262. disableLighting: boolean;
  104263. /**
  104264. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104265. */
  104266. forceIrradianceInFragment: boolean;
  104267. /**
  104268. * Number of Simultaneous lights allowed on the material.
  104269. */
  104270. maxSimultaneousLights: number;
  104271. /**
  104272. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104273. */
  104274. invertNormalMapX: boolean;
  104275. /**
  104276. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104277. */
  104278. invertNormalMapY: boolean;
  104279. /**
  104280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104281. */
  104282. twoSidedLighting: boolean;
  104283. /**
  104284. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104285. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104286. */
  104287. useAlphaFresnel: boolean;
  104288. /**
  104289. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104290. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104291. */
  104292. useLinearAlphaFresnel: boolean;
  104293. /**
  104294. * Let user defines the brdf lookup texture used for IBL.
  104295. * A default 8bit version is embedded but you could point at :
  104296. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104297. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104298. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104299. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104300. */
  104301. environmentBRDFTexture: Nullable<BaseTexture>;
  104302. /**
  104303. * Force normal to face away from face.
  104304. */
  104305. forceNormalForward: boolean;
  104306. /**
  104307. * Enables specular anti aliasing in the PBR shader.
  104308. * It will both interacts on the Geometry for analytical and IBL lighting.
  104309. * It also prefilter the roughness map based on the bump values.
  104310. */
  104311. enableSpecularAntiAliasing: boolean;
  104312. /**
  104313. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104314. * makes the reflect vector face the model (under horizon).
  104315. */
  104316. useHorizonOcclusion: boolean;
  104317. /**
  104318. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104319. * too much the area relying on ambient texture to define their ambient occlusion.
  104320. */
  104321. useRadianceOcclusion: boolean;
  104322. /**
  104323. * If set to true, no lighting calculations will be applied.
  104324. */
  104325. unlit: boolean;
  104326. /**
  104327. * Gets the image processing configuration used either in this material.
  104328. */
  104329. /**
  104330. * Sets the Default image processing configuration used either in the this material.
  104331. *
  104332. * If sets to null, the scene one is in use.
  104333. */
  104334. imageProcessingConfiguration: ImageProcessingConfiguration;
  104335. /**
  104336. * Gets wether the color curves effect is enabled.
  104337. */
  104338. /**
  104339. * Sets wether the color curves effect is enabled.
  104340. */
  104341. cameraColorCurvesEnabled: boolean;
  104342. /**
  104343. * Gets wether the color grading effect is enabled.
  104344. */
  104345. /**
  104346. * Gets wether the color grading effect is enabled.
  104347. */
  104348. cameraColorGradingEnabled: boolean;
  104349. /**
  104350. * Gets wether tonemapping is enabled or not.
  104351. */
  104352. /**
  104353. * Sets wether tonemapping is enabled or not
  104354. */
  104355. cameraToneMappingEnabled: boolean;
  104356. /**
  104357. * The camera exposure used on this material.
  104358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104359. * This corresponds to a photographic exposure.
  104360. */
  104361. /**
  104362. * The camera exposure used on this material.
  104363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104364. * This corresponds to a photographic exposure.
  104365. */
  104366. cameraExposure: number;
  104367. /**
  104368. * Gets The camera contrast used on this material.
  104369. */
  104370. /**
  104371. * Sets The camera contrast used on this material.
  104372. */
  104373. cameraContrast: number;
  104374. /**
  104375. * Gets the Color Grading 2D Lookup Texture.
  104376. */
  104377. /**
  104378. * Sets the Color Grading 2D Lookup Texture.
  104379. */
  104380. cameraColorGradingTexture: Nullable<BaseTexture>;
  104381. /**
  104382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104384. * 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;
  104385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104386. */
  104387. /**
  104388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104390. * 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;
  104391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104392. */
  104393. cameraColorCurves: Nullable<ColorCurves>;
  104394. /**
  104395. * Instantiates a new PBRMaterial instance.
  104396. *
  104397. * @param name The material name
  104398. * @param scene The scene the material will be use in.
  104399. */
  104400. constructor(name: string, scene: Scene);
  104401. /**
  104402. * Returns the name of this material class.
  104403. */
  104404. getClassName(): string;
  104405. /**
  104406. * Makes a duplicate of the current material.
  104407. * @param name - name to use for the new material.
  104408. */
  104409. clone(name: string): PBRMaterial;
  104410. /**
  104411. * Serializes this PBR Material.
  104412. * @returns - An object with the serialized material.
  104413. */
  104414. serialize(): any;
  104415. /**
  104416. * Parses a PBR Material from a serialized object.
  104417. * @param source - Serialized object.
  104418. * @param scene - BJS scene instance.
  104419. * @param rootUrl - url for the scene object
  104420. * @returns - PBRMaterial
  104421. */
  104422. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104423. }
  104424. }
  104425. declare module BABYLON {
  104426. /**
  104427. * Direct draw surface info
  104428. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104429. */
  104430. export interface DDSInfo {
  104431. /**
  104432. * Width of the texture
  104433. */
  104434. width: number;
  104435. /**
  104436. * Width of the texture
  104437. */
  104438. height: number;
  104439. /**
  104440. * Number of Mipmaps for the texture
  104441. * @see https://en.wikipedia.org/wiki/Mipmap
  104442. */
  104443. mipmapCount: number;
  104444. /**
  104445. * If the textures format is a known fourCC format
  104446. * @see https://www.fourcc.org/
  104447. */
  104448. isFourCC: boolean;
  104449. /**
  104450. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104451. */
  104452. isRGB: boolean;
  104453. /**
  104454. * If the texture is a lumincance format
  104455. */
  104456. isLuminance: boolean;
  104457. /**
  104458. * If this is a cube texture
  104459. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104460. */
  104461. isCube: boolean;
  104462. /**
  104463. * If the texture is a compressed format eg. FOURCC_DXT1
  104464. */
  104465. isCompressed: boolean;
  104466. /**
  104467. * The dxgiFormat of the texture
  104468. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104469. */
  104470. dxgiFormat: number;
  104471. /**
  104472. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104473. */
  104474. textureType: number;
  104475. /**
  104476. * Sphericle polynomial created for the dds texture
  104477. */
  104478. sphericalPolynomial?: SphericalPolynomial;
  104479. }
  104480. /**
  104481. * Class used to provide DDS decompression tools
  104482. */
  104483. export class DDSTools {
  104484. /**
  104485. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104486. */
  104487. static StoreLODInAlphaChannel: boolean;
  104488. /**
  104489. * Gets DDS information from an array buffer
  104490. * @param arrayBuffer defines the array buffer to read data from
  104491. * @returns the DDS information
  104492. */
  104493. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104494. private static _FloatView;
  104495. private static _Int32View;
  104496. private static _ToHalfFloat;
  104497. private static _FromHalfFloat;
  104498. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104499. private static _GetHalfFloatRGBAArrayBuffer;
  104500. private static _GetFloatRGBAArrayBuffer;
  104501. private static _GetFloatAsUIntRGBAArrayBuffer;
  104502. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104503. private static _GetRGBAArrayBuffer;
  104504. private static _ExtractLongWordOrder;
  104505. private static _GetRGBArrayBuffer;
  104506. private static _GetLuminanceArrayBuffer;
  104507. /**
  104508. * Uploads DDS Levels to a Babylon Texture
  104509. * @hidden
  104510. */
  104511. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104512. }
  104513. interface Engine {
  104514. /**
  104515. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104516. * @param rootUrl defines the url where the file to load is located
  104517. * @param scene defines the current scene
  104518. * @param lodScale defines scale to apply to the mip map selection
  104519. * @param lodOffset defines offset to apply to the mip map selection
  104520. * @param onLoad defines an optional callback raised when the texture is loaded
  104521. * @param onError defines an optional callback raised if there is an issue to load the texture
  104522. * @param format defines the format of the data
  104523. * @param forcedExtension defines the extension to use to pick the right loader
  104524. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104525. * @returns the cube texture as an InternalTexture
  104526. */
  104527. 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;
  104528. }
  104529. }
  104530. declare module BABYLON {
  104531. /**
  104532. * Implementation of the DDS Texture Loader.
  104533. * @hidden
  104534. */
  104535. export class _DDSTextureLoader implements IInternalTextureLoader {
  104536. /**
  104537. * Defines wether the loader supports cascade loading the different faces.
  104538. */
  104539. readonly supportCascades: boolean;
  104540. /**
  104541. * This returns if the loader support the current file information.
  104542. * @param extension defines the file extension of the file being loaded
  104543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104544. * @param fallback defines the fallback internal texture if any
  104545. * @param isBase64 defines whether the texture is encoded as a base64
  104546. * @param isBuffer defines whether the texture data are stored as a buffer
  104547. * @returns true if the loader can load the specified file
  104548. */
  104549. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104550. /**
  104551. * Transform the url before loading if required.
  104552. * @param rootUrl the url of the texture
  104553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104554. * @returns the transformed texture
  104555. */
  104556. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104557. /**
  104558. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104559. * @param rootUrl the url of the texture
  104560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104561. * @returns the fallback texture
  104562. */
  104563. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104564. /**
  104565. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104566. * @param data contains the texture data
  104567. * @param texture defines the BabylonJS internal texture
  104568. * @param createPolynomials will be true if polynomials have been requested
  104569. * @param onLoad defines the callback to trigger once the texture is ready
  104570. * @param onError defines the callback to trigger in case of error
  104571. */
  104572. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104573. /**
  104574. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104575. * @param data contains the texture data
  104576. * @param texture defines the BabylonJS internal texture
  104577. * @param callback defines the method to call once ready to upload
  104578. */
  104579. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104580. }
  104581. }
  104582. declare module BABYLON {
  104583. /** @hidden */
  104584. export var rgbdEncodePixelShader: {
  104585. name: string;
  104586. shader: string;
  104587. };
  104588. }
  104589. declare module BABYLON {
  104590. /** @hidden */
  104591. export var rgbdDecodePixelShader: {
  104592. name: string;
  104593. shader: string;
  104594. };
  104595. }
  104596. declare module BABYLON {
  104597. /**
  104598. * Raw texture data and descriptor sufficient for WebGL texture upload
  104599. */
  104600. export interface EnvironmentTextureInfo {
  104601. /**
  104602. * Version of the environment map
  104603. */
  104604. version: number;
  104605. /**
  104606. * Width of image
  104607. */
  104608. width: number;
  104609. /**
  104610. * Irradiance information stored in the file.
  104611. */
  104612. irradiance: any;
  104613. /**
  104614. * Specular information stored in the file.
  104615. */
  104616. specular: any;
  104617. }
  104618. /**
  104619. * Sets of helpers addressing the serialization and deserialization of environment texture
  104620. * stored in a BabylonJS env file.
  104621. * Those files are usually stored as .env files.
  104622. */
  104623. export class EnvironmentTextureTools {
  104624. /**
  104625. * Magic number identifying the env file.
  104626. */
  104627. private static _MagicBytes;
  104628. /**
  104629. * Gets the environment info from an env file.
  104630. * @param data The array buffer containing the .env bytes.
  104631. * @returns the environment file info (the json header) if successfully parsed.
  104632. */
  104633. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104634. /**
  104635. * Creates an environment texture from a loaded cube texture.
  104636. * @param texture defines the cube texture to convert in env file
  104637. * @return a promise containing the environment data if succesfull.
  104638. */
  104639. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104640. /**
  104641. * Creates a JSON representation of the spherical data.
  104642. * @param texture defines the texture containing the polynomials
  104643. * @return the JSON representation of the spherical info
  104644. */
  104645. private static _CreateEnvTextureIrradiance;
  104646. /**
  104647. * Uploads the texture info contained in the env file to the GPU.
  104648. * @param texture defines the internal texture to upload to
  104649. * @param arrayBuffer defines the buffer cotaining the data to load
  104650. * @param info defines the texture info retrieved through the GetEnvInfo method
  104651. * @returns a promise
  104652. */
  104653. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104654. /**
  104655. * Uploads the levels of image data to the GPU.
  104656. * @param texture defines the internal texture to upload to
  104657. * @param imageData defines the array buffer views of image data [mipmap][face]
  104658. * @returns a promise
  104659. */
  104660. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104661. /**
  104662. * Uploads spherical polynomials information to the texture.
  104663. * @param texture defines the texture we are trying to upload the information to
  104664. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104665. */
  104666. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104667. /** @hidden */
  104668. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104669. }
  104670. }
  104671. declare module BABYLON {
  104672. /**
  104673. * Implementation of the ENV Texture Loader.
  104674. * @hidden
  104675. */
  104676. export class _ENVTextureLoader implements IInternalTextureLoader {
  104677. /**
  104678. * Defines wether the loader supports cascade loading the different faces.
  104679. */
  104680. readonly supportCascades: boolean;
  104681. /**
  104682. * This returns if the loader support the current file information.
  104683. * @param extension defines the file extension of the file being loaded
  104684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104685. * @param fallback defines the fallback internal texture if any
  104686. * @param isBase64 defines whether the texture is encoded as a base64
  104687. * @param isBuffer defines whether the texture data are stored as a buffer
  104688. * @returns true if the loader can load the specified file
  104689. */
  104690. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104691. /**
  104692. * Transform the url before loading if required.
  104693. * @param rootUrl the url of the texture
  104694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104695. * @returns the transformed texture
  104696. */
  104697. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104698. /**
  104699. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104700. * @param rootUrl the url of the texture
  104701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104702. * @returns the fallback texture
  104703. */
  104704. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104705. /**
  104706. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104707. * @param data contains the texture data
  104708. * @param texture defines the BabylonJS internal texture
  104709. * @param createPolynomials will be true if polynomials have been requested
  104710. * @param onLoad defines the callback to trigger once the texture is ready
  104711. * @param onError defines the callback to trigger in case of error
  104712. */
  104713. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104714. /**
  104715. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104716. * @param data contains the texture data
  104717. * @param texture defines the BabylonJS internal texture
  104718. * @param callback defines the method to call once ready to upload
  104719. */
  104720. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104721. }
  104722. }
  104723. declare module BABYLON {
  104724. /**
  104725. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104726. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104727. */
  104728. export class KhronosTextureContainer {
  104729. /** contents of the KTX container file */
  104730. arrayBuffer: any;
  104731. private static HEADER_LEN;
  104732. private static COMPRESSED_2D;
  104733. private static COMPRESSED_3D;
  104734. private static TEX_2D;
  104735. private static TEX_3D;
  104736. /**
  104737. * Gets the openGL type
  104738. */
  104739. glType: number;
  104740. /**
  104741. * Gets the openGL type size
  104742. */
  104743. glTypeSize: number;
  104744. /**
  104745. * Gets the openGL format
  104746. */
  104747. glFormat: number;
  104748. /**
  104749. * Gets the openGL internal format
  104750. */
  104751. glInternalFormat: number;
  104752. /**
  104753. * Gets the base internal format
  104754. */
  104755. glBaseInternalFormat: number;
  104756. /**
  104757. * Gets image width in pixel
  104758. */
  104759. pixelWidth: number;
  104760. /**
  104761. * Gets image height in pixel
  104762. */
  104763. pixelHeight: number;
  104764. /**
  104765. * Gets image depth in pixels
  104766. */
  104767. pixelDepth: number;
  104768. /**
  104769. * Gets the number of array elements
  104770. */
  104771. numberOfArrayElements: number;
  104772. /**
  104773. * Gets the number of faces
  104774. */
  104775. numberOfFaces: number;
  104776. /**
  104777. * Gets the number of mipmap levels
  104778. */
  104779. numberOfMipmapLevels: number;
  104780. /**
  104781. * Gets the bytes of key value data
  104782. */
  104783. bytesOfKeyValueData: number;
  104784. /**
  104785. * Gets the load type
  104786. */
  104787. loadType: number;
  104788. /**
  104789. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104790. */
  104791. isInvalid: boolean;
  104792. /**
  104793. * Creates a new KhronosTextureContainer
  104794. * @param arrayBuffer contents of the KTX container file
  104795. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104796. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104797. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104798. */
  104799. constructor(
  104800. /** contents of the KTX container file */
  104801. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104802. /**
  104803. * Uploads KTX content to a Babylon Texture.
  104804. * It is assumed that the texture has already been created & is currently bound
  104805. * @hidden
  104806. */
  104807. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104808. private _upload2DCompressedLevels;
  104809. }
  104810. }
  104811. declare module BABYLON {
  104812. /**
  104813. * Implementation of the KTX Texture Loader.
  104814. * @hidden
  104815. */
  104816. export class _KTXTextureLoader implements IInternalTextureLoader {
  104817. /**
  104818. * Defines wether the loader supports cascade loading the different faces.
  104819. */
  104820. readonly supportCascades: boolean;
  104821. /**
  104822. * This returns if the loader support the current file information.
  104823. * @param extension defines the file extension of the file being loaded
  104824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104825. * @param fallback defines the fallback internal texture if any
  104826. * @param isBase64 defines whether the texture is encoded as a base64
  104827. * @param isBuffer defines whether the texture data are stored as a buffer
  104828. * @returns true if the loader can load the specified file
  104829. */
  104830. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104831. /**
  104832. * Transform the url before loading if required.
  104833. * @param rootUrl the url of the texture
  104834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104835. * @returns the transformed texture
  104836. */
  104837. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104838. /**
  104839. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104840. * @param rootUrl the url of the texture
  104841. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104842. * @returns the fallback texture
  104843. */
  104844. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104845. /**
  104846. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104847. * @param data contains the texture data
  104848. * @param texture defines the BabylonJS internal texture
  104849. * @param createPolynomials will be true if polynomials have been requested
  104850. * @param onLoad defines the callback to trigger once the texture is ready
  104851. * @param onError defines the callback to trigger in case of error
  104852. */
  104853. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104854. /**
  104855. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104856. * @param data contains the texture data
  104857. * @param texture defines the BabylonJS internal texture
  104858. * @param callback defines the method to call once ready to upload
  104859. */
  104860. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104861. }
  104862. }
  104863. declare module BABYLON {
  104864. /** @hidden */
  104865. export var _forceSceneHelpersToBundle: boolean;
  104866. interface Scene {
  104867. /**
  104868. * Creates a default light for the scene.
  104869. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  104870. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  104871. */
  104872. createDefaultLight(replace?: boolean): void;
  104873. /**
  104874. * Creates a default camera for the scene.
  104875. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  104876. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104877. * @param replace has default false, when true replaces the active camera in the scene
  104878. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  104879. */
  104880. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104881. /**
  104882. * Creates a default camera and a default light.
  104883. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  104884. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104885. * @param replace has the default false, when true replaces the active camera/light in the scene
  104886. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  104887. */
  104888. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104889. /**
  104890. * Creates a new sky box
  104891. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  104892. * @param environmentTexture defines the texture to use as environment texture
  104893. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  104894. * @param scale defines the overall scale of the skybox
  104895. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  104896. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  104897. * @returns a new mesh holding the sky box
  104898. */
  104899. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  104900. /**
  104901. * Creates a new environment
  104902. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  104903. * @param options defines the options you can use to configure the environment
  104904. * @returns the new EnvironmentHelper
  104905. */
  104906. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  104907. /**
  104908. * Creates a new VREXperienceHelper
  104909. * @see http://doc.babylonjs.com/how_to/webvr_helper
  104910. * @param webVROptions defines the options used to create the new VREXperienceHelper
  104911. * @returns a new VREXperienceHelper
  104912. */
  104913. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  104914. /**
  104915. * Creates a new XREXperienceHelper
  104916. * @see http://doc.babylonjs.com/how_to/webxr
  104917. * @returns a promise for a new XREXperienceHelper
  104918. */
  104919. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  104920. }
  104921. }
  104922. declare module BABYLON {
  104923. /**
  104924. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  104925. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  104926. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  104927. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  104928. */
  104929. export class VideoDome extends TransformNode {
  104930. /**
  104931. * Define the video source as a Monoscopic panoramic 360 video.
  104932. */
  104933. static readonly MODE_MONOSCOPIC: number;
  104934. /**
  104935. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104936. */
  104937. static readonly MODE_TOPBOTTOM: number;
  104938. /**
  104939. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104940. */
  104941. static readonly MODE_SIDEBYSIDE: number;
  104942. private _useDirectMapping;
  104943. /**
  104944. * The video texture being displayed on the sphere
  104945. */
  104946. protected _videoTexture: VideoTexture;
  104947. /**
  104948. * Gets the video texture being displayed on the sphere
  104949. */
  104950. readonly videoTexture: VideoTexture;
  104951. /**
  104952. * The skybox material
  104953. */
  104954. protected _material: BackgroundMaterial;
  104955. /**
  104956. * The surface used for the skybox
  104957. */
  104958. protected _mesh: Mesh;
  104959. /**
  104960. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  104961. * Also see the options.resolution property.
  104962. */
  104963. fovMultiplier: number;
  104964. private _videoMode;
  104965. /**
  104966. * Gets or set the current video mode for the video. It can be:
  104967. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  104968. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104969. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104970. */
  104971. videoMode: number;
  104972. /**
  104973. * Oberserver used in Stereoscopic VR Mode.
  104974. */
  104975. private _onBeforeCameraRenderObserver;
  104976. /**
  104977. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  104978. * @param name Element's name, child elements will append suffixes for their own names.
  104979. * @param urlsOrVideo defines the url(s) or the video element to use
  104980. * @param options An object containing optional or exposed sub element properties
  104981. */
  104982. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  104983. resolution?: number;
  104984. clickToPlay?: boolean;
  104985. autoPlay?: boolean;
  104986. loop?: boolean;
  104987. size?: number;
  104988. poster?: string;
  104989. faceForward?: boolean;
  104990. useDirectMapping?: boolean;
  104991. }, scene: Scene);
  104992. private _changeVideoMode;
  104993. /**
  104994. * Releases resources associated with this node.
  104995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104997. */
  104998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104999. }
  105000. }
  105001. declare module BABYLON {
  105002. /**
  105003. * This class can be used to get instrumentation data from a Babylon engine
  105004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105005. */
  105006. export class EngineInstrumentation implements IDisposable {
  105007. /**
  105008. * Define the instrumented engine.
  105009. */
  105010. engine: Engine;
  105011. private _captureGPUFrameTime;
  105012. private _gpuFrameTimeToken;
  105013. private _gpuFrameTime;
  105014. private _captureShaderCompilationTime;
  105015. private _shaderCompilationTime;
  105016. private _onBeginFrameObserver;
  105017. private _onEndFrameObserver;
  105018. private _onBeforeShaderCompilationObserver;
  105019. private _onAfterShaderCompilationObserver;
  105020. /**
  105021. * Gets the perf counter used for GPU frame time
  105022. */
  105023. readonly gpuFrameTimeCounter: PerfCounter;
  105024. /**
  105025. * Gets the GPU frame time capture status
  105026. */
  105027. /**
  105028. * Enable or disable the GPU frame time capture
  105029. */
  105030. captureGPUFrameTime: boolean;
  105031. /**
  105032. * Gets the perf counter used for shader compilation time
  105033. */
  105034. readonly shaderCompilationTimeCounter: PerfCounter;
  105035. /**
  105036. * Gets the shader compilation time capture status
  105037. */
  105038. /**
  105039. * Enable or disable the shader compilation time capture
  105040. */
  105041. captureShaderCompilationTime: boolean;
  105042. /**
  105043. * Instantiates a new engine instrumentation.
  105044. * This class can be used to get instrumentation data from a Babylon engine
  105045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105046. * @param engine Defines the engine to instrument
  105047. */
  105048. constructor(
  105049. /**
  105050. * Define the instrumented engine.
  105051. */
  105052. engine: Engine);
  105053. /**
  105054. * Dispose and release associated resources.
  105055. */
  105056. dispose(): void;
  105057. }
  105058. }
  105059. declare module BABYLON {
  105060. /**
  105061. * This class can be used to get instrumentation data from a Babylon engine
  105062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105063. */
  105064. export class SceneInstrumentation implements IDisposable {
  105065. /**
  105066. * Defines the scene to instrument
  105067. */
  105068. scene: Scene;
  105069. private _captureActiveMeshesEvaluationTime;
  105070. private _activeMeshesEvaluationTime;
  105071. private _captureRenderTargetsRenderTime;
  105072. private _renderTargetsRenderTime;
  105073. private _captureFrameTime;
  105074. private _frameTime;
  105075. private _captureRenderTime;
  105076. private _renderTime;
  105077. private _captureInterFrameTime;
  105078. private _interFrameTime;
  105079. private _captureParticlesRenderTime;
  105080. private _particlesRenderTime;
  105081. private _captureSpritesRenderTime;
  105082. private _spritesRenderTime;
  105083. private _capturePhysicsTime;
  105084. private _physicsTime;
  105085. private _captureAnimationsTime;
  105086. private _animationsTime;
  105087. private _captureCameraRenderTime;
  105088. private _cameraRenderTime;
  105089. private _onBeforeActiveMeshesEvaluationObserver;
  105090. private _onAfterActiveMeshesEvaluationObserver;
  105091. private _onBeforeRenderTargetsRenderObserver;
  105092. private _onAfterRenderTargetsRenderObserver;
  105093. private _onAfterRenderObserver;
  105094. private _onBeforeDrawPhaseObserver;
  105095. private _onAfterDrawPhaseObserver;
  105096. private _onBeforeAnimationsObserver;
  105097. private _onBeforeParticlesRenderingObserver;
  105098. private _onAfterParticlesRenderingObserver;
  105099. private _onBeforeSpritesRenderingObserver;
  105100. private _onAfterSpritesRenderingObserver;
  105101. private _onBeforePhysicsObserver;
  105102. private _onAfterPhysicsObserver;
  105103. private _onAfterAnimationsObserver;
  105104. private _onBeforeCameraRenderObserver;
  105105. private _onAfterCameraRenderObserver;
  105106. /**
  105107. * Gets the perf counter used for active meshes evaluation time
  105108. */
  105109. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105110. /**
  105111. * Gets the active meshes evaluation time capture status
  105112. */
  105113. /**
  105114. * Enable or disable the active meshes evaluation time capture
  105115. */
  105116. captureActiveMeshesEvaluationTime: boolean;
  105117. /**
  105118. * Gets the perf counter used for render targets render time
  105119. */
  105120. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105121. /**
  105122. * Gets the render targets render time capture status
  105123. */
  105124. /**
  105125. * Enable or disable the render targets render time capture
  105126. */
  105127. captureRenderTargetsRenderTime: boolean;
  105128. /**
  105129. * Gets the perf counter used for particles render time
  105130. */
  105131. readonly particlesRenderTimeCounter: PerfCounter;
  105132. /**
  105133. * Gets the particles render time capture status
  105134. */
  105135. /**
  105136. * Enable or disable the particles render time capture
  105137. */
  105138. captureParticlesRenderTime: boolean;
  105139. /**
  105140. * Gets the perf counter used for sprites render time
  105141. */
  105142. readonly spritesRenderTimeCounter: PerfCounter;
  105143. /**
  105144. * Gets the sprites render time capture status
  105145. */
  105146. /**
  105147. * Enable or disable the sprites render time capture
  105148. */
  105149. captureSpritesRenderTime: boolean;
  105150. /**
  105151. * Gets the perf counter used for physics time
  105152. */
  105153. readonly physicsTimeCounter: PerfCounter;
  105154. /**
  105155. * Gets the physics time capture status
  105156. */
  105157. /**
  105158. * Enable or disable the physics time capture
  105159. */
  105160. capturePhysicsTime: boolean;
  105161. /**
  105162. * Gets the perf counter used for animations time
  105163. */
  105164. readonly animationsTimeCounter: PerfCounter;
  105165. /**
  105166. * Gets the animations time capture status
  105167. */
  105168. /**
  105169. * Enable or disable the animations time capture
  105170. */
  105171. captureAnimationsTime: boolean;
  105172. /**
  105173. * Gets the perf counter used for frame time capture
  105174. */
  105175. readonly frameTimeCounter: PerfCounter;
  105176. /**
  105177. * Gets the frame time capture status
  105178. */
  105179. /**
  105180. * Enable or disable the frame time capture
  105181. */
  105182. captureFrameTime: boolean;
  105183. /**
  105184. * Gets the perf counter used for inter-frames time capture
  105185. */
  105186. readonly interFrameTimeCounter: PerfCounter;
  105187. /**
  105188. * Gets the inter-frames time capture status
  105189. */
  105190. /**
  105191. * Enable or disable the inter-frames time capture
  105192. */
  105193. captureInterFrameTime: boolean;
  105194. /**
  105195. * Gets the perf counter used for render time capture
  105196. */
  105197. readonly renderTimeCounter: PerfCounter;
  105198. /**
  105199. * Gets the render time capture status
  105200. */
  105201. /**
  105202. * Enable or disable the render time capture
  105203. */
  105204. captureRenderTime: boolean;
  105205. /**
  105206. * Gets the perf counter used for camera render time capture
  105207. */
  105208. readonly cameraRenderTimeCounter: PerfCounter;
  105209. /**
  105210. * Gets the camera render time capture status
  105211. */
  105212. /**
  105213. * Enable or disable the camera render time capture
  105214. */
  105215. captureCameraRenderTime: boolean;
  105216. /**
  105217. * Gets the perf counter used for draw calls
  105218. */
  105219. readonly drawCallsCounter: PerfCounter;
  105220. /**
  105221. * Gets the perf counter used for texture collisions
  105222. */
  105223. readonly textureCollisionsCounter: PerfCounter;
  105224. /**
  105225. * Instantiates a new scene instrumentation.
  105226. * This class can be used to get instrumentation data from a Babylon engine
  105227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105228. * @param scene Defines the scene to instrument
  105229. */
  105230. constructor(
  105231. /**
  105232. * Defines the scene to instrument
  105233. */
  105234. scene: Scene);
  105235. /**
  105236. * Dispose and release associated resources.
  105237. */
  105238. dispose(): void;
  105239. }
  105240. }
  105241. declare module BABYLON {
  105242. /** @hidden */
  105243. export var glowMapGenerationPixelShader: {
  105244. name: string;
  105245. shader: string;
  105246. };
  105247. }
  105248. declare module BABYLON {
  105249. /** @hidden */
  105250. export var glowMapGenerationVertexShader: {
  105251. name: string;
  105252. shader: string;
  105253. };
  105254. }
  105255. declare module BABYLON {
  105256. /**
  105257. * Effect layer options. This helps customizing the behaviour
  105258. * of the effect layer.
  105259. */
  105260. export interface IEffectLayerOptions {
  105261. /**
  105262. * Multiplication factor apply to the canvas size to compute the render target size
  105263. * used to generated the objects (the smaller the faster).
  105264. */
  105265. mainTextureRatio: number;
  105266. /**
  105267. * Enforces a fixed size texture to ensure effect stability across devices.
  105268. */
  105269. mainTextureFixedSize?: number;
  105270. /**
  105271. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105272. */
  105273. alphaBlendingMode: number;
  105274. /**
  105275. * The camera attached to the layer.
  105276. */
  105277. camera: Nullable<Camera>;
  105278. /**
  105279. * The rendering group to draw the layer in.
  105280. */
  105281. renderingGroupId: number;
  105282. }
  105283. /**
  105284. * The effect layer Helps adding post process effect blended with the main pass.
  105285. *
  105286. * This can be for instance use to generate glow or higlight effects on the scene.
  105287. *
  105288. * The effect layer class can not be used directly and is intented to inherited from to be
  105289. * customized per effects.
  105290. */
  105291. export abstract class EffectLayer {
  105292. private _vertexBuffers;
  105293. private _indexBuffer;
  105294. private _cachedDefines;
  105295. private _effectLayerMapGenerationEffect;
  105296. private _effectLayerOptions;
  105297. private _mergeEffect;
  105298. protected _scene: Scene;
  105299. protected _engine: Engine;
  105300. protected _maxSize: number;
  105301. protected _mainTextureDesiredSize: ISize;
  105302. protected _mainTexture: RenderTargetTexture;
  105303. protected _shouldRender: boolean;
  105304. protected _postProcesses: PostProcess[];
  105305. protected _textures: BaseTexture[];
  105306. protected _emissiveTextureAndColor: {
  105307. texture: Nullable<BaseTexture>;
  105308. color: Color4;
  105309. };
  105310. /**
  105311. * The name of the layer
  105312. */
  105313. name: string;
  105314. /**
  105315. * The clear color of the texture used to generate the glow map.
  105316. */
  105317. neutralColor: Color4;
  105318. /**
  105319. * Specifies wether the highlight layer is enabled or not.
  105320. */
  105321. isEnabled: boolean;
  105322. /**
  105323. * Gets the camera attached to the layer.
  105324. */
  105325. readonly camera: Nullable<Camera>;
  105326. /**
  105327. * Gets the rendering group id the layer should render in.
  105328. */
  105329. readonly renderingGroupId: number;
  105330. /**
  105331. * An event triggered when the effect layer has been disposed.
  105332. */
  105333. onDisposeObservable: Observable<EffectLayer>;
  105334. /**
  105335. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105336. */
  105337. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105338. /**
  105339. * An event triggered when the generated texture is being merged in the scene.
  105340. */
  105341. onBeforeComposeObservable: Observable<EffectLayer>;
  105342. /**
  105343. * An event triggered when the generated texture has been merged in the scene.
  105344. */
  105345. onAfterComposeObservable: Observable<EffectLayer>;
  105346. /**
  105347. * An event triggered when the efffect layer changes its size.
  105348. */
  105349. onSizeChangedObservable: Observable<EffectLayer>;
  105350. /** @hidden */
  105351. static _SceneComponentInitialization: (scene: Scene) => void;
  105352. /**
  105353. * Instantiates a new effect Layer and references it in the scene.
  105354. * @param name The name of the layer
  105355. * @param scene The scene to use the layer in
  105356. */
  105357. constructor(
  105358. /** The Friendly of the effect in the scene */
  105359. name: string, scene: Scene);
  105360. /**
  105361. * Get the effect name of the layer.
  105362. * @return The effect name
  105363. */
  105364. abstract getEffectName(): string;
  105365. /**
  105366. * Checks for the readiness of the element composing the layer.
  105367. * @param subMesh the mesh to check for
  105368. * @param useInstances specify wether or not to use instances to render the mesh
  105369. * @return true if ready otherwise, false
  105370. */
  105371. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105372. /**
  105373. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105374. * @returns true if the effect requires stencil during the main canvas render pass.
  105375. */
  105376. abstract needStencil(): boolean;
  105377. /**
  105378. * Create the merge effect. This is the shader use to blit the information back
  105379. * to the main canvas at the end of the scene rendering.
  105380. * @returns The effect containing the shader used to merge the effect on the main canvas
  105381. */
  105382. protected abstract _createMergeEffect(): Effect;
  105383. /**
  105384. * Creates the render target textures and post processes used in the effect layer.
  105385. */
  105386. protected abstract _createTextureAndPostProcesses(): void;
  105387. /**
  105388. * Implementation specific of rendering the generating effect on the main canvas.
  105389. * @param effect The effect used to render through
  105390. */
  105391. protected abstract _internalRender(effect: Effect): void;
  105392. /**
  105393. * Sets the required values for both the emissive texture and and the main color.
  105394. */
  105395. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105396. /**
  105397. * Free any resources and references associated to a mesh.
  105398. * Internal use
  105399. * @param mesh The mesh to free.
  105400. */
  105401. abstract _disposeMesh(mesh: Mesh): void;
  105402. /**
  105403. * Serializes this layer (Glow or Highlight for example)
  105404. * @returns a serialized layer object
  105405. */
  105406. abstract serialize?(): any;
  105407. /**
  105408. * Initializes the effect layer with the required options.
  105409. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105410. */
  105411. protected _init(options: Partial<IEffectLayerOptions>): void;
  105412. /**
  105413. * Generates the index buffer of the full screen quad blending to the main canvas.
  105414. */
  105415. private _generateIndexBuffer;
  105416. /**
  105417. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105418. */
  105419. private _genrateVertexBuffer;
  105420. /**
  105421. * Sets the main texture desired size which is the closest power of two
  105422. * of the engine canvas size.
  105423. */
  105424. private _setMainTextureSize;
  105425. /**
  105426. * Creates the main texture for the effect layer.
  105427. */
  105428. protected _createMainTexture(): void;
  105429. /**
  105430. * Adds specific effects defines.
  105431. * @param defines The defines to add specifics to.
  105432. */
  105433. protected _addCustomEffectDefines(defines: string[]): void;
  105434. /**
  105435. * Checks for the readiness of the element composing the layer.
  105436. * @param subMesh the mesh to check for
  105437. * @param useInstances specify wether or not to use instances to render the mesh
  105438. * @param emissiveTexture the associated emissive texture used to generate the glow
  105439. * @return true if ready otherwise, false
  105440. */
  105441. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105442. /**
  105443. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105444. */
  105445. render(): void;
  105446. /**
  105447. * Determine if a given mesh will be used in the current effect.
  105448. * @param mesh mesh to test
  105449. * @returns true if the mesh will be used
  105450. */
  105451. hasMesh(mesh: AbstractMesh): boolean;
  105452. /**
  105453. * Returns true if the layer contains information to display, otherwise false.
  105454. * @returns true if the glow layer should be rendered
  105455. */
  105456. shouldRender(): boolean;
  105457. /**
  105458. * Returns true if the mesh should render, otherwise false.
  105459. * @param mesh The mesh to render
  105460. * @returns true if it should render otherwise false
  105461. */
  105462. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105463. /**
  105464. * Returns true if the mesh can be rendered, otherwise false.
  105465. * @param mesh The mesh to render
  105466. * @param material The material used on the mesh
  105467. * @returns true if it can be rendered otherwise false
  105468. */
  105469. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105470. /**
  105471. * Returns true if the mesh should render, otherwise false.
  105472. * @param mesh The mesh to render
  105473. * @returns true if it should render otherwise false
  105474. */
  105475. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105476. /**
  105477. * Renders the submesh passed in parameter to the generation map.
  105478. */
  105479. protected _renderSubMesh(subMesh: SubMesh): void;
  105480. /**
  105481. * Rebuild the required buffers.
  105482. * @hidden Internal use only.
  105483. */
  105484. _rebuild(): void;
  105485. /**
  105486. * Dispose only the render target textures and post process.
  105487. */
  105488. private _disposeTextureAndPostProcesses;
  105489. /**
  105490. * Dispose the highlight layer and free resources.
  105491. */
  105492. dispose(): void;
  105493. /**
  105494. * Gets the class name of the effect layer
  105495. * @returns the string with the class name of the effect layer
  105496. */
  105497. getClassName(): string;
  105498. /**
  105499. * Creates an effect layer from parsed effect layer data
  105500. * @param parsedEffectLayer defines effect layer data
  105501. * @param scene defines the current scene
  105502. * @param rootUrl defines the root URL containing the effect layer information
  105503. * @returns a parsed effect Layer
  105504. */
  105505. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  105506. }
  105507. }
  105508. declare module BABYLON {
  105509. interface AbstractScene {
  105510. /**
  105511. * The list of effect layers (highlights/glow) added to the scene
  105512. * @see http://doc.babylonjs.com/how_to/highlight_layer
  105513. * @see http://doc.babylonjs.com/how_to/glow_layer
  105514. */
  105515. effectLayers: Array<EffectLayer>;
  105516. /**
  105517. * Removes the given effect layer from this scene.
  105518. * @param toRemove defines the effect layer to remove
  105519. * @returns the index of the removed effect layer
  105520. */
  105521. removeEffectLayer(toRemove: EffectLayer): number;
  105522. /**
  105523. * Adds the given effect layer to this scene
  105524. * @param newEffectLayer defines the effect layer to add
  105525. */
  105526. addEffectLayer(newEffectLayer: EffectLayer): void;
  105527. }
  105528. /**
  105529. * Defines the layer scene component responsible to manage any effect layers
  105530. * in a given scene.
  105531. */
  105532. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  105533. /**
  105534. * The component name helpfull to identify the component in the list of scene components.
  105535. */
  105536. readonly name: string;
  105537. /**
  105538. * The scene the component belongs to.
  105539. */
  105540. scene: Scene;
  105541. private _engine;
  105542. private _renderEffects;
  105543. private _needStencil;
  105544. private _previousStencilState;
  105545. /**
  105546. * Creates a new instance of the component for the given scene
  105547. * @param scene Defines the scene to register the component in
  105548. */
  105549. constructor(scene: Scene);
  105550. /**
  105551. * Registers the component in a given scene
  105552. */
  105553. register(): void;
  105554. /**
  105555. * Rebuilds the elements related to this component in case of
  105556. * context lost for instance.
  105557. */
  105558. rebuild(): void;
  105559. /**
  105560. * Serializes the component data to the specified json object
  105561. * @param serializationObject The object to serialize to
  105562. */
  105563. serialize(serializationObject: any): void;
  105564. /**
  105565. * Adds all the element from the container to the scene
  105566. * @param container the container holding the elements
  105567. */
  105568. addFromContainer(container: AbstractScene): void;
  105569. /**
  105570. * Removes all the elements in the container from the scene
  105571. * @param container contains the elements to remove
  105572. * @param dispose if the removed element should be disposed (default: false)
  105573. */
  105574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105575. /**
  105576. * Disposes the component and the associated ressources.
  105577. */
  105578. dispose(): void;
  105579. private _isReadyForMesh;
  105580. private _renderMainTexture;
  105581. private _setStencil;
  105582. private _setStencilBack;
  105583. private _draw;
  105584. private _drawCamera;
  105585. private _drawRenderingGroup;
  105586. }
  105587. }
  105588. declare module BABYLON {
  105589. /** @hidden */
  105590. export var glowMapMergePixelShader: {
  105591. name: string;
  105592. shader: string;
  105593. };
  105594. }
  105595. declare module BABYLON {
  105596. /** @hidden */
  105597. export var glowMapMergeVertexShader: {
  105598. name: string;
  105599. shader: string;
  105600. };
  105601. }
  105602. declare module BABYLON {
  105603. interface AbstractScene {
  105604. /**
  105605. * Return a the first highlight layer of the scene with a given name.
  105606. * @param name The name of the highlight layer to look for.
  105607. * @return The highlight layer if found otherwise null.
  105608. */
  105609. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  105610. }
  105611. /**
  105612. * Glow layer options. This helps customizing the behaviour
  105613. * of the glow layer.
  105614. */
  105615. export interface IGlowLayerOptions {
  105616. /**
  105617. * Multiplication factor apply to the canvas size to compute the render target size
  105618. * used to generated the glowing objects (the smaller the faster).
  105619. */
  105620. mainTextureRatio: number;
  105621. /**
  105622. * Enforces a fixed size texture to ensure resize independant blur.
  105623. */
  105624. mainTextureFixedSize?: number;
  105625. /**
  105626. * How big is the kernel of the blur texture.
  105627. */
  105628. blurKernelSize: number;
  105629. /**
  105630. * The camera attached to the layer.
  105631. */
  105632. camera: Nullable<Camera>;
  105633. /**
  105634. * Enable MSAA by chosing the number of samples.
  105635. */
  105636. mainTextureSamples?: number;
  105637. /**
  105638. * The rendering group to draw the layer in.
  105639. */
  105640. renderingGroupId: number;
  105641. }
  105642. /**
  105643. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  105644. *
  105645. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105646. * glowy meshes to your scene.
  105647. *
  105648. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  105649. */
  105650. export class GlowLayer extends EffectLayer {
  105651. /**
  105652. * Effect Name of the layer.
  105653. */
  105654. static readonly EffectName: string;
  105655. /**
  105656. * The default blur kernel size used for the glow.
  105657. */
  105658. static DefaultBlurKernelSize: number;
  105659. /**
  105660. * The default texture size ratio used for the glow.
  105661. */
  105662. static DefaultTextureRatio: number;
  105663. /**
  105664. * Sets the kernel size of the blur.
  105665. */
  105666. /**
  105667. * Gets the kernel size of the blur.
  105668. */
  105669. blurKernelSize: number;
  105670. /**
  105671. * Sets the glow intensity.
  105672. */
  105673. /**
  105674. * Gets the glow intensity.
  105675. */
  105676. intensity: number;
  105677. private _options;
  105678. private _intensity;
  105679. private _horizontalBlurPostprocess1;
  105680. private _verticalBlurPostprocess1;
  105681. private _horizontalBlurPostprocess2;
  105682. private _verticalBlurPostprocess2;
  105683. private _blurTexture1;
  105684. private _blurTexture2;
  105685. private _postProcesses1;
  105686. private _postProcesses2;
  105687. private _includedOnlyMeshes;
  105688. private _excludedMeshes;
  105689. /**
  105690. * Callback used to let the user override the color selection on a per mesh basis
  105691. */
  105692. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  105693. /**
  105694. * Callback used to let the user override the texture selection on a per mesh basis
  105695. */
  105696. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  105697. /**
  105698. * Instantiates a new glow Layer and references it to the scene.
  105699. * @param name The name of the layer
  105700. * @param scene The scene to use the layer in
  105701. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  105702. */
  105703. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  105704. /**
  105705. * Get the effect name of the layer.
  105706. * @return The effect name
  105707. */
  105708. getEffectName(): string;
  105709. /**
  105710. * Create the merge effect. This is the shader use to blit the information back
  105711. * to the main canvas at the end of the scene rendering.
  105712. */
  105713. protected _createMergeEffect(): Effect;
  105714. /**
  105715. * Creates the render target textures and post processes used in the glow layer.
  105716. */
  105717. protected _createTextureAndPostProcesses(): void;
  105718. /**
  105719. * Checks for the readiness of the element composing the layer.
  105720. * @param subMesh the mesh to check for
  105721. * @param useInstances specify wether or not to use instances to render the mesh
  105722. * @param emissiveTexture the associated emissive texture used to generate the glow
  105723. * @return true if ready otherwise, false
  105724. */
  105725. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105726. /**
  105727. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105728. */
  105729. needStencil(): boolean;
  105730. /**
  105731. * Returns true if the mesh can be rendered, otherwise false.
  105732. * @param mesh The mesh to render
  105733. * @param material The material used on the mesh
  105734. * @returns true if it can be rendered otherwise false
  105735. */
  105736. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105737. /**
  105738. * Implementation specific of rendering the generating effect on the main canvas.
  105739. * @param effect The effect used to render through
  105740. */
  105741. protected _internalRender(effect: Effect): void;
  105742. /**
  105743. * Sets the required values for both the emissive texture and and the main color.
  105744. */
  105745. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105746. /**
  105747. * Returns true if the mesh should render, otherwise false.
  105748. * @param mesh The mesh to render
  105749. * @returns true if it should render otherwise false
  105750. */
  105751. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105752. /**
  105753. * Adds specific effects defines.
  105754. * @param defines The defines to add specifics to.
  105755. */
  105756. protected _addCustomEffectDefines(defines: string[]): void;
  105757. /**
  105758. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  105759. * @param mesh The mesh to exclude from the glow layer
  105760. */
  105761. addExcludedMesh(mesh: Mesh): void;
  105762. /**
  105763. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  105764. * @param mesh The mesh to remove
  105765. */
  105766. removeExcludedMesh(mesh: Mesh): void;
  105767. /**
  105768. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  105769. * @param mesh The mesh to include in the glow layer
  105770. */
  105771. addIncludedOnlyMesh(mesh: Mesh): void;
  105772. /**
  105773. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  105774. * @param mesh The mesh to remove
  105775. */
  105776. removeIncludedOnlyMesh(mesh: Mesh): void;
  105777. /**
  105778. * Determine if a given mesh will be used in the glow layer
  105779. * @param mesh The mesh to test
  105780. * @returns true if the mesh will be highlighted by the current glow layer
  105781. */
  105782. hasMesh(mesh: AbstractMesh): boolean;
  105783. /**
  105784. * Free any resources and references associated to a mesh.
  105785. * Internal use
  105786. * @param mesh The mesh to free.
  105787. * @hidden
  105788. */
  105789. _disposeMesh(mesh: Mesh): void;
  105790. /**
  105791. * Gets the class name of the effect layer
  105792. * @returns the string with the class name of the effect layer
  105793. */
  105794. getClassName(): string;
  105795. /**
  105796. * Serializes this glow layer
  105797. * @returns a serialized glow layer object
  105798. */
  105799. serialize(): any;
  105800. /**
  105801. * Creates a Glow Layer from parsed glow layer data
  105802. * @param parsedGlowLayer defines glow layer data
  105803. * @param scene defines the current scene
  105804. * @param rootUrl defines the root URL containing the glow layer information
  105805. * @returns a parsed Glow Layer
  105806. */
  105807. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  105808. }
  105809. }
  105810. declare module BABYLON {
  105811. /** @hidden */
  105812. export var glowBlurPostProcessPixelShader: {
  105813. name: string;
  105814. shader: string;
  105815. };
  105816. }
  105817. declare module BABYLON {
  105818. interface AbstractScene {
  105819. /**
  105820. * Return a the first highlight layer of the scene with a given name.
  105821. * @param name The name of the highlight layer to look for.
  105822. * @return The highlight layer if found otherwise null.
  105823. */
  105824. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  105825. }
  105826. /**
  105827. * Highlight layer options. This helps customizing the behaviour
  105828. * of the highlight layer.
  105829. */
  105830. export interface IHighlightLayerOptions {
  105831. /**
  105832. * Multiplication factor apply to the canvas size to compute the render target size
  105833. * used to generated the glowing objects (the smaller the faster).
  105834. */
  105835. mainTextureRatio: number;
  105836. /**
  105837. * Enforces a fixed size texture to ensure resize independant blur.
  105838. */
  105839. mainTextureFixedSize?: number;
  105840. /**
  105841. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  105842. * of the picture to blur (the smaller the faster).
  105843. */
  105844. blurTextureSizeRatio: number;
  105845. /**
  105846. * How big in texel of the blur texture is the vertical blur.
  105847. */
  105848. blurVerticalSize: number;
  105849. /**
  105850. * How big in texel of the blur texture is the horizontal blur.
  105851. */
  105852. blurHorizontalSize: number;
  105853. /**
  105854. * Alpha blending mode used to apply the blur. Default is combine.
  105855. */
  105856. alphaBlendingMode: number;
  105857. /**
  105858. * The camera attached to the layer.
  105859. */
  105860. camera: Nullable<Camera>;
  105861. /**
  105862. * Should we display highlight as a solid stroke?
  105863. */
  105864. isStroke?: boolean;
  105865. /**
  105866. * The rendering group to draw the layer in.
  105867. */
  105868. renderingGroupId: number;
  105869. }
  105870. /**
  105871. * The highlight layer Helps adding a glow effect around a mesh.
  105872. *
  105873. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105874. * glowy meshes to your scene.
  105875. *
  105876. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  105877. */
  105878. export class HighlightLayer extends EffectLayer {
  105879. name: string;
  105880. /**
  105881. * Effect Name of the highlight layer.
  105882. */
  105883. static readonly EffectName: string;
  105884. /**
  105885. * The neutral color used during the preparation of the glow effect.
  105886. * This is black by default as the blend operation is a blend operation.
  105887. */
  105888. static NeutralColor: Color4;
  105889. /**
  105890. * Stencil value used for glowing meshes.
  105891. */
  105892. static GlowingMeshStencilReference: number;
  105893. /**
  105894. * Stencil value used for the other meshes in the scene.
  105895. */
  105896. static NormalMeshStencilReference: number;
  105897. /**
  105898. * Specifies whether or not the inner glow is ACTIVE in the layer.
  105899. */
  105900. innerGlow: boolean;
  105901. /**
  105902. * Specifies whether or not the outer glow is ACTIVE in the layer.
  105903. */
  105904. outerGlow: boolean;
  105905. /**
  105906. * Specifies the horizontal size of the blur.
  105907. */
  105908. /**
  105909. * Gets the horizontal size of the blur.
  105910. */
  105911. blurHorizontalSize: number;
  105912. /**
  105913. * Specifies the vertical size of the blur.
  105914. */
  105915. /**
  105916. * Gets the vertical size of the blur.
  105917. */
  105918. blurVerticalSize: number;
  105919. /**
  105920. * An event triggered when the highlight layer is being blurred.
  105921. */
  105922. onBeforeBlurObservable: Observable<HighlightLayer>;
  105923. /**
  105924. * An event triggered when the highlight layer has been blurred.
  105925. */
  105926. onAfterBlurObservable: Observable<HighlightLayer>;
  105927. private _instanceGlowingMeshStencilReference;
  105928. private _options;
  105929. private _downSamplePostprocess;
  105930. private _horizontalBlurPostprocess;
  105931. private _verticalBlurPostprocess;
  105932. private _blurTexture;
  105933. private _meshes;
  105934. private _excludedMeshes;
  105935. /**
  105936. * Instantiates a new highlight Layer and references it to the scene..
  105937. * @param name The name of the layer
  105938. * @param scene The scene to use the layer in
  105939. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  105940. */
  105941. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  105942. /**
  105943. * Get the effect name of the layer.
  105944. * @return The effect name
  105945. */
  105946. getEffectName(): string;
  105947. /**
  105948. * Create the merge effect. This is the shader use to blit the information back
  105949. * to the main canvas at the end of the scene rendering.
  105950. */
  105951. protected _createMergeEffect(): Effect;
  105952. /**
  105953. * Creates the render target textures and post processes used in the highlight layer.
  105954. */
  105955. protected _createTextureAndPostProcesses(): void;
  105956. /**
  105957. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105958. */
  105959. needStencil(): boolean;
  105960. /**
  105961. * Checks for the readiness of the element composing the layer.
  105962. * @param subMesh the mesh to check for
  105963. * @param useInstances specify wether or not to use instances to render the mesh
  105964. * @param emissiveTexture the associated emissive texture used to generate the glow
  105965. * @return true if ready otherwise, false
  105966. */
  105967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105968. /**
  105969. * Implementation specific of rendering the generating effect on the main canvas.
  105970. * @param effect The effect used to render through
  105971. */
  105972. protected _internalRender(effect: Effect): void;
  105973. /**
  105974. * Returns true if the layer contains information to display, otherwise false.
  105975. */
  105976. shouldRender(): boolean;
  105977. /**
  105978. * Returns true if the mesh should render, otherwise false.
  105979. * @param mesh The mesh to render
  105980. * @returns true if it should render otherwise false
  105981. */
  105982. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105983. /**
  105984. * Sets the required values for both the emissive texture and and the main color.
  105985. */
  105986. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105987. /**
  105988. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  105989. * @param mesh The mesh to exclude from the highlight layer
  105990. */
  105991. addExcludedMesh(mesh: Mesh): void;
  105992. /**
  105993. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  105994. * @param mesh The mesh to highlight
  105995. */
  105996. removeExcludedMesh(mesh: Mesh): void;
  105997. /**
  105998. * Determine if a given mesh will be highlighted by the current HighlightLayer
  105999. * @param mesh mesh to test
  106000. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106001. */
  106002. hasMesh(mesh: AbstractMesh): boolean;
  106003. /**
  106004. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106005. * @param mesh The mesh to highlight
  106006. * @param color The color of the highlight
  106007. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106008. */
  106009. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106010. /**
  106011. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106012. * @param mesh The mesh to highlight
  106013. */
  106014. removeMesh(mesh: Mesh): void;
  106015. /**
  106016. * Force the stencil to the normal expected value for none glowing parts
  106017. */
  106018. private _defaultStencilReference;
  106019. /**
  106020. * Free any resources and references associated to a mesh.
  106021. * Internal use
  106022. * @param mesh The mesh to free.
  106023. * @hidden
  106024. */
  106025. _disposeMesh(mesh: Mesh): void;
  106026. /**
  106027. * Dispose the highlight layer and free resources.
  106028. */
  106029. dispose(): void;
  106030. /**
  106031. * Gets the class name of the effect layer
  106032. * @returns the string with the class name of the effect layer
  106033. */
  106034. getClassName(): string;
  106035. /**
  106036. * Serializes this Highlight layer
  106037. * @returns a serialized Highlight layer object
  106038. */
  106039. serialize(): any;
  106040. /**
  106041. * Creates a Highlight layer from parsed Highlight layer data
  106042. * @param parsedHightlightLayer defines the Highlight layer data
  106043. * @param scene defines the current scene
  106044. * @param rootUrl defines the root URL containing the Highlight layer information
  106045. * @returns a parsed Highlight layer
  106046. */
  106047. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106048. }
  106049. }
  106050. declare module BABYLON {
  106051. /** @hidden */
  106052. export var lensFlarePixelShader: {
  106053. name: string;
  106054. shader: string;
  106055. };
  106056. }
  106057. declare module BABYLON {
  106058. /** @hidden */
  106059. export var lensFlareVertexShader: {
  106060. name: string;
  106061. shader: string;
  106062. };
  106063. }
  106064. declare module BABYLON {
  106065. /**
  106066. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106067. * It is usually composed of several `lensFlare`.
  106068. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106069. */
  106070. export class LensFlareSystem {
  106071. /**
  106072. * Define the name of the lens flare system
  106073. */
  106074. name: string;
  106075. /**
  106076. * List of lens flares used in this system.
  106077. */
  106078. lensFlares: LensFlare[];
  106079. /**
  106080. * Define a limit from the border the lens flare can be visible.
  106081. */
  106082. borderLimit: number;
  106083. /**
  106084. * Define a viewport border we do not want to see the lens flare in.
  106085. */
  106086. viewportBorder: number;
  106087. /**
  106088. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106089. */
  106090. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106091. /**
  106092. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106093. */
  106094. layerMask: number;
  106095. /**
  106096. * Define the id of the lens flare system in the scene.
  106097. * (equal to name by default)
  106098. */
  106099. id: string;
  106100. private _scene;
  106101. private _emitter;
  106102. private _vertexBuffers;
  106103. private _indexBuffer;
  106104. private _effect;
  106105. private _positionX;
  106106. private _positionY;
  106107. private _isEnabled;
  106108. /** @hidden */
  106109. static _SceneComponentInitialization: (scene: Scene) => void;
  106110. /**
  106111. * Instantiates a lens flare system.
  106112. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106113. * It is usually composed of several `lensFlare`.
  106114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106115. * @param name Define the name of the lens flare system in the scene
  106116. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106117. * @param scene Define the scene the lens flare system belongs to
  106118. */
  106119. constructor(
  106120. /**
  106121. * Define the name of the lens flare system
  106122. */
  106123. name: string, emitter: any, scene: Scene);
  106124. /**
  106125. * Define if the lens flare system is enabled.
  106126. */
  106127. isEnabled: boolean;
  106128. /**
  106129. * Get the scene the effects belongs to.
  106130. * @returns the scene holding the lens flare system
  106131. */
  106132. getScene(): Scene;
  106133. /**
  106134. * Get the emitter of the lens flare system.
  106135. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106136. * @returns the emitter of the lens flare system
  106137. */
  106138. getEmitter(): any;
  106139. /**
  106140. * Set the emitter of the lens flare system.
  106141. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106142. * @param newEmitter Define the new emitter of the system
  106143. */
  106144. setEmitter(newEmitter: any): void;
  106145. /**
  106146. * Get the lens flare system emitter position.
  106147. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106148. * @returns the position
  106149. */
  106150. getEmitterPosition(): Vector3;
  106151. /**
  106152. * @hidden
  106153. */
  106154. computeEffectivePosition(globalViewport: Viewport): boolean;
  106155. /** @hidden */
  106156. _isVisible(): boolean;
  106157. /**
  106158. * @hidden
  106159. */
  106160. render(): boolean;
  106161. /**
  106162. * Dispose and release the lens flare with its associated resources.
  106163. */
  106164. dispose(): void;
  106165. /**
  106166. * Parse a lens flare system from a JSON repressentation
  106167. * @param parsedLensFlareSystem Define the JSON to parse
  106168. * @param scene Define the scene the parsed system should be instantiated in
  106169. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106170. * @returns the parsed system
  106171. */
  106172. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106173. /**
  106174. * Serialize the current Lens Flare System into a JSON representation.
  106175. * @returns the serialized JSON
  106176. */
  106177. serialize(): any;
  106178. }
  106179. }
  106180. declare module BABYLON {
  106181. /**
  106182. * This represents one of the lens effect in a `lensFlareSystem`.
  106183. * It controls one of the indiviual texture used in the effect.
  106184. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106185. */
  106186. export class LensFlare {
  106187. /**
  106188. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106189. */
  106190. size: number;
  106191. /**
  106192. * 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.
  106193. */
  106194. position: number;
  106195. /**
  106196. * Define the lens color.
  106197. */
  106198. color: Color3;
  106199. /**
  106200. * Define the lens texture.
  106201. */
  106202. texture: Nullable<Texture>;
  106203. /**
  106204. * Define the alpha mode to render this particular lens.
  106205. */
  106206. alphaMode: number;
  106207. private _system;
  106208. /**
  106209. * Creates a new Lens Flare.
  106210. * This represents one of the lens effect in a `lensFlareSystem`.
  106211. * It controls one of the indiviual texture used in the effect.
  106212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106213. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106214. * @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.
  106215. * @param color Define the lens color
  106216. * @param imgUrl Define the lens texture url
  106217. * @param system Define the `lensFlareSystem` this flare is part of
  106218. * @returns The newly created Lens Flare
  106219. */
  106220. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106221. /**
  106222. * Instantiates a new Lens Flare.
  106223. * This represents one of the lens effect in a `lensFlareSystem`.
  106224. * It controls one of the indiviual texture used in the effect.
  106225. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106226. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106227. * @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.
  106228. * @param color Define the lens color
  106229. * @param imgUrl Define the lens texture url
  106230. * @param system Define the `lensFlareSystem` this flare is part of
  106231. */
  106232. constructor(
  106233. /**
  106234. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106235. */
  106236. size: number,
  106237. /**
  106238. * 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.
  106239. */
  106240. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106241. /**
  106242. * Dispose and release the lens flare with its associated resources.
  106243. */
  106244. dispose(): void;
  106245. }
  106246. }
  106247. declare module BABYLON {
  106248. interface AbstractScene {
  106249. /**
  106250. * The list of lens flare system added to the scene
  106251. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106252. */
  106253. lensFlareSystems: Array<LensFlareSystem>;
  106254. /**
  106255. * Removes the given lens flare system from this scene.
  106256. * @param toRemove The lens flare system to remove
  106257. * @returns The index of the removed lens flare system
  106258. */
  106259. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106260. /**
  106261. * Adds the given lens flare system to this scene
  106262. * @param newLensFlareSystem The lens flare system to add
  106263. */
  106264. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106265. /**
  106266. * Gets a lens flare system using its name
  106267. * @param name defines the name to look for
  106268. * @returns the lens flare system or null if not found
  106269. */
  106270. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106271. /**
  106272. * Gets a lens flare system using its id
  106273. * @param id defines the id to look for
  106274. * @returns the lens flare system or null if not found
  106275. */
  106276. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106277. }
  106278. /**
  106279. * Defines the lens flare scene component responsible to manage any lens flares
  106280. * in a given scene.
  106281. */
  106282. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106283. /**
  106284. * The component name helpfull to identify the component in the list of scene components.
  106285. */
  106286. readonly name: string;
  106287. /**
  106288. * The scene the component belongs to.
  106289. */
  106290. scene: Scene;
  106291. /**
  106292. * Creates a new instance of the component for the given scene
  106293. * @param scene Defines the scene to register the component in
  106294. */
  106295. constructor(scene: Scene);
  106296. /**
  106297. * Registers the component in a given scene
  106298. */
  106299. register(): void;
  106300. /**
  106301. * Rebuilds the elements related to this component in case of
  106302. * context lost for instance.
  106303. */
  106304. rebuild(): void;
  106305. /**
  106306. * Adds all the element from the container to the scene
  106307. * @param container the container holding the elements
  106308. */
  106309. addFromContainer(container: AbstractScene): void;
  106310. /**
  106311. * Removes all the elements in the container from the scene
  106312. * @param container contains the elements to remove
  106313. * @param dispose if the removed element should be disposed (default: false)
  106314. */
  106315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106316. /**
  106317. * Serializes the component data to the specified json object
  106318. * @param serializationObject The object to serialize to
  106319. */
  106320. serialize(serializationObject: any): void;
  106321. /**
  106322. * Disposes the component and the associated ressources.
  106323. */
  106324. dispose(): void;
  106325. private _draw;
  106326. }
  106327. }
  106328. declare module BABYLON {
  106329. /**
  106330. * Defines the shadow generator component responsible to manage any shadow generators
  106331. * in a given scene.
  106332. */
  106333. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106334. /**
  106335. * The component name helpfull to identify the component in the list of scene components.
  106336. */
  106337. readonly name: string;
  106338. /**
  106339. * The scene the component belongs to.
  106340. */
  106341. scene: Scene;
  106342. /**
  106343. * Creates a new instance of the component for the given scene
  106344. * @param scene Defines the scene to register the component in
  106345. */
  106346. constructor(scene: Scene);
  106347. /**
  106348. * Registers the component in a given scene
  106349. */
  106350. register(): void;
  106351. /**
  106352. * Rebuilds the elements related to this component in case of
  106353. * context lost for instance.
  106354. */
  106355. rebuild(): void;
  106356. /**
  106357. * Serializes the component data to the specified json object
  106358. * @param serializationObject The object to serialize to
  106359. */
  106360. serialize(serializationObject: any): void;
  106361. /**
  106362. * Adds all the element from the container to the scene
  106363. * @param container the container holding the elements
  106364. */
  106365. addFromContainer(container: AbstractScene): void;
  106366. /**
  106367. * Removes all the elements in the container from the scene
  106368. * @param container contains the elements to remove
  106369. * @param dispose if the removed element should be disposed (default: false)
  106370. */
  106371. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106372. /**
  106373. * Rebuilds the elements related to this component in case of
  106374. * context lost for instance.
  106375. */
  106376. dispose(): void;
  106377. private _gatherRenderTargets;
  106378. }
  106379. }
  106380. declare module BABYLON {
  106381. /**
  106382. * A point light is a light defined by an unique point in world space.
  106383. * The light is emitted in every direction from this point.
  106384. * A good example of a point light is a standard light bulb.
  106385. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106386. */
  106387. export class PointLight extends ShadowLight {
  106388. private _shadowAngle;
  106389. /**
  106390. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106391. * This specifies what angle the shadow will use to be created.
  106392. *
  106393. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106394. */
  106395. /**
  106396. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106397. * This specifies what angle the shadow will use to be created.
  106398. *
  106399. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106400. */
  106401. shadowAngle: number;
  106402. /**
  106403. * Gets the direction if it has been set.
  106404. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106405. */
  106406. /**
  106407. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106408. */
  106409. direction: Vector3;
  106410. /**
  106411. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106412. * A PointLight emits the light in every direction.
  106413. * It can cast shadows.
  106414. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106415. * ```javascript
  106416. * var pointLight = new PointLight("pl", camera.position, scene);
  106417. * ```
  106418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106419. * @param name The light friendly name
  106420. * @param position The position of the point light in the scene
  106421. * @param scene The scene the lights belongs to
  106422. */
  106423. constructor(name: string, position: Vector3, scene: Scene);
  106424. /**
  106425. * Returns the string "PointLight"
  106426. * @returns the class name
  106427. */
  106428. getClassName(): string;
  106429. /**
  106430. * Returns the integer 0.
  106431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106432. */
  106433. getTypeID(): number;
  106434. /**
  106435. * Specifies wether or not the shadowmap should be a cube texture.
  106436. * @returns true if the shadowmap needs to be a cube texture.
  106437. */
  106438. needCube(): boolean;
  106439. /**
  106440. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106441. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106442. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106443. */
  106444. getShadowDirection(faceIndex?: number): Vector3;
  106445. /**
  106446. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106447. * - fov = PI / 2
  106448. * - aspect ratio : 1.0
  106449. * - z-near and far equal to the active camera minZ and maxZ.
  106450. * Returns the PointLight.
  106451. */
  106452. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106453. protected _buildUniformLayout(): void;
  106454. /**
  106455. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106456. * @param effect The effect to update
  106457. * @param lightIndex The index of the light in the effect to update
  106458. * @returns The point light
  106459. */
  106460. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106461. /**
  106462. * Prepares the list of defines specific to the light type.
  106463. * @param defines the list of defines
  106464. * @param lightIndex defines the index of the light for the effect
  106465. */
  106466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106467. }
  106468. }
  106469. declare module BABYLON {
  106470. /**
  106471. * Header information of HDR texture files.
  106472. */
  106473. export interface HDRInfo {
  106474. /**
  106475. * The height of the texture in pixels.
  106476. */
  106477. height: number;
  106478. /**
  106479. * The width of the texture in pixels.
  106480. */
  106481. width: number;
  106482. /**
  106483. * The index of the beginning of the data in the binary file.
  106484. */
  106485. dataPosition: number;
  106486. }
  106487. /**
  106488. * This groups tools to convert HDR texture to native colors array.
  106489. */
  106490. export class HDRTools {
  106491. private static Ldexp;
  106492. private static Rgbe2float;
  106493. private static readStringLine;
  106494. /**
  106495. * Reads header information from an RGBE texture stored in a native array.
  106496. * More information on this format are available here:
  106497. * https://en.wikipedia.org/wiki/RGBE_image_format
  106498. *
  106499. * @param uint8array The binary file stored in native array.
  106500. * @return The header information.
  106501. */
  106502. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  106503. /**
  106504. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106505. * This RGBE texture needs to store the information as a panorama.
  106506. *
  106507. * More information on this format are available here:
  106508. * https://en.wikipedia.org/wiki/RGBE_image_format
  106509. *
  106510. * @param buffer The binary file stored in an array buffer.
  106511. * @param size The expected size of the extracted cubemap.
  106512. * @return The Cube Map information.
  106513. */
  106514. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  106515. /**
  106516. * Returns the pixels data extracted from an RGBE texture.
  106517. * This pixels will be stored left to right up to down in the R G B order in one array.
  106518. *
  106519. * More information on this format are available here:
  106520. * https://en.wikipedia.org/wiki/RGBE_image_format
  106521. *
  106522. * @param uint8array The binary file stored in an array buffer.
  106523. * @param hdrInfo The header information of the file.
  106524. * @return The pixels data in RGB right to left up to down order.
  106525. */
  106526. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  106527. private static RGBE_ReadPixels_RLE;
  106528. }
  106529. }
  106530. declare module BABYLON {
  106531. /**
  106532. * This represents a texture coming from an HDR input.
  106533. *
  106534. * The only supported format is currently panorama picture stored in RGBE format.
  106535. * Example of such files can be found on HDRLib: http://hdrlib.com/
  106536. */
  106537. export class HDRCubeTexture extends BaseTexture {
  106538. private static _facesMapping;
  106539. private _generateHarmonics;
  106540. private _noMipmap;
  106541. private _textureMatrix;
  106542. private _size;
  106543. private _onLoad;
  106544. private _onError;
  106545. /**
  106546. * The texture URL.
  106547. */
  106548. url: string;
  106549. /**
  106550. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  106551. */
  106552. coordinatesMode: number;
  106553. protected _isBlocking: boolean;
  106554. /**
  106555. * Sets wether or not the texture is blocking during loading.
  106556. */
  106557. /**
  106558. * Gets wether or not the texture is blocking during loading.
  106559. */
  106560. isBlocking: boolean;
  106561. protected _rotationY: number;
  106562. /**
  106563. * Sets texture matrix rotation angle around Y axis in radians.
  106564. */
  106565. /**
  106566. * Gets texture matrix rotation angle around Y axis radians.
  106567. */
  106568. rotationY: number;
  106569. /**
  106570. * Gets or sets the center of the bounding box associated with the cube texture
  106571. * It must define where the camera used to render the texture was set
  106572. */
  106573. boundingBoxPosition: Vector3;
  106574. private _boundingBoxSize;
  106575. /**
  106576. * Gets or sets the size of the bounding box associated with the cube texture
  106577. * When defined, the cubemap will switch to local mode
  106578. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  106579. * @example https://www.babylonjs-playground.com/#RNASML
  106580. */
  106581. boundingBoxSize: Vector3;
  106582. /**
  106583. * Instantiates an HDRTexture from the following parameters.
  106584. *
  106585. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  106586. * @param scene The scene the texture will be used in
  106587. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106588. * @param noMipmap Forces to not generate the mipmap if true
  106589. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  106590. * @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)
  106591. * @param reserved Reserved flag for internal use.
  106592. */
  106593. 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>);
  106594. /**
  106595. * Get the current class name of the texture useful for serialization or dynamic coding.
  106596. * @returns "HDRCubeTexture"
  106597. */
  106598. getClassName(): string;
  106599. /**
  106600. * Occurs when the file is raw .hdr file.
  106601. */
  106602. private loadTexture;
  106603. clone(): HDRCubeTexture;
  106604. delayLoad(): void;
  106605. /**
  106606. * Get the texture reflection matrix used to rotate/transform the reflection.
  106607. * @returns the reflection matrix
  106608. */
  106609. getReflectionTextureMatrix(): Matrix;
  106610. /**
  106611. * Set the texture reflection matrix used to rotate/transform the reflection.
  106612. * @param value Define the reflection matrix to set
  106613. */
  106614. setReflectionTextureMatrix(value: Matrix): void;
  106615. /**
  106616. * Parses a JSON representation of an HDR Texture in order to create the texture
  106617. * @param parsedTexture Define the JSON representation
  106618. * @param scene Define the scene the texture should be created in
  106619. * @param rootUrl Define the root url in case we need to load relative dependencies
  106620. * @returns the newly created texture after parsing
  106621. */
  106622. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  106623. serialize(): any;
  106624. }
  106625. }
  106626. declare module BABYLON {
  106627. /**
  106628. * Class used to control physics engine
  106629. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106630. */
  106631. export class PhysicsEngine implements IPhysicsEngine {
  106632. private _physicsPlugin;
  106633. /**
  106634. * Global value used to control the smallest number supported by the simulation
  106635. */
  106636. static Epsilon: number;
  106637. private _impostors;
  106638. private _joints;
  106639. /**
  106640. * Gets the gravity vector used by the simulation
  106641. */
  106642. gravity: Vector3;
  106643. /**
  106644. * Factory used to create the default physics plugin.
  106645. * @returns The default physics plugin
  106646. */
  106647. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  106648. /**
  106649. * Creates a new Physics Engine
  106650. * @param gravity defines the gravity vector used by the simulation
  106651. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  106652. */
  106653. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  106654. /**
  106655. * Sets the gravity vector used by the simulation
  106656. * @param gravity defines the gravity vector to use
  106657. */
  106658. setGravity(gravity: Vector3): void;
  106659. /**
  106660. * Set the time step of the physics engine.
  106661. * Default is 1/60.
  106662. * To slow it down, enter 1/600 for example.
  106663. * To speed it up, 1/30
  106664. * @param newTimeStep defines the new timestep to apply to this world.
  106665. */
  106666. setTimeStep(newTimeStep?: number): void;
  106667. /**
  106668. * Get the time step of the physics engine.
  106669. * @returns the current time step
  106670. */
  106671. getTimeStep(): number;
  106672. /**
  106673. * Release all resources
  106674. */
  106675. dispose(): void;
  106676. /**
  106677. * Gets the name of the current physics plugin
  106678. * @returns the name of the plugin
  106679. */
  106680. getPhysicsPluginName(): string;
  106681. /**
  106682. * Adding a new impostor for the impostor tracking.
  106683. * This will be done by the impostor itself.
  106684. * @param impostor the impostor to add
  106685. */
  106686. addImpostor(impostor: PhysicsImpostor): void;
  106687. /**
  106688. * Remove an impostor from the engine.
  106689. * This impostor and its mesh will not longer be updated by the physics engine.
  106690. * @param impostor the impostor to remove
  106691. */
  106692. removeImpostor(impostor: PhysicsImpostor): void;
  106693. /**
  106694. * Add a joint to the physics engine
  106695. * @param mainImpostor defines the main impostor to which the joint is added.
  106696. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106697. * @param joint defines the joint that will connect both impostors.
  106698. */
  106699. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106700. /**
  106701. * Removes a joint from the simulation
  106702. * @param mainImpostor defines the impostor used with the joint
  106703. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106704. * @param joint defines the joint to remove
  106705. */
  106706. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106707. /**
  106708. * Called by the scene. No need to call it.
  106709. * @param delta defines the timespam between frames
  106710. */
  106711. _step(delta: number): void;
  106712. /**
  106713. * Gets the current plugin used to run the simulation
  106714. * @returns current plugin
  106715. */
  106716. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106717. /**
  106718. * Gets the list of physic impostors
  106719. * @returns an array of PhysicsImpostor
  106720. */
  106721. getImpostors(): Array<PhysicsImpostor>;
  106722. /**
  106723. * Gets the impostor for a physics enabled object
  106724. * @param object defines the object impersonated by the impostor
  106725. * @returns the PhysicsImpostor or null if not found
  106726. */
  106727. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106728. /**
  106729. * Gets the impostor for a physics body object
  106730. * @param body defines physics body used by the impostor
  106731. * @returns the PhysicsImpostor or null if not found
  106732. */
  106733. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106734. /**
  106735. * Does a raycast in the physics world
  106736. * @param from when should the ray start?
  106737. * @param to when should the ray end?
  106738. * @returns PhysicsRaycastResult
  106739. */
  106740. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106741. }
  106742. }
  106743. declare module BABYLON {
  106744. /** @hidden */
  106745. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  106746. private _useDeltaForWorldStep;
  106747. world: any;
  106748. name: string;
  106749. private _physicsMaterials;
  106750. private _fixedTimeStep;
  106751. private _cannonRaycastResult;
  106752. private _raycastResult;
  106753. private _removeAfterStep;
  106754. BJSCANNON: any;
  106755. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  106756. setGravity(gravity: Vector3): void;
  106757. setTimeStep(timeStep: number): void;
  106758. getTimeStep(): number;
  106759. executeStep(delta: number): void;
  106760. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106761. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106763. private _processChildMeshes;
  106764. removePhysicsBody(impostor: PhysicsImpostor): void;
  106765. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106766. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106767. private _addMaterial;
  106768. private _checkWithEpsilon;
  106769. private _createShape;
  106770. private _createHeightmap;
  106771. private _minus90X;
  106772. private _plus90X;
  106773. private _tmpPosition;
  106774. private _tmpDeltaPosition;
  106775. private _tmpUnityRotation;
  106776. private _updatePhysicsBodyTransformation;
  106777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106779. isSupported(): boolean;
  106780. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106781. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106782. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106783. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106784. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106785. getBodyMass(impostor: PhysicsImpostor): number;
  106786. getBodyFriction(impostor: PhysicsImpostor): number;
  106787. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106788. getBodyRestitution(impostor: PhysicsImpostor): number;
  106789. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106790. sleepBody(impostor: PhysicsImpostor): void;
  106791. wakeUpBody(impostor: PhysicsImpostor): void;
  106792. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  106793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106794. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106796. getRadius(impostor: PhysicsImpostor): number;
  106797. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106798. dispose(): void;
  106799. private _extendNamespace;
  106800. /**
  106801. * Does a raycast in the physics world
  106802. * @param from when should the ray start?
  106803. * @param to when should the ray end?
  106804. * @returns PhysicsRaycastResult
  106805. */
  106806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106807. }
  106808. }
  106809. declare module BABYLON {
  106810. /** @hidden */
  106811. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  106812. world: any;
  106813. name: string;
  106814. BJSOIMO: any;
  106815. private _raycastResult;
  106816. constructor(iterations?: number, oimoInjection?: any);
  106817. setGravity(gravity: Vector3): void;
  106818. setTimeStep(timeStep: number): void;
  106819. getTimeStep(): number;
  106820. private _tmpImpostorsArray;
  106821. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106822. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106824. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106825. private _tmpPositionVector;
  106826. removePhysicsBody(impostor: PhysicsImpostor): void;
  106827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106828. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106829. isSupported(): boolean;
  106830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106831. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106832. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106833. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106834. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106835. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106836. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106837. getBodyMass(impostor: PhysicsImpostor): number;
  106838. getBodyFriction(impostor: PhysicsImpostor): number;
  106839. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106840. getBodyRestitution(impostor: PhysicsImpostor): number;
  106841. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106842. sleepBody(impostor: PhysicsImpostor): void;
  106843. wakeUpBody(impostor: PhysicsImpostor): void;
  106844. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106845. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  106846. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106847. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106848. getRadius(impostor: PhysicsImpostor): number;
  106849. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106850. dispose(): void;
  106851. /**
  106852. * Does a raycast in the physics world
  106853. * @param from when should the ray start?
  106854. * @param to when should the ray end?
  106855. * @returns PhysicsRaycastResult
  106856. */
  106857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106858. }
  106859. }
  106860. declare module BABYLON {
  106861. /**
  106862. * Class containing static functions to help procedurally build meshes
  106863. */
  106864. export class RibbonBuilder {
  106865. /**
  106866. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106867. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106868. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106869. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106870. * * 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
  106871. * * 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
  106872. * * 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
  106873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106876. * * 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
  106877. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106878. * * 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
  106879. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106881. * @param name defines the name of the mesh
  106882. * @param options defines the options used to create the mesh
  106883. * @param scene defines the hosting scene
  106884. * @returns the ribbon mesh
  106885. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106887. */
  106888. static CreateRibbon(name: string, options: {
  106889. pathArray: Vector3[][];
  106890. closeArray?: boolean;
  106891. closePath?: boolean;
  106892. offset?: number;
  106893. updatable?: boolean;
  106894. sideOrientation?: number;
  106895. frontUVs?: Vector4;
  106896. backUVs?: Vector4;
  106897. instance?: Mesh;
  106898. invertUV?: boolean;
  106899. uvs?: Vector2[];
  106900. colors?: Color4[];
  106901. }, scene?: Nullable<Scene>): Mesh;
  106902. }
  106903. }
  106904. declare module BABYLON {
  106905. /**
  106906. * Class containing static functions to help procedurally build meshes
  106907. */
  106908. export class ShapeBuilder {
  106909. /**
  106910. * 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.
  106911. * * 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.
  106912. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106913. * * 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.
  106914. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106915. * * 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
  106916. * * 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
  106917. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106922. * @param name defines the name of the mesh
  106923. * @param options defines the options used to create the mesh
  106924. * @param scene defines the hosting scene
  106925. * @returns the extruded shape mesh
  106926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106928. */
  106929. static ExtrudeShape(name: string, options: {
  106930. shape: Vector3[];
  106931. path: Vector3[];
  106932. scale?: number;
  106933. rotation?: number;
  106934. cap?: number;
  106935. updatable?: boolean;
  106936. sideOrientation?: number;
  106937. frontUVs?: Vector4;
  106938. backUVs?: Vector4;
  106939. instance?: Mesh;
  106940. invertUV?: boolean;
  106941. }, scene?: Nullable<Scene>): Mesh;
  106942. /**
  106943. * Creates an custom extruded shape mesh.
  106944. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106945. * * 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.
  106946. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106947. * * 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
  106948. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106949. * * 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
  106950. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106951. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106952. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106953. * * 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
  106954. * * 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
  106955. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106958. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106960. * @param name defines the name of the mesh
  106961. * @param options defines the options used to create the mesh
  106962. * @param scene defines the hosting scene
  106963. * @returns the custom extruded shape mesh
  106964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106967. */
  106968. static ExtrudeShapeCustom(name: string, options: {
  106969. shape: Vector3[];
  106970. path: Vector3[];
  106971. scaleFunction?: any;
  106972. rotationFunction?: any;
  106973. ribbonCloseArray?: boolean;
  106974. ribbonClosePath?: boolean;
  106975. cap?: number;
  106976. updatable?: boolean;
  106977. sideOrientation?: number;
  106978. frontUVs?: Vector4;
  106979. backUVs?: Vector4;
  106980. instance?: Mesh;
  106981. invertUV?: boolean;
  106982. }, scene: Scene): Mesh;
  106983. private static _ExtrudeShapeGeneric;
  106984. }
  106985. }
  106986. declare module BABYLON {
  106987. /**
  106988. * AmmoJS Physics plugin
  106989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106990. * @see https://github.com/kripken/ammo.js/
  106991. */
  106992. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106993. private _useDeltaForWorldStep;
  106994. /**
  106995. * Reference to the Ammo library
  106996. */
  106997. bjsAMMO: any;
  106998. /**
  106999. * Created ammoJS world which physics bodies are added to
  107000. */
  107001. world: any;
  107002. /**
  107003. * Name of the plugin
  107004. */
  107005. name: string;
  107006. private _timeStep;
  107007. private _fixedTimeStep;
  107008. private _maxSteps;
  107009. private _tmpQuaternion;
  107010. private _tmpAmmoTransform;
  107011. private _tmpAmmoQuaternion;
  107012. private _tmpAmmoConcreteContactResultCallback;
  107013. private _collisionConfiguration;
  107014. private _dispatcher;
  107015. private _overlappingPairCache;
  107016. private _solver;
  107017. private _softBodySolver;
  107018. private _tmpAmmoVectorA;
  107019. private _tmpAmmoVectorB;
  107020. private _tmpAmmoVectorC;
  107021. private _tmpAmmoVectorD;
  107022. private _tmpContactCallbackResult;
  107023. private _tmpAmmoVectorRCA;
  107024. private _tmpAmmoVectorRCB;
  107025. private _raycastResult;
  107026. private static readonly DISABLE_COLLISION_FLAG;
  107027. private static readonly KINEMATIC_FLAG;
  107028. private static readonly DISABLE_DEACTIVATION_FLAG;
  107029. /**
  107030. * Initializes the ammoJS plugin
  107031. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107032. * @param ammoInjection can be used to inject your own ammo reference
  107033. */
  107034. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107035. /**
  107036. * Sets the gravity of the physics world (m/(s^2))
  107037. * @param gravity Gravity to set
  107038. */
  107039. setGravity(gravity: Vector3): void;
  107040. /**
  107041. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107042. * @param timeStep timestep to use in seconds
  107043. */
  107044. setTimeStep(timeStep: number): void;
  107045. /**
  107046. * 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)
  107047. * @param fixedTimeStep fixedTimeStep to use in seconds
  107048. */
  107049. setFixedTimeStep(fixedTimeStep: number): void;
  107050. /**
  107051. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107052. * @param maxSteps the maximum number of steps by the physics engine per frame
  107053. */
  107054. setMaxSteps(maxSteps: number): void;
  107055. /**
  107056. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107057. * @returns the current timestep in seconds
  107058. */
  107059. getTimeStep(): number;
  107060. private _isImpostorInContact;
  107061. private _isImpostorPairInContact;
  107062. private _stepSimulation;
  107063. /**
  107064. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107065. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107066. * After the step the babylon meshes are set to the position of the physics imposters
  107067. * @param delta amount of time to step forward
  107068. * @param impostors array of imposters to update before/after the step
  107069. */
  107070. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107071. /**
  107072. * Update babylon mesh to match physics world object
  107073. * @param impostor imposter to match
  107074. */
  107075. private _afterSoftStep;
  107076. /**
  107077. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107078. * @param impostor imposter to match
  107079. */
  107080. private _ropeStep;
  107081. /**
  107082. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107083. * @param impostor imposter to match
  107084. */
  107085. private _softbodyOrClothStep;
  107086. private _tmpVector;
  107087. private _tmpMatrix;
  107088. /**
  107089. * Applies an impulse on the imposter
  107090. * @param impostor imposter to apply impulse to
  107091. * @param force amount of force to be applied to the imposter
  107092. * @param contactPoint the location to apply the impulse on the imposter
  107093. */
  107094. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107095. /**
  107096. * Applies a force on the imposter
  107097. * @param impostor imposter to apply force
  107098. * @param force amount of force to be applied to the imposter
  107099. * @param contactPoint the location to apply the force on the imposter
  107100. */
  107101. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107102. /**
  107103. * Creates a physics body using the plugin
  107104. * @param impostor the imposter to create the physics body on
  107105. */
  107106. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107107. /**
  107108. * Removes the physics body from the imposter and disposes of the body's memory
  107109. * @param impostor imposter to remove the physics body from
  107110. */
  107111. removePhysicsBody(impostor: PhysicsImpostor): void;
  107112. /**
  107113. * Generates a joint
  107114. * @param impostorJoint the imposter joint to create the joint with
  107115. */
  107116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107117. /**
  107118. * Removes a joint
  107119. * @param impostorJoint the imposter joint to remove the joint from
  107120. */
  107121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107122. private _addMeshVerts;
  107123. /**
  107124. * Initialise the soft body vertices to match its object's (mesh) vertices
  107125. * Softbody vertices (nodes) are in world space and to match this
  107126. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107127. * @param impostor to create the softbody for
  107128. */
  107129. private _softVertexData;
  107130. /**
  107131. * Create an impostor's soft body
  107132. * @param impostor to create the softbody for
  107133. */
  107134. private _createSoftbody;
  107135. /**
  107136. * Create cloth for an impostor
  107137. * @param impostor to create the softbody for
  107138. */
  107139. private _createCloth;
  107140. /**
  107141. * Create rope for an impostor
  107142. * @param impostor to create the softbody for
  107143. */
  107144. private _createRope;
  107145. private _addHullVerts;
  107146. private _createShape;
  107147. /**
  107148. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107149. * @param impostor imposter containing the physics body and babylon object
  107150. */
  107151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107152. /**
  107153. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107154. * @param impostor imposter containing the physics body and babylon object
  107155. * @param newPosition new position
  107156. * @param newRotation new rotation
  107157. */
  107158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107159. /**
  107160. * If this plugin is supported
  107161. * @returns true if its supported
  107162. */
  107163. isSupported(): boolean;
  107164. /**
  107165. * Sets the linear velocity of the physics body
  107166. * @param impostor imposter to set the velocity on
  107167. * @param velocity velocity to set
  107168. */
  107169. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107170. /**
  107171. * Sets the angular velocity of the physics body
  107172. * @param impostor imposter to set the velocity on
  107173. * @param velocity velocity to set
  107174. */
  107175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107176. /**
  107177. * gets the linear velocity
  107178. * @param impostor imposter to get linear velocity from
  107179. * @returns linear velocity
  107180. */
  107181. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107182. /**
  107183. * gets the angular velocity
  107184. * @param impostor imposter to get angular velocity from
  107185. * @returns angular velocity
  107186. */
  107187. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107188. /**
  107189. * Sets the mass of physics body
  107190. * @param impostor imposter to set the mass on
  107191. * @param mass mass to set
  107192. */
  107193. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107194. /**
  107195. * Gets the mass of the physics body
  107196. * @param impostor imposter to get the mass from
  107197. * @returns mass
  107198. */
  107199. getBodyMass(impostor: PhysicsImpostor): number;
  107200. /**
  107201. * Gets friction of the impostor
  107202. * @param impostor impostor to get friction from
  107203. * @returns friction value
  107204. */
  107205. getBodyFriction(impostor: PhysicsImpostor): number;
  107206. /**
  107207. * Sets friction of the impostor
  107208. * @param impostor impostor to set friction on
  107209. * @param friction friction value
  107210. */
  107211. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107212. /**
  107213. * Gets restitution of the impostor
  107214. * @param impostor impostor to get restitution from
  107215. * @returns restitution value
  107216. */
  107217. getBodyRestitution(impostor: PhysicsImpostor): number;
  107218. /**
  107219. * Sets resitution of the impostor
  107220. * @param impostor impostor to set resitution on
  107221. * @param restitution resitution value
  107222. */
  107223. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107224. /**
  107225. * Gets pressure inside the impostor
  107226. * @param impostor impostor to get pressure from
  107227. * @returns pressure value
  107228. */
  107229. getBodyPressure(impostor: PhysicsImpostor): number;
  107230. /**
  107231. * Sets pressure inside a soft body impostor
  107232. * Cloth and rope must remain 0 pressure
  107233. * @param impostor impostor to set pressure on
  107234. * @param pressure pressure value
  107235. */
  107236. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107237. /**
  107238. * Gets stiffness of the impostor
  107239. * @param impostor impostor to get stiffness from
  107240. * @returns pressure value
  107241. */
  107242. getBodyStiffness(impostor: PhysicsImpostor): number;
  107243. /**
  107244. * Sets stiffness of the impostor
  107245. * @param impostor impostor to set stiffness on
  107246. * @param stiffness stiffness value from 0 to 1
  107247. */
  107248. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107249. /**
  107250. * Gets velocityIterations of the impostor
  107251. * @param impostor impostor to get velocity iterations from
  107252. * @returns velocityIterations value
  107253. */
  107254. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107255. /**
  107256. * Sets velocityIterations of the impostor
  107257. * @param impostor impostor to set velocity iterations on
  107258. * @param velocityIterations velocityIterations value
  107259. */
  107260. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107261. /**
  107262. * Gets positionIterations of the impostor
  107263. * @param impostor impostor to get position iterations from
  107264. * @returns positionIterations value
  107265. */
  107266. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107267. /**
  107268. * Sets positionIterations of the impostor
  107269. * @param impostor impostor to set position on
  107270. * @param positionIterations positionIterations value
  107271. */
  107272. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107273. /**
  107274. * Append an anchor to a cloth object
  107275. * @param impostor is the cloth impostor to add anchor to
  107276. * @param otherImpostor is the rigid impostor to anchor to
  107277. * @param width ratio across width from 0 to 1
  107278. * @param height ratio up height from 0 to 1
  107279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107280. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107281. */
  107282. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107283. /**
  107284. * Append an hook to a rope object
  107285. * @param impostor is the rope impostor to add hook to
  107286. * @param otherImpostor is the rigid impostor to hook to
  107287. * @param length ratio along the rope from 0 to 1
  107288. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107290. */
  107291. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107292. /**
  107293. * Sleeps the physics body and stops it from being active
  107294. * @param impostor impostor to sleep
  107295. */
  107296. sleepBody(impostor: PhysicsImpostor): void;
  107297. /**
  107298. * Activates the physics body
  107299. * @param impostor impostor to activate
  107300. */
  107301. wakeUpBody(impostor: PhysicsImpostor): void;
  107302. /**
  107303. * Updates the distance parameters of the joint
  107304. * @param joint joint to update
  107305. * @param maxDistance maximum distance of the joint
  107306. * @param minDistance minimum distance of the joint
  107307. */
  107308. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107309. /**
  107310. * Sets a motor on the joint
  107311. * @param joint joint to set motor on
  107312. * @param speed speed of the motor
  107313. * @param maxForce maximum force of the motor
  107314. * @param motorIndex index of the motor
  107315. */
  107316. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107317. /**
  107318. * Sets the motors limit
  107319. * @param joint joint to set limit on
  107320. * @param upperLimit upper limit
  107321. * @param lowerLimit lower limit
  107322. */
  107323. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107324. /**
  107325. * Syncs the position and rotation of a mesh with the impostor
  107326. * @param mesh mesh to sync
  107327. * @param impostor impostor to update the mesh with
  107328. */
  107329. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107330. /**
  107331. * Gets the radius of the impostor
  107332. * @param impostor impostor to get radius from
  107333. * @returns the radius
  107334. */
  107335. getRadius(impostor: PhysicsImpostor): number;
  107336. /**
  107337. * Gets the box size of the impostor
  107338. * @param impostor impostor to get box size from
  107339. * @param result the resulting box size
  107340. */
  107341. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107342. /**
  107343. * Disposes of the impostor
  107344. */
  107345. dispose(): void;
  107346. /**
  107347. * Does a raycast in the physics world
  107348. * @param from when should the ray start?
  107349. * @param to when should the ray end?
  107350. * @returns PhysicsRaycastResult
  107351. */
  107352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107353. }
  107354. }
  107355. declare module BABYLON {
  107356. interface AbstractScene {
  107357. /**
  107358. * The list of reflection probes added to the scene
  107359. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107360. */
  107361. reflectionProbes: Array<ReflectionProbe>;
  107362. /**
  107363. * Removes the given reflection probe from this scene.
  107364. * @param toRemove The reflection probe to remove
  107365. * @returns The index of the removed reflection probe
  107366. */
  107367. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107368. /**
  107369. * Adds the given reflection probe to this scene.
  107370. * @param newReflectionProbe The reflection probe to add
  107371. */
  107372. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107373. }
  107374. /**
  107375. * Class used to generate realtime reflection / refraction cube textures
  107376. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107377. */
  107378. export class ReflectionProbe {
  107379. /** defines the name of the probe */
  107380. name: string;
  107381. private _scene;
  107382. private _renderTargetTexture;
  107383. private _projectionMatrix;
  107384. private _viewMatrix;
  107385. private _target;
  107386. private _add;
  107387. private _attachedMesh;
  107388. private _invertYAxis;
  107389. /** Gets or sets probe position (center of the cube map) */
  107390. position: Vector3;
  107391. /**
  107392. * Creates a new reflection probe
  107393. * @param name defines the name of the probe
  107394. * @param size defines the texture resolution (for each face)
  107395. * @param scene defines the hosting scene
  107396. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107397. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107398. */
  107399. constructor(
  107400. /** defines the name of the probe */
  107401. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107402. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107403. samples: number;
  107404. /** Gets or sets the refresh rate to use (on every frame by default) */
  107405. refreshRate: number;
  107406. /**
  107407. * Gets the hosting scene
  107408. * @returns a Scene
  107409. */
  107410. getScene(): Scene;
  107411. /** Gets the internal CubeTexture used to render to */
  107412. readonly cubeTexture: RenderTargetTexture;
  107413. /** Gets the list of meshes to render */
  107414. readonly renderList: Nullable<AbstractMesh[]>;
  107415. /**
  107416. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107417. * @param mesh defines the mesh to attach to
  107418. */
  107419. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107420. /**
  107421. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107422. * @param renderingGroupId The rendering group id corresponding to its index
  107423. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107424. */
  107425. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107426. /**
  107427. * Clean all associated resources
  107428. */
  107429. dispose(): void;
  107430. /**
  107431. * Converts the reflection probe information to a readable string for debug purpose.
  107432. * @param fullDetails Supports for multiple levels of logging within scene loading
  107433. * @returns the human readable reflection probe info
  107434. */
  107435. toString(fullDetails?: boolean): string;
  107436. /**
  107437. * Get the class name of the relfection probe.
  107438. * @returns "ReflectionProbe"
  107439. */
  107440. getClassName(): string;
  107441. /**
  107442. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107443. * @returns The JSON representation of the texture
  107444. */
  107445. serialize(): any;
  107446. /**
  107447. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107448. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107449. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107450. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107451. * @returns The parsed reflection probe if successful
  107452. */
  107453. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107454. }
  107455. }
  107456. declare module BABYLON {
  107457. /** @hidden */
  107458. export var _BabylonLoaderRegistered: boolean;
  107459. }
  107460. declare module BABYLON {
  107461. /**
  107462. * The Physically based simple base material of BJS.
  107463. *
  107464. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107465. * It is used as the base class for both the specGloss and metalRough conventions.
  107466. */
  107467. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107468. /**
  107469. * Number of Simultaneous lights allowed on the material.
  107470. */
  107471. maxSimultaneousLights: number;
  107472. /**
  107473. * If sets to true, disables all the lights affecting the material.
  107474. */
  107475. disableLighting: boolean;
  107476. /**
  107477. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107478. */
  107479. environmentTexture: BaseTexture;
  107480. /**
  107481. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107482. */
  107483. invertNormalMapX: boolean;
  107484. /**
  107485. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107486. */
  107487. invertNormalMapY: boolean;
  107488. /**
  107489. * Normal map used in the model.
  107490. */
  107491. normalTexture: BaseTexture;
  107492. /**
  107493. * Emissivie color used to self-illuminate the model.
  107494. */
  107495. emissiveColor: Color3;
  107496. /**
  107497. * Emissivie texture used to self-illuminate the model.
  107498. */
  107499. emissiveTexture: BaseTexture;
  107500. /**
  107501. * Occlusion Channel Strenght.
  107502. */
  107503. occlusionStrength: number;
  107504. /**
  107505. * Occlusion Texture of the material (adding extra occlusion effects).
  107506. */
  107507. occlusionTexture: BaseTexture;
  107508. /**
  107509. * Defines the alpha limits in alpha test mode.
  107510. */
  107511. alphaCutOff: number;
  107512. /**
  107513. * Gets the current double sided mode.
  107514. */
  107515. /**
  107516. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107517. */
  107518. doubleSided: boolean;
  107519. /**
  107520. * Stores the pre-calculated light information of a mesh in a texture.
  107521. */
  107522. lightmapTexture: BaseTexture;
  107523. /**
  107524. * If true, the light map contains occlusion information instead of lighting info.
  107525. */
  107526. useLightmapAsShadowmap: boolean;
  107527. /**
  107528. * Instantiates a new PBRMaterial instance.
  107529. *
  107530. * @param name The material name
  107531. * @param scene The scene the material will be use in.
  107532. */
  107533. constructor(name: string, scene: Scene);
  107534. getClassName(): string;
  107535. }
  107536. }
  107537. declare module BABYLON {
  107538. /**
  107539. * The PBR material of BJS following the metal roughness convention.
  107540. *
  107541. * This fits to the PBR convention in the GLTF definition:
  107542. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  107543. */
  107544. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  107545. /**
  107546. * The base color has two different interpretations depending on the value of metalness.
  107547. * When the material is a metal, the base color is the specific measured reflectance value
  107548. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  107549. * of the material.
  107550. */
  107551. baseColor: Color3;
  107552. /**
  107553. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  107554. * well as opacity information in the alpha channel.
  107555. */
  107556. baseTexture: BaseTexture;
  107557. /**
  107558. * Specifies the metallic scalar value of the material.
  107559. * Can also be used to scale the metalness values of the metallic texture.
  107560. */
  107561. metallic: number;
  107562. /**
  107563. * Specifies the roughness scalar value of the material.
  107564. * Can also be used to scale the roughness values of the metallic texture.
  107565. */
  107566. roughness: number;
  107567. /**
  107568. * Texture containing both the metallic value in the B channel and the
  107569. * roughness value in the G channel to keep better precision.
  107570. */
  107571. metallicRoughnessTexture: BaseTexture;
  107572. /**
  107573. * Instantiates a new PBRMetalRoughnessMaterial instance.
  107574. *
  107575. * @param name The material name
  107576. * @param scene The scene the material will be use in.
  107577. */
  107578. constructor(name: string, scene: Scene);
  107579. /**
  107580. * Return the currrent class name of the material.
  107581. */
  107582. getClassName(): string;
  107583. /**
  107584. * Makes a duplicate of the current material.
  107585. * @param name - name to use for the new material.
  107586. */
  107587. clone(name: string): PBRMetallicRoughnessMaterial;
  107588. /**
  107589. * Serialize the material to a parsable JSON object.
  107590. */
  107591. serialize(): any;
  107592. /**
  107593. * Parses a JSON object correponding to the serialize function.
  107594. */
  107595. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  107596. }
  107597. }
  107598. declare module BABYLON {
  107599. /**
  107600. * The PBR material of BJS following the specular glossiness convention.
  107601. *
  107602. * This fits to the PBR convention in the GLTF definition:
  107603. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  107604. */
  107605. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  107606. /**
  107607. * Specifies the diffuse color of the material.
  107608. */
  107609. diffuseColor: Color3;
  107610. /**
  107611. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  107612. * channel.
  107613. */
  107614. diffuseTexture: BaseTexture;
  107615. /**
  107616. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  107617. */
  107618. specularColor: Color3;
  107619. /**
  107620. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  107621. */
  107622. glossiness: number;
  107623. /**
  107624. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  107625. */
  107626. specularGlossinessTexture: BaseTexture;
  107627. /**
  107628. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  107629. *
  107630. * @param name The material name
  107631. * @param scene The scene the material will be use in.
  107632. */
  107633. constructor(name: string, scene: Scene);
  107634. /**
  107635. * Return the currrent class name of the material.
  107636. */
  107637. getClassName(): string;
  107638. /**
  107639. * Makes a duplicate of the current material.
  107640. * @param name - name to use for the new material.
  107641. */
  107642. clone(name: string): PBRSpecularGlossinessMaterial;
  107643. /**
  107644. * Serialize the material to a parsable JSON object.
  107645. */
  107646. serialize(): any;
  107647. /**
  107648. * Parses a JSON object correponding to the serialize function.
  107649. */
  107650. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  107651. }
  107652. }
  107653. declare module BABYLON {
  107654. /**
  107655. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  107656. * It can help converting any input color in a desired output one. This can then be used to create effects
  107657. * from sepia, black and white to sixties or futuristic rendering...
  107658. *
  107659. * The only supported format is currently 3dl.
  107660. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  107661. */
  107662. export class ColorGradingTexture extends BaseTexture {
  107663. /**
  107664. * The current texture matrix. (will always be identity in color grading texture)
  107665. */
  107666. private _textureMatrix;
  107667. /**
  107668. * The texture URL.
  107669. */
  107670. url: string;
  107671. /**
  107672. * Empty line regex stored for GC.
  107673. */
  107674. private static _noneEmptyLineRegex;
  107675. private _engine;
  107676. /**
  107677. * Instantiates a ColorGradingTexture from the following parameters.
  107678. *
  107679. * @param url The location of the color gradind data (currently only supporting 3dl)
  107680. * @param scene The scene the texture will be used in
  107681. */
  107682. constructor(url: string, scene: Scene);
  107683. /**
  107684. * Returns the texture matrix used in most of the material.
  107685. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  107686. */
  107687. getTextureMatrix(): Matrix;
  107688. /**
  107689. * Occurs when the file being loaded is a .3dl LUT file.
  107690. */
  107691. private load3dlTexture;
  107692. /**
  107693. * Starts the loading process of the texture.
  107694. */
  107695. private loadTexture;
  107696. /**
  107697. * Clones the color gradind texture.
  107698. */
  107699. clone(): ColorGradingTexture;
  107700. /**
  107701. * Called during delayed load for textures.
  107702. */
  107703. delayLoad(): void;
  107704. /**
  107705. * Parses a color grading texture serialized by Babylon.
  107706. * @param parsedTexture The texture information being parsedTexture
  107707. * @param scene The scene to load the texture in
  107708. * @param rootUrl The root url of the data assets to load
  107709. * @return A color gradind texture
  107710. */
  107711. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  107712. /**
  107713. * Serializes the LUT texture to json format.
  107714. */
  107715. serialize(): any;
  107716. }
  107717. }
  107718. declare module BABYLON {
  107719. /**
  107720. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  107721. */
  107722. export class EquiRectangularCubeTexture extends BaseTexture {
  107723. /** The six faces of the cube. */
  107724. private static _FacesMapping;
  107725. private _noMipmap;
  107726. private _onLoad;
  107727. private _onError;
  107728. /** The size of the cubemap. */
  107729. private _size;
  107730. /** The buffer of the image. */
  107731. private _buffer;
  107732. /** The width of the input image. */
  107733. private _width;
  107734. /** The height of the input image. */
  107735. private _height;
  107736. /** The URL to the image. */
  107737. url: string;
  107738. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  107739. coordinatesMode: number;
  107740. /**
  107741. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  107742. * @param url The location of the image
  107743. * @param scene The scene the texture will be used in
  107744. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107745. * @param noMipmap Forces to not generate the mipmap if true
  107746. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  107747. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  107748. * @param onLoad — defines a callback called when texture is loaded
  107749. * @param onError — defines a callback called if there is an error
  107750. */
  107751. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  107752. /**
  107753. * Load the image data, by putting the image on a canvas and extracting its buffer.
  107754. */
  107755. private loadImage;
  107756. /**
  107757. * Convert the image buffer into a cubemap and create a CubeTexture.
  107758. */
  107759. private loadTexture;
  107760. /**
  107761. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  107762. * @param buffer The ArrayBuffer that should be converted.
  107763. * @returns The buffer as Float32Array.
  107764. */
  107765. private getFloat32ArrayFromArrayBuffer;
  107766. /**
  107767. * Get the current class name of the texture useful for serialization or dynamic coding.
  107768. * @returns "EquiRectangularCubeTexture"
  107769. */
  107770. getClassName(): string;
  107771. /**
  107772. * Create a clone of the current EquiRectangularCubeTexture and return it.
  107773. * @returns A clone of the current EquiRectangularCubeTexture.
  107774. */
  107775. clone(): EquiRectangularCubeTexture;
  107776. }
  107777. }
  107778. declare module BABYLON {
  107779. /**
  107780. * Based on jsTGALoader - Javascript loader for TGA file
  107781. * By Vincent Thibault
  107782. * @see http://blog.robrowser.com/javascript-tga-loader.html
  107783. */
  107784. export class TGATools {
  107785. private static _TYPE_INDEXED;
  107786. private static _TYPE_RGB;
  107787. private static _TYPE_GREY;
  107788. private static _TYPE_RLE_INDEXED;
  107789. private static _TYPE_RLE_RGB;
  107790. private static _TYPE_RLE_GREY;
  107791. private static _ORIGIN_MASK;
  107792. private static _ORIGIN_SHIFT;
  107793. private static _ORIGIN_BL;
  107794. private static _ORIGIN_BR;
  107795. private static _ORIGIN_UL;
  107796. private static _ORIGIN_UR;
  107797. /**
  107798. * Gets the header of a TGA file
  107799. * @param data defines the TGA data
  107800. * @returns the header
  107801. */
  107802. static GetTGAHeader(data: Uint8Array): any;
  107803. /**
  107804. * Uploads TGA content to a Babylon Texture
  107805. * @hidden
  107806. */
  107807. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  107808. /** @hidden */
  107809. 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;
  107810. /** @hidden */
  107811. 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;
  107812. /** @hidden */
  107813. 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;
  107814. /** @hidden */
  107815. 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;
  107816. /** @hidden */
  107817. 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;
  107818. /** @hidden */
  107819. 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;
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /**
  107824. * Implementation of the TGA Texture Loader.
  107825. * @hidden
  107826. */
  107827. export class _TGATextureLoader implements IInternalTextureLoader {
  107828. /**
  107829. * Defines wether the loader supports cascade loading the different faces.
  107830. */
  107831. readonly supportCascades: boolean;
  107832. /**
  107833. * This returns if the loader support the current file information.
  107834. * @param extension defines the file extension of the file being loaded
  107835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107836. * @param fallback defines the fallback internal texture if any
  107837. * @param isBase64 defines whether the texture is encoded as a base64
  107838. * @param isBuffer defines whether the texture data are stored as a buffer
  107839. * @returns true if the loader can load the specified file
  107840. */
  107841. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  107842. /**
  107843. * Transform the url before loading if required.
  107844. * @param rootUrl the url of the texture
  107845. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107846. * @returns the transformed texture
  107847. */
  107848. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  107849. /**
  107850. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  107851. * @param rootUrl the url of the texture
  107852. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107853. * @returns the fallback texture
  107854. */
  107855. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  107856. /**
  107857. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  107858. * @param data contains the texture data
  107859. * @param texture defines the BabylonJS internal texture
  107860. * @param createPolynomials will be true if polynomials have been requested
  107861. * @param onLoad defines the callback to trigger once the texture is ready
  107862. * @param onError defines the callback to trigger in case of error
  107863. */
  107864. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  107865. /**
  107866. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  107867. * @param data contains the texture data
  107868. * @param texture defines the BabylonJS internal texture
  107869. * @param callback defines the method to call once ready to upload
  107870. */
  107871. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  107872. }
  107873. }
  107874. declare module BABYLON {
  107875. /**
  107876. * 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.
  107877. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107878. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107879. */
  107880. export class CustomProceduralTexture extends ProceduralTexture {
  107881. private _animate;
  107882. private _time;
  107883. private _config;
  107884. private _texturePath;
  107885. /**
  107886. * Instantiates a new Custom Procedural Texture.
  107887. * 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.
  107888. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107889. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107890. * @param name Define the name of the texture
  107891. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  107892. * @param size Define the size of the texture to create
  107893. * @param scene Define the scene the texture belongs to
  107894. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  107895. * @param generateMipMaps Define if the texture should creates mip maps or not
  107896. */
  107897. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107898. private _loadJson;
  107899. /**
  107900. * Is the texture ready to be used ? (rendered at least once)
  107901. * @returns true if ready, otherwise, false.
  107902. */
  107903. isReady(): boolean;
  107904. /**
  107905. * Render the texture to its associated render target.
  107906. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  107907. */
  107908. render(useCameraPostProcess?: boolean): void;
  107909. /**
  107910. * Update the list of dependant textures samplers in the shader.
  107911. */
  107912. updateTextures(): void;
  107913. /**
  107914. * Update the uniform values of the procedural texture in the shader.
  107915. */
  107916. updateShaderUniforms(): void;
  107917. /**
  107918. * Define if the texture animates or not.
  107919. */
  107920. animate: boolean;
  107921. }
  107922. }
  107923. declare module BABYLON {
  107924. /** @hidden */
  107925. export var noisePixelShader: {
  107926. name: string;
  107927. shader: string;
  107928. };
  107929. }
  107930. declare module BABYLON {
  107931. /**
  107932. * Class used to generate noise procedural textures
  107933. */
  107934. export class NoiseProceduralTexture extends ProceduralTexture {
  107935. private _time;
  107936. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  107937. brightness: number;
  107938. /** Defines the number of octaves to process */
  107939. octaves: number;
  107940. /** Defines the level of persistence (0.8 by default) */
  107941. persistence: number;
  107942. /** Gets or sets animation speed factor (default is 1) */
  107943. animationSpeedFactor: number;
  107944. /**
  107945. * Creates a new NoiseProceduralTexture
  107946. * @param name defines the name fo the texture
  107947. * @param size defines the size of the texture (default is 256)
  107948. * @param scene defines the hosting scene
  107949. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  107950. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  107951. */
  107952. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107953. private _updateShaderUniforms;
  107954. protected _getDefines(): string;
  107955. /** Generate the current state of the procedural texture */
  107956. render(useCameraPostProcess?: boolean): void;
  107957. /**
  107958. * Serializes this noise procedural texture
  107959. * @returns a serialized noise procedural texture object
  107960. */
  107961. serialize(): any;
  107962. /**
  107963. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  107964. * @param parsedTexture defines parsed texture data
  107965. * @param scene defines the current scene
  107966. * @param rootUrl defines the root URL containing noise procedural texture information
  107967. * @returns a parsed NoiseProceduralTexture
  107968. */
  107969. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  107970. }
  107971. }
  107972. declare module BABYLON {
  107973. /**
  107974. * Raw cube texture where the raw buffers are passed in
  107975. */
  107976. export class RawCubeTexture extends CubeTexture {
  107977. /**
  107978. * Creates a cube texture where the raw buffers are passed in.
  107979. * @param scene defines the scene the texture is attached to
  107980. * @param data defines the array of data to use to create each face
  107981. * @param size defines the size of the textures
  107982. * @param format defines the format of the data
  107983. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  107984. * @param generateMipMaps defines if the engine should generate the mip levels
  107985. * @param invertY defines if data must be stored with Y axis inverted
  107986. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  107987. * @param compression defines the compression used (null by default)
  107988. */
  107989. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  107990. /**
  107991. * Updates the raw cube texture.
  107992. * @param data defines the data to store
  107993. * @param format defines the data format
  107994. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107995. * @param invertY defines if data must be stored with Y axis inverted
  107996. * @param compression defines the compression used (null by default)
  107997. * @param level defines which level of the texture to update
  107998. */
  107999. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108000. /**
  108001. * Updates a raw cube texture with RGBD encoded data.
  108002. * @param data defines the array of data [mipmap][face] to use to create each face
  108003. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108004. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108005. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108006. * @returns a promsie that resolves when the operation is complete
  108007. */
  108008. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108009. /**
  108010. * Clones the raw cube texture.
  108011. * @return a new cube texture
  108012. */
  108013. clone(): CubeTexture;
  108014. /** @hidden */
  108015. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108016. }
  108017. }
  108018. declare module BABYLON {
  108019. /**
  108020. * Class used to store 3D textures containing user data
  108021. */
  108022. export class RawTexture3D extends Texture {
  108023. /** Gets or sets the texture format to use */
  108024. format: number;
  108025. private _engine;
  108026. /**
  108027. * Create a new RawTexture3D
  108028. * @param data defines the data of the texture
  108029. * @param width defines the width of the texture
  108030. * @param height defines the height of the texture
  108031. * @param depth defines the depth of the texture
  108032. * @param format defines the texture format to use
  108033. * @param scene defines the hosting scene
  108034. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108035. * @param invertY defines if texture must be stored with Y axis inverted
  108036. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108037. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108038. */
  108039. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108040. /** Gets or sets the texture format to use */
  108041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108042. /**
  108043. * Update the texture with new data
  108044. * @param data defines the data to store in the texture
  108045. */
  108046. update(data: ArrayBufferView): void;
  108047. }
  108048. }
  108049. declare module BABYLON {
  108050. /**
  108051. * Creates a refraction texture used by refraction channel of the standard material.
  108052. * It is like a mirror but to see through a material.
  108053. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108054. */
  108055. export class RefractionTexture extends RenderTargetTexture {
  108056. /**
  108057. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108058. * 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.
  108059. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108060. */
  108061. refractionPlane: Plane;
  108062. /**
  108063. * Define how deep under the surface we should see.
  108064. */
  108065. depth: number;
  108066. /**
  108067. * Creates a refraction texture used by refraction channel of the standard material.
  108068. * It is like a mirror but to see through a material.
  108069. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108070. * @param name Define the texture name
  108071. * @param size Define the size of the underlying texture
  108072. * @param scene Define the scene the refraction belongs to
  108073. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108074. */
  108075. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108076. /**
  108077. * Clone the refraction texture.
  108078. * @returns the cloned texture
  108079. */
  108080. clone(): RefractionTexture;
  108081. /**
  108082. * Serialize the texture to a JSON representation you could use in Parse later on
  108083. * @returns the serialized JSON representation
  108084. */
  108085. serialize(): any;
  108086. }
  108087. }
  108088. declare module BABYLON {
  108089. /**
  108090. * Configuration for Draco compression
  108091. */
  108092. export interface IDracoCompressionConfiguration {
  108093. /**
  108094. * Configuration for the decoder.
  108095. */
  108096. decoder?: {
  108097. /**
  108098. * The url to the WebAssembly module.
  108099. */
  108100. wasmUrl?: string;
  108101. /**
  108102. * The url to the WebAssembly binary.
  108103. */
  108104. wasmBinaryUrl?: string;
  108105. /**
  108106. * The url to the fallback JavaScript module.
  108107. */
  108108. fallbackUrl?: string;
  108109. };
  108110. }
  108111. /**
  108112. * Draco compression (https://google.github.io/draco/)
  108113. *
  108114. * This class wraps the Draco module.
  108115. *
  108116. * **Encoder**
  108117. *
  108118. * The encoder is not currently implemented.
  108119. *
  108120. * **Decoder**
  108121. *
  108122. * 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.
  108123. *
  108124. * To update the configuration, use the following code:
  108125. * ```javascript
  108126. * DracoCompression.Configuration = {
  108127. * decoder: {
  108128. * wasmUrl: "<url to the WebAssembly library>",
  108129. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108130. * fallbackUrl: "<url to the fallback JavaScript library>",
  108131. * }
  108132. * };
  108133. * ```
  108134. *
  108135. * 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.
  108136. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108137. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108138. *
  108139. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108140. * ```javascript
  108141. * var dracoCompression = new DracoCompression();
  108142. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108143. * [VertexBuffer.PositionKind]: 0
  108144. * });
  108145. * ```
  108146. *
  108147. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108148. */
  108149. export class DracoCompression implements IDisposable {
  108150. private static _DecoderModulePromise;
  108151. /**
  108152. * The configuration. Defaults to the following urls:
  108153. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108154. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108155. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108156. */
  108157. static Configuration: IDracoCompressionConfiguration;
  108158. /**
  108159. * Returns true if the decoder is available.
  108160. */
  108161. static readonly DecoderAvailable: boolean;
  108162. /**
  108163. * Constructor
  108164. */
  108165. constructor();
  108166. /**
  108167. * Stop all async operations and release resources.
  108168. */
  108169. dispose(): void;
  108170. /**
  108171. * Decode Draco compressed mesh data to vertex data.
  108172. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108173. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108174. * @returns A promise that resolves with the decoded vertex data
  108175. */
  108176. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108177. [kind: string]: number;
  108178. }): Promise<VertexData>;
  108179. private static _GetDecoderModule;
  108180. private static _LoadScriptAsync;
  108181. private static _LoadFileAsync;
  108182. }
  108183. }
  108184. declare module BABYLON {
  108185. /**
  108186. * Class for building Constructive Solid Geometry
  108187. */
  108188. export class CSG {
  108189. private polygons;
  108190. /**
  108191. * The world matrix
  108192. */
  108193. matrix: Matrix;
  108194. /**
  108195. * Stores the position
  108196. */
  108197. position: Vector3;
  108198. /**
  108199. * Stores the rotation
  108200. */
  108201. rotation: Vector3;
  108202. /**
  108203. * Stores the rotation quaternion
  108204. */
  108205. rotationQuaternion: Nullable<Quaternion>;
  108206. /**
  108207. * Stores the scaling vector
  108208. */
  108209. scaling: Vector3;
  108210. /**
  108211. * Convert the Mesh to CSG
  108212. * @param mesh The Mesh to convert to CSG
  108213. * @returns A new CSG from the Mesh
  108214. */
  108215. static FromMesh(mesh: Mesh): CSG;
  108216. /**
  108217. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108218. * @param polygons Polygons used to construct a CSG solid
  108219. */
  108220. private static FromPolygons;
  108221. /**
  108222. * Clones, or makes a deep copy, of the CSG
  108223. * @returns A new CSG
  108224. */
  108225. clone(): CSG;
  108226. /**
  108227. * Unions this CSG with another CSG
  108228. * @param csg The CSG to union against this CSG
  108229. * @returns The unioned CSG
  108230. */
  108231. union(csg: CSG): CSG;
  108232. /**
  108233. * Unions this CSG with another CSG in place
  108234. * @param csg The CSG to union against this CSG
  108235. */
  108236. unionInPlace(csg: CSG): void;
  108237. /**
  108238. * Subtracts this CSG with another CSG
  108239. * @param csg The CSG to subtract against this CSG
  108240. * @returns A new CSG
  108241. */
  108242. subtract(csg: CSG): CSG;
  108243. /**
  108244. * Subtracts this CSG with another CSG in place
  108245. * @param csg The CSG to subtact against this CSG
  108246. */
  108247. subtractInPlace(csg: CSG): void;
  108248. /**
  108249. * Intersect this CSG with another CSG
  108250. * @param csg The CSG to intersect against this CSG
  108251. * @returns A new CSG
  108252. */
  108253. intersect(csg: CSG): CSG;
  108254. /**
  108255. * Intersects this CSG with another CSG in place
  108256. * @param csg The CSG to intersect against this CSG
  108257. */
  108258. intersectInPlace(csg: CSG): void;
  108259. /**
  108260. * Return a new CSG solid with solid and empty space switched. This solid is
  108261. * not modified.
  108262. * @returns A new CSG solid with solid and empty space switched
  108263. */
  108264. inverse(): CSG;
  108265. /**
  108266. * Inverses the CSG in place
  108267. */
  108268. inverseInPlace(): void;
  108269. /**
  108270. * This is used to keep meshes transformations so they can be restored
  108271. * when we build back a Babylon Mesh
  108272. * NB : All CSG operations are performed in world coordinates
  108273. * @param csg The CSG to copy the transform attributes from
  108274. * @returns This CSG
  108275. */
  108276. copyTransformAttributes(csg: CSG): CSG;
  108277. /**
  108278. * Build Raw mesh from CSG
  108279. * Coordinates here are in world space
  108280. * @param name The name of the mesh geometry
  108281. * @param scene The Scene
  108282. * @param keepSubMeshes Specifies if the submeshes should be kept
  108283. * @returns A new Mesh
  108284. */
  108285. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108286. /**
  108287. * Build Mesh from CSG taking material and transforms into account
  108288. * @param name The name of the Mesh
  108289. * @param material The material of the Mesh
  108290. * @param scene The Scene
  108291. * @param keepSubMeshes Specifies if submeshes should be kept
  108292. * @returns The new Mesh
  108293. */
  108294. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108295. }
  108296. }
  108297. declare module BABYLON {
  108298. /**
  108299. * Class used to create a trail following a mesh
  108300. */
  108301. export class TrailMesh extends Mesh {
  108302. private _generator;
  108303. private _autoStart;
  108304. private _running;
  108305. private _diameter;
  108306. private _length;
  108307. private _sectionPolygonPointsCount;
  108308. private _sectionVectors;
  108309. private _sectionNormalVectors;
  108310. private _beforeRenderObserver;
  108311. /**
  108312. * @constructor
  108313. * @param name The value used by scene.getMeshByName() to do a lookup.
  108314. * @param generator The mesh to generate a trail.
  108315. * @param scene The scene to add this mesh to.
  108316. * @param diameter Diameter of trailing mesh. Default is 1.
  108317. * @param length Length of trailing mesh. Default is 60.
  108318. * @param autoStart Automatically start trailing mesh. Default true.
  108319. */
  108320. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108321. /**
  108322. * "TrailMesh"
  108323. * @returns "TrailMesh"
  108324. */
  108325. getClassName(): string;
  108326. private _createMesh;
  108327. /**
  108328. * Start trailing mesh.
  108329. */
  108330. start(): void;
  108331. /**
  108332. * Stop trailing mesh.
  108333. */
  108334. stop(): void;
  108335. /**
  108336. * Update trailing mesh geometry.
  108337. */
  108338. update(): void;
  108339. /**
  108340. * Returns a new TrailMesh object.
  108341. * @param name is a string, the name given to the new mesh
  108342. * @param newGenerator use new generator object for cloned trail mesh
  108343. * @returns a new mesh
  108344. */
  108345. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108346. /**
  108347. * Serializes this trail mesh
  108348. * @param serializationObject object to write serialization to
  108349. */
  108350. serialize(serializationObject: any): void;
  108351. /**
  108352. * Parses a serialized trail mesh
  108353. * @param parsedMesh the serialized mesh
  108354. * @param scene the scene to create the trail mesh in
  108355. * @returns the created trail mesh
  108356. */
  108357. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108358. }
  108359. }
  108360. declare module BABYLON {
  108361. /**
  108362. * Class containing static functions to help procedurally build meshes
  108363. */
  108364. export class TorusKnotBuilder {
  108365. /**
  108366. * Creates a torus knot mesh
  108367. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108368. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108369. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108370. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108374. * @param name defines the name of the mesh
  108375. * @param options defines the options used to create the mesh
  108376. * @param scene defines the hosting scene
  108377. * @returns the torus knot mesh
  108378. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108379. */
  108380. static CreateTorusKnot(name: string, options: {
  108381. radius?: number;
  108382. tube?: number;
  108383. radialSegments?: number;
  108384. tubularSegments?: number;
  108385. p?: number;
  108386. q?: number;
  108387. updatable?: boolean;
  108388. sideOrientation?: number;
  108389. frontUVs?: Vector4;
  108390. backUVs?: Vector4;
  108391. }, scene: any): Mesh;
  108392. }
  108393. }
  108394. declare module BABYLON {
  108395. /**
  108396. * Polygon
  108397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108398. */
  108399. export class Polygon {
  108400. /**
  108401. * Creates a rectangle
  108402. * @param xmin bottom X coord
  108403. * @param ymin bottom Y coord
  108404. * @param xmax top X coord
  108405. * @param ymax top Y coord
  108406. * @returns points that make the resulting rectation
  108407. */
  108408. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108409. /**
  108410. * Creates a circle
  108411. * @param radius radius of circle
  108412. * @param cx scale in x
  108413. * @param cy scale in y
  108414. * @param numberOfSides number of sides that make up the circle
  108415. * @returns points that make the resulting circle
  108416. */
  108417. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108418. /**
  108419. * Creates a polygon from input string
  108420. * @param input Input polygon data
  108421. * @returns the parsed points
  108422. */
  108423. static Parse(input: string): Vector2[];
  108424. /**
  108425. * Starts building a polygon from x and y coordinates
  108426. * @param x x coordinate
  108427. * @param y y coordinate
  108428. * @returns the started path2
  108429. */
  108430. static StartingAt(x: number, y: number): Path2;
  108431. }
  108432. /**
  108433. * Builds a polygon
  108434. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108435. */
  108436. export class PolygonMeshBuilder {
  108437. private _points;
  108438. private _outlinepoints;
  108439. private _holes;
  108440. private _name;
  108441. private _scene;
  108442. private _epoints;
  108443. private _eholes;
  108444. private _addToepoint;
  108445. /**
  108446. * Babylon reference to the earcut plugin.
  108447. */
  108448. bjsEarcut: any;
  108449. /**
  108450. * Creates a PolygonMeshBuilder
  108451. * @param name name of the builder
  108452. * @param contours Path of the polygon
  108453. * @param scene scene to add to when creating the mesh
  108454. * @param earcutInjection can be used to inject your own earcut reference
  108455. */
  108456. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108457. /**
  108458. * Adds a whole within the polygon
  108459. * @param hole Array of points defining the hole
  108460. * @returns this
  108461. */
  108462. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108463. /**
  108464. * Creates the polygon
  108465. * @param updatable If the mesh should be updatable
  108466. * @param depth The depth of the mesh created
  108467. * @returns the created mesh
  108468. */
  108469. build(updatable?: boolean, depth?: number): Mesh;
  108470. /**
  108471. * Creates the polygon
  108472. * @param depth The depth of the mesh created
  108473. * @returns the created VertexData
  108474. */
  108475. buildVertexData(depth?: number): VertexData;
  108476. /**
  108477. * Adds a side to the polygon
  108478. * @param positions points that make the polygon
  108479. * @param normals normals of the polygon
  108480. * @param uvs uvs of the polygon
  108481. * @param indices indices of the polygon
  108482. * @param bounds bounds of the polygon
  108483. * @param points points of the polygon
  108484. * @param depth depth of the polygon
  108485. * @param flip flip of the polygon
  108486. */
  108487. private addSide;
  108488. }
  108489. }
  108490. declare module BABYLON {
  108491. /**
  108492. * Class containing static functions to help procedurally build meshes
  108493. */
  108494. export class PolygonBuilder {
  108495. /**
  108496. * Creates a polygon mesh
  108497. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108498. * * 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
  108499. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  108502. * * Remember you can only change the shape positions, not their number when updating a polygon
  108503. * @param name defines the name of the mesh
  108504. * @param options defines the options used to create the mesh
  108505. * @param scene defines the hosting scene
  108506. * @param earcutInjection can be used to inject your own earcut reference
  108507. * @returns the polygon mesh
  108508. */
  108509. static CreatePolygon(name: string, options: {
  108510. shape: Vector3[];
  108511. holes?: Vector3[][];
  108512. depth?: number;
  108513. faceUV?: Vector4[];
  108514. faceColors?: Color4[];
  108515. updatable?: boolean;
  108516. sideOrientation?: number;
  108517. frontUVs?: Vector4;
  108518. backUVs?: Vector4;
  108519. }, scene: Scene, earcutInjection?: any): Mesh;
  108520. /**
  108521. * Creates an extruded polygon mesh, with depth in the Y direction.
  108522. * * 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)
  108523. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108524. * @param name defines the name of the mesh
  108525. * @param options defines the options used to create the mesh
  108526. * @param scene defines the hosting scene
  108527. * @param earcutInjection can be used to inject your own earcut reference
  108528. * @returns the polygon mesh
  108529. */
  108530. static ExtrudePolygon(name: string, options: {
  108531. shape: Vector3[];
  108532. holes?: Vector3[][];
  108533. depth?: number;
  108534. faceUV?: Vector4[];
  108535. faceColors?: Color4[];
  108536. updatable?: boolean;
  108537. sideOrientation?: number;
  108538. frontUVs?: Vector4;
  108539. backUVs?: Vector4;
  108540. }, scene: Scene, earcutInjection?: any): Mesh;
  108541. }
  108542. }
  108543. declare module BABYLON {
  108544. /**
  108545. * Class containing static functions to help procedurally build meshes
  108546. */
  108547. export class LatheBuilder {
  108548. /**
  108549. * Creates lathe mesh.
  108550. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  108551. * * 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
  108552. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  108553. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  108554. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  108555. * * 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
  108556. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  108557. * * 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
  108558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108562. * @param name defines the name of the mesh
  108563. * @param options defines the options used to create the mesh
  108564. * @param scene defines the hosting scene
  108565. * @returns the lathe mesh
  108566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  108567. */
  108568. static CreateLathe(name: string, options: {
  108569. shape: Vector3[];
  108570. radius?: number;
  108571. tessellation?: number;
  108572. clip?: number;
  108573. arc?: number;
  108574. closed?: boolean;
  108575. updatable?: boolean;
  108576. sideOrientation?: number;
  108577. frontUVs?: Vector4;
  108578. backUVs?: Vector4;
  108579. cap?: number;
  108580. invertUV?: boolean;
  108581. }, scene: Scene): Mesh;
  108582. }
  108583. }
  108584. declare module BABYLON {
  108585. /**
  108586. * Class containing static functions to help procedurally build meshes
  108587. */
  108588. export class TubeBuilder {
  108589. /**
  108590. * Creates a tube mesh.
  108591. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108592. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  108593. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  108594. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  108595. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  108596. * * 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)
  108597. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  108598. * * 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
  108599. * * 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
  108600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108604. * @param name defines the name of the mesh
  108605. * @param options defines the options used to create the mesh
  108606. * @param scene defines the hosting scene
  108607. * @returns the tube mesh
  108608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108609. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  108610. */
  108611. static CreateTube(name: string, options: {
  108612. path: Vector3[];
  108613. radius?: number;
  108614. tessellation?: number;
  108615. radiusFunction?: {
  108616. (i: number, distance: number): number;
  108617. };
  108618. cap?: number;
  108619. arc?: number;
  108620. updatable?: boolean;
  108621. sideOrientation?: number;
  108622. frontUVs?: Vector4;
  108623. backUVs?: Vector4;
  108624. instance?: Mesh;
  108625. invertUV?: boolean;
  108626. }, scene: Scene): Mesh;
  108627. }
  108628. }
  108629. declare module BABYLON {
  108630. /**
  108631. * Class containing static functions to help procedurally build meshes
  108632. */
  108633. export class IcoSphereBuilder {
  108634. /**
  108635. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108636. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108637. * * 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`)
  108638. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108639. * * 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
  108640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108643. * @param name defines the name of the mesh
  108644. * @param options defines the options used to create the mesh
  108645. * @param scene defines the hosting scene
  108646. * @returns the icosahedron mesh
  108647. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108648. */
  108649. static CreateIcoSphere(name: string, options: {
  108650. radius?: number;
  108651. radiusX?: number;
  108652. radiusY?: number;
  108653. radiusZ?: number;
  108654. flat?: boolean;
  108655. subdivisions?: number;
  108656. sideOrientation?: number;
  108657. frontUVs?: Vector4;
  108658. backUVs?: Vector4;
  108659. updatable?: boolean;
  108660. }, scene: Scene): Mesh;
  108661. }
  108662. }
  108663. declare module BABYLON {
  108664. /**
  108665. * Class containing static functions to help procedurally build meshes
  108666. */
  108667. export class DecalBuilder {
  108668. /**
  108669. * Creates a decal mesh.
  108670. * 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
  108671. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  108672. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  108673. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  108674. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  108675. * @param name defines the name of the mesh
  108676. * @param sourceMesh defines the mesh where the decal must be applied
  108677. * @param options defines the options used to create the mesh
  108678. * @param scene defines the hosting scene
  108679. * @returns the decal mesh
  108680. * @see https://doc.babylonjs.com/how_to/decals
  108681. */
  108682. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  108683. position?: Vector3;
  108684. normal?: Vector3;
  108685. size?: Vector3;
  108686. angle?: number;
  108687. }): Mesh;
  108688. }
  108689. }
  108690. declare module BABYLON {
  108691. /**
  108692. * Class containing static functions to help procedurally build meshes
  108693. */
  108694. export class MeshBuilder {
  108695. /**
  108696. * Creates a box mesh
  108697. * * The parameter `size` sets the size (float) of each box side (default 1)
  108698. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108699. * * 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)
  108700. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108704. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108705. * @param name defines the name of the mesh
  108706. * @param options defines the options used to create the mesh
  108707. * @param scene defines the hosting scene
  108708. * @returns the box mesh
  108709. */
  108710. static CreateBox(name: string, options: {
  108711. size?: number;
  108712. width?: number;
  108713. height?: number;
  108714. depth?: number;
  108715. faceUV?: Vector4[];
  108716. faceColors?: Color4[];
  108717. sideOrientation?: number;
  108718. frontUVs?: Vector4;
  108719. backUVs?: Vector4;
  108720. updatable?: boolean;
  108721. }, scene?: Nullable<Scene>): Mesh;
  108722. /**
  108723. * Creates a sphere mesh
  108724. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108725. * * 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`)
  108726. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108727. * * 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
  108728. * * 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)
  108729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108732. * @param name defines the name of the mesh
  108733. * @param options defines the options used to create the mesh
  108734. * @param scene defines the hosting scene
  108735. * @returns the sphere mesh
  108736. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108737. */
  108738. static CreateSphere(name: string, options: {
  108739. segments?: number;
  108740. diameter?: number;
  108741. diameterX?: number;
  108742. diameterY?: number;
  108743. diameterZ?: number;
  108744. arc?: number;
  108745. slice?: number;
  108746. sideOrientation?: number;
  108747. frontUVs?: Vector4;
  108748. backUVs?: Vector4;
  108749. updatable?: boolean;
  108750. }, scene: any): Mesh;
  108751. /**
  108752. * Creates a plane polygonal mesh. By default, this is a disc
  108753. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108754. * * 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
  108755. * * 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
  108756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108759. * @param name defines the name of the mesh
  108760. * @param options defines the options used to create the mesh
  108761. * @param scene defines the hosting scene
  108762. * @returns the plane polygonal mesh
  108763. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108764. */
  108765. static CreateDisc(name: string, options: {
  108766. radius?: number;
  108767. tessellation?: number;
  108768. arc?: number;
  108769. updatable?: boolean;
  108770. sideOrientation?: number;
  108771. frontUVs?: Vector4;
  108772. backUVs?: Vector4;
  108773. }, scene?: Nullable<Scene>): Mesh;
  108774. /**
  108775. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108776. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108777. * * 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`)
  108778. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108779. * * 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
  108780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108783. * @param name defines the name of the mesh
  108784. * @param options defines the options used to create the mesh
  108785. * @param scene defines the hosting scene
  108786. * @returns the icosahedron mesh
  108787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108788. */
  108789. static CreateIcoSphere(name: string, options: {
  108790. radius?: number;
  108791. radiusX?: number;
  108792. radiusY?: number;
  108793. radiusZ?: number;
  108794. flat?: boolean;
  108795. subdivisions?: number;
  108796. sideOrientation?: number;
  108797. frontUVs?: Vector4;
  108798. backUVs?: Vector4;
  108799. updatable?: boolean;
  108800. }, scene: Scene): Mesh;
  108801. /**
  108802. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108803. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108804. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108805. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108806. * * 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
  108807. * * 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
  108808. * * 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
  108809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108812. * * 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
  108813. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108814. * * 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
  108815. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108817. * @param name defines the name of the mesh
  108818. * @param options defines the options used to create the mesh
  108819. * @param scene defines the hosting scene
  108820. * @returns the ribbon mesh
  108821. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108822. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108823. */
  108824. static CreateRibbon(name: string, options: {
  108825. pathArray: Vector3[][];
  108826. closeArray?: boolean;
  108827. closePath?: boolean;
  108828. offset?: number;
  108829. updatable?: boolean;
  108830. sideOrientation?: number;
  108831. frontUVs?: Vector4;
  108832. backUVs?: Vector4;
  108833. instance?: Mesh;
  108834. invertUV?: boolean;
  108835. uvs?: Vector2[];
  108836. colors?: Color4[];
  108837. }, scene?: Nullable<Scene>): Mesh;
  108838. /**
  108839. * Creates a cylinder or a cone mesh
  108840. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108841. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108842. * * 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.
  108843. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108844. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108845. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108846. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108847. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108848. * * 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).
  108849. * * 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
  108850. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108851. * * 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
  108852. * * 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.
  108853. * * If `enclose` is false, a ring surface is one element.
  108854. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108855. * * 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
  108856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108859. * @param name defines the name of the mesh
  108860. * @param options defines the options used to create the mesh
  108861. * @param scene defines the hosting scene
  108862. * @returns the cylinder mesh
  108863. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108864. */
  108865. static CreateCylinder(name: string, options: {
  108866. height?: number;
  108867. diameterTop?: number;
  108868. diameterBottom?: number;
  108869. diameter?: number;
  108870. tessellation?: number;
  108871. subdivisions?: number;
  108872. arc?: number;
  108873. faceColors?: Color4[];
  108874. faceUV?: Vector4[];
  108875. updatable?: boolean;
  108876. hasRings?: boolean;
  108877. enclose?: boolean;
  108878. sideOrientation?: number;
  108879. frontUVs?: Vector4;
  108880. backUVs?: Vector4;
  108881. }, scene: any): Mesh;
  108882. /**
  108883. * Creates a torus mesh
  108884. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108885. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108886. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108890. * @param name defines the name of the mesh
  108891. * @param options defines the options used to create the mesh
  108892. * @param scene defines the hosting scene
  108893. * @returns the torus mesh
  108894. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108895. */
  108896. static CreateTorus(name: string, options: {
  108897. diameter?: number;
  108898. thickness?: number;
  108899. tessellation?: number;
  108900. updatable?: boolean;
  108901. sideOrientation?: number;
  108902. frontUVs?: Vector4;
  108903. backUVs?: Vector4;
  108904. }, scene: any): Mesh;
  108905. /**
  108906. * Creates a torus knot mesh
  108907. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108908. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108909. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108910. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108914. * @param name defines the name of the mesh
  108915. * @param options defines the options used to create the mesh
  108916. * @param scene defines the hosting scene
  108917. * @returns the torus knot mesh
  108918. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108919. */
  108920. static CreateTorusKnot(name: string, options: {
  108921. radius?: number;
  108922. tube?: number;
  108923. radialSegments?: number;
  108924. tubularSegments?: number;
  108925. p?: number;
  108926. q?: number;
  108927. updatable?: boolean;
  108928. sideOrientation?: number;
  108929. frontUVs?: Vector4;
  108930. backUVs?: Vector4;
  108931. }, scene: any): Mesh;
  108932. /**
  108933. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108934. * * 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
  108935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108936. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108937. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108938. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108939. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108940. * * 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
  108941. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108944. * @param name defines the name of the new line system
  108945. * @param options defines the options used to create the line system
  108946. * @param scene defines the hosting scene
  108947. * @returns a new line system mesh
  108948. */
  108949. static CreateLineSystem(name: string, options: {
  108950. lines: Vector3[][];
  108951. updatable?: boolean;
  108952. instance?: Nullable<LinesMesh>;
  108953. colors?: Nullable<Color4[][]>;
  108954. useVertexAlpha?: boolean;
  108955. }, scene: Nullable<Scene>): LinesMesh;
  108956. /**
  108957. * Creates a line mesh
  108958. * 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
  108959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108960. * * The parameter `points` is an array successive Vector3
  108961. * * 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
  108962. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108963. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108964. * * When updating an instance, remember that only point positions can change, not the number of points
  108965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108967. * @param name defines the name of the new line system
  108968. * @param options defines the options used to create the line system
  108969. * @param scene defines the hosting scene
  108970. * @returns a new line mesh
  108971. */
  108972. static CreateLines(name: string, options: {
  108973. points: Vector3[];
  108974. updatable?: boolean;
  108975. instance?: Nullable<LinesMesh>;
  108976. colors?: Color4[];
  108977. useVertexAlpha?: boolean;
  108978. }, scene?: Nullable<Scene>): LinesMesh;
  108979. /**
  108980. * Creates a dashed line mesh
  108981. * * 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
  108982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108983. * * The parameter `points` is an array successive Vector3
  108984. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108985. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108986. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108987. * * 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
  108988. * * When updating an instance, remember that only point positions can change, not the number of points
  108989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108990. * @param name defines the name of the mesh
  108991. * @param options defines the options used to create the mesh
  108992. * @param scene defines the hosting scene
  108993. * @returns the dashed line mesh
  108994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108995. */
  108996. static CreateDashedLines(name: string, options: {
  108997. points: Vector3[];
  108998. dashSize?: number;
  108999. gapSize?: number;
  109000. dashNb?: number;
  109001. updatable?: boolean;
  109002. instance?: LinesMesh;
  109003. }, scene?: Nullable<Scene>): LinesMesh;
  109004. /**
  109005. * 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.
  109006. * * 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.
  109007. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109008. * * 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.
  109009. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109010. * * 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
  109011. * * 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
  109012. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109017. * @param name defines the name of the mesh
  109018. * @param options defines the options used to create the mesh
  109019. * @param scene defines the hosting scene
  109020. * @returns the extruded shape mesh
  109021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109023. */
  109024. static ExtrudeShape(name: string, options: {
  109025. shape: Vector3[];
  109026. path: Vector3[];
  109027. scale?: number;
  109028. rotation?: number;
  109029. cap?: number;
  109030. updatable?: boolean;
  109031. sideOrientation?: number;
  109032. frontUVs?: Vector4;
  109033. backUVs?: Vector4;
  109034. instance?: Mesh;
  109035. invertUV?: boolean;
  109036. }, scene?: Nullable<Scene>): Mesh;
  109037. /**
  109038. * Creates an custom extruded shape mesh.
  109039. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109040. * * 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.
  109041. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109042. * * 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
  109043. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109044. * * 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
  109045. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109046. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109047. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109048. * * 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
  109049. * * 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
  109050. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109055. * @param name defines the name of the mesh
  109056. * @param options defines the options used to create the mesh
  109057. * @param scene defines the hosting scene
  109058. * @returns the custom extruded shape mesh
  109059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109062. */
  109063. static ExtrudeShapeCustom(name: string, options: {
  109064. shape: Vector3[];
  109065. path: Vector3[];
  109066. scaleFunction?: any;
  109067. rotationFunction?: any;
  109068. ribbonCloseArray?: boolean;
  109069. ribbonClosePath?: boolean;
  109070. cap?: number;
  109071. updatable?: boolean;
  109072. sideOrientation?: number;
  109073. frontUVs?: Vector4;
  109074. backUVs?: Vector4;
  109075. instance?: Mesh;
  109076. invertUV?: boolean;
  109077. }, scene: Scene): Mesh;
  109078. /**
  109079. * Creates lathe mesh.
  109080. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109081. * * 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
  109082. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109083. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109084. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109085. * * 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
  109086. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109087. * * 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
  109088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109092. * @param name defines the name of the mesh
  109093. * @param options defines the options used to create the mesh
  109094. * @param scene defines the hosting scene
  109095. * @returns the lathe mesh
  109096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109097. */
  109098. static CreateLathe(name: string, options: {
  109099. shape: Vector3[];
  109100. radius?: number;
  109101. tessellation?: number;
  109102. clip?: number;
  109103. arc?: number;
  109104. closed?: boolean;
  109105. updatable?: boolean;
  109106. sideOrientation?: number;
  109107. frontUVs?: Vector4;
  109108. backUVs?: Vector4;
  109109. cap?: number;
  109110. invertUV?: boolean;
  109111. }, scene: Scene): Mesh;
  109112. /**
  109113. * Creates a plane mesh
  109114. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109115. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109116. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109120. * @param name defines the name of the mesh
  109121. * @param options defines the options used to create the mesh
  109122. * @param scene defines the hosting scene
  109123. * @returns the plane mesh
  109124. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109125. */
  109126. static CreatePlane(name: string, options: {
  109127. size?: number;
  109128. width?: number;
  109129. height?: number;
  109130. sideOrientation?: number;
  109131. frontUVs?: Vector4;
  109132. backUVs?: Vector4;
  109133. updatable?: boolean;
  109134. sourcePlane?: Plane;
  109135. }, scene: Scene): Mesh;
  109136. /**
  109137. * Creates a ground mesh
  109138. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109139. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109141. * @param name defines the name of the mesh
  109142. * @param options defines the options used to create the mesh
  109143. * @param scene defines the hosting scene
  109144. * @returns the ground mesh
  109145. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109146. */
  109147. static CreateGround(name: string, options: {
  109148. width?: number;
  109149. height?: number;
  109150. subdivisions?: number;
  109151. subdivisionsX?: number;
  109152. subdivisionsY?: number;
  109153. updatable?: boolean;
  109154. }, scene: any): Mesh;
  109155. /**
  109156. * Creates a tiled ground mesh
  109157. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109158. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109159. * * 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
  109160. * * 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
  109161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109162. * @param name defines the name of the mesh
  109163. * @param options defines the options used to create the mesh
  109164. * @param scene defines the hosting scene
  109165. * @returns the tiled ground mesh
  109166. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109167. */
  109168. static CreateTiledGround(name: string, options: {
  109169. xmin: number;
  109170. zmin: number;
  109171. xmax: number;
  109172. zmax: number;
  109173. subdivisions?: {
  109174. w: number;
  109175. h: number;
  109176. };
  109177. precision?: {
  109178. w: number;
  109179. h: number;
  109180. };
  109181. updatable?: boolean;
  109182. }, scene: Scene): Mesh;
  109183. /**
  109184. * Creates a ground mesh from a height map
  109185. * * The parameter `url` sets the URL of the height map image resource.
  109186. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109187. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109188. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109189. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109190. * * 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.
  109191. * * 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).
  109192. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109194. * @param name defines the name of the mesh
  109195. * @param url defines the url to the height map
  109196. * @param options defines the options used to create the mesh
  109197. * @param scene defines the hosting scene
  109198. * @returns the ground mesh
  109199. * @see https://doc.babylonjs.com/babylon101/height_map
  109200. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109201. */
  109202. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109203. width?: number;
  109204. height?: number;
  109205. subdivisions?: number;
  109206. minHeight?: number;
  109207. maxHeight?: number;
  109208. colorFilter?: Color3;
  109209. alphaFilter?: number;
  109210. updatable?: boolean;
  109211. onReady?: (mesh: GroundMesh) => void;
  109212. }, scene: Scene): GroundMesh;
  109213. /**
  109214. * Creates a polygon mesh
  109215. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109216. * * 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
  109217. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109220. * * Remember you can only change the shape positions, not their number when updating a polygon
  109221. * @param name defines the name of the mesh
  109222. * @param options defines the options used to create the mesh
  109223. * @param scene defines the hosting scene
  109224. * @param earcutInjection can be used to inject your own earcut reference
  109225. * @returns the polygon mesh
  109226. */
  109227. static CreatePolygon(name: string, options: {
  109228. shape: Vector3[];
  109229. holes?: Vector3[][];
  109230. depth?: number;
  109231. faceUV?: Vector4[];
  109232. faceColors?: Color4[];
  109233. updatable?: boolean;
  109234. sideOrientation?: number;
  109235. frontUVs?: Vector4;
  109236. backUVs?: Vector4;
  109237. }, scene: Scene, earcutInjection?: any): Mesh;
  109238. /**
  109239. * Creates an extruded polygon mesh, with depth in the Y direction.
  109240. * * 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)
  109241. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109242. * @param name defines the name of the mesh
  109243. * @param options defines the options used to create the mesh
  109244. * @param scene defines the hosting scene
  109245. * @param earcutInjection can be used to inject your own earcut reference
  109246. * @returns the polygon mesh
  109247. */
  109248. static ExtrudePolygon(name: string, options: {
  109249. shape: Vector3[];
  109250. holes?: Vector3[][];
  109251. depth?: number;
  109252. faceUV?: Vector4[];
  109253. faceColors?: Color4[];
  109254. updatable?: boolean;
  109255. sideOrientation?: number;
  109256. frontUVs?: Vector4;
  109257. backUVs?: Vector4;
  109258. }, scene: Scene, earcutInjection?: any): Mesh;
  109259. /**
  109260. * Creates a tube mesh.
  109261. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109262. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109263. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109264. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109265. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109266. * * 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)
  109267. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109268. * * 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
  109269. * * 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
  109270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109274. * @param name defines the name of the mesh
  109275. * @param options defines the options used to create the mesh
  109276. * @param scene defines the hosting scene
  109277. * @returns the tube mesh
  109278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109279. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109280. */
  109281. static CreateTube(name: string, options: {
  109282. path: Vector3[];
  109283. radius?: number;
  109284. tessellation?: number;
  109285. radiusFunction?: {
  109286. (i: number, distance: number): number;
  109287. };
  109288. cap?: number;
  109289. arc?: number;
  109290. updatable?: boolean;
  109291. sideOrientation?: number;
  109292. frontUVs?: Vector4;
  109293. backUVs?: Vector4;
  109294. instance?: Mesh;
  109295. invertUV?: boolean;
  109296. }, scene: Scene): Mesh;
  109297. /**
  109298. * Creates a polyhedron mesh
  109299. * * 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
  109300. * * The parameter `size` (positive float, default 1) sets the polygon size
  109301. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109302. * * 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`
  109303. * * 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
  109304. * * 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)`)
  109305. * * 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
  109306. * * 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
  109307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109310. * @param name defines the name of the mesh
  109311. * @param options defines the options used to create the mesh
  109312. * @param scene defines the hosting scene
  109313. * @returns the polyhedron mesh
  109314. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109315. */
  109316. static CreatePolyhedron(name: string, options: {
  109317. type?: number;
  109318. size?: number;
  109319. sizeX?: number;
  109320. sizeY?: number;
  109321. sizeZ?: number;
  109322. custom?: any;
  109323. faceUV?: Vector4[];
  109324. faceColors?: Color4[];
  109325. flat?: boolean;
  109326. updatable?: boolean;
  109327. sideOrientation?: number;
  109328. frontUVs?: Vector4;
  109329. backUVs?: Vector4;
  109330. }, scene: Scene): Mesh;
  109331. /**
  109332. * Creates a decal mesh.
  109333. * 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
  109334. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109335. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109336. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109337. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109338. * @param name defines the name of the mesh
  109339. * @param sourceMesh defines the mesh where the decal must be applied
  109340. * @param options defines the options used to create the mesh
  109341. * @param scene defines the hosting scene
  109342. * @returns the decal mesh
  109343. * @see https://doc.babylonjs.com/how_to/decals
  109344. */
  109345. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109346. position?: Vector3;
  109347. normal?: Vector3;
  109348. size?: Vector3;
  109349. angle?: number;
  109350. }): Mesh;
  109351. }
  109352. }
  109353. declare module BABYLON {
  109354. /**
  109355. * A simplifier interface for future simplification implementations
  109356. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109357. */
  109358. export interface ISimplifier {
  109359. /**
  109360. * Simplification of a given mesh according to the given settings.
  109361. * Since this requires computation, it is assumed that the function runs async.
  109362. * @param settings The settings of the simplification, including quality and distance
  109363. * @param successCallback A callback that will be called after the mesh was simplified.
  109364. * @param errorCallback in case of an error, this callback will be called. optional.
  109365. */
  109366. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109367. }
  109368. /**
  109369. * Expected simplification settings.
  109370. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109371. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109372. */
  109373. export interface ISimplificationSettings {
  109374. /**
  109375. * Gets or sets the expected quality
  109376. */
  109377. quality: number;
  109378. /**
  109379. * Gets or sets the distance when this optimized version should be used
  109380. */
  109381. distance: number;
  109382. /**
  109383. * Gets an already optimized mesh
  109384. */
  109385. optimizeMesh?: boolean;
  109386. }
  109387. /**
  109388. * Class used to specify simplification options
  109389. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109390. */
  109391. export class SimplificationSettings implements ISimplificationSettings {
  109392. /** expected quality */
  109393. quality: number;
  109394. /** distance when this optimized version should be used */
  109395. distance: number;
  109396. /** already optimized mesh */
  109397. optimizeMesh?: boolean | undefined;
  109398. /**
  109399. * Creates a SimplificationSettings
  109400. * @param quality expected quality
  109401. * @param distance distance when this optimized version should be used
  109402. * @param optimizeMesh already optimized mesh
  109403. */
  109404. constructor(
  109405. /** expected quality */
  109406. quality: number,
  109407. /** distance when this optimized version should be used */
  109408. distance: number,
  109409. /** already optimized mesh */
  109410. optimizeMesh?: boolean | undefined);
  109411. }
  109412. /**
  109413. * Interface used to define a simplification task
  109414. */
  109415. export interface ISimplificationTask {
  109416. /**
  109417. * Array of settings
  109418. */
  109419. settings: Array<ISimplificationSettings>;
  109420. /**
  109421. * Simplification type
  109422. */
  109423. simplificationType: SimplificationType;
  109424. /**
  109425. * Mesh to simplify
  109426. */
  109427. mesh: Mesh;
  109428. /**
  109429. * Callback called on success
  109430. */
  109431. successCallback?: () => void;
  109432. /**
  109433. * Defines if parallel processing can be used
  109434. */
  109435. parallelProcessing: boolean;
  109436. }
  109437. /**
  109438. * Queue used to order the simplification tasks
  109439. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109440. */
  109441. export class SimplificationQueue {
  109442. private _simplificationArray;
  109443. /**
  109444. * Gets a boolean indicating that the process is still running
  109445. */
  109446. running: boolean;
  109447. /**
  109448. * Creates a new queue
  109449. */
  109450. constructor();
  109451. /**
  109452. * Adds a new simplification task
  109453. * @param task defines a task to add
  109454. */
  109455. addTask(task: ISimplificationTask): void;
  109456. /**
  109457. * Execute next task
  109458. */
  109459. executeNext(): void;
  109460. /**
  109461. * Execute a simplification task
  109462. * @param task defines the task to run
  109463. */
  109464. runSimplification(task: ISimplificationTask): void;
  109465. private getSimplifier;
  109466. }
  109467. /**
  109468. * The implemented types of simplification
  109469. * At the moment only Quadratic Error Decimation is implemented
  109470. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109471. */
  109472. export enum SimplificationType {
  109473. /** Quadratic error decimation */
  109474. QUADRATIC = 0
  109475. }
  109476. }
  109477. declare module BABYLON {
  109478. interface Scene {
  109479. /** @hidden (Backing field) */
  109480. _simplificationQueue: SimplificationQueue;
  109481. /**
  109482. * Gets or sets the simplification queue attached to the scene
  109483. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109484. */
  109485. simplificationQueue: SimplificationQueue;
  109486. }
  109487. interface Mesh {
  109488. /**
  109489. * Simplify the mesh according to the given array of settings.
  109490. * Function will return immediately and will simplify async
  109491. * @param settings a collection of simplification settings
  109492. * @param parallelProcessing should all levels calculate parallel or one after the other
  109493. * @param simplificationType the type of simplification to run
  109494. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  109495. * @returns the current mesh
  109496. */
  109497. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  109498. }
  109499. /**
  109500. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  109501. * created in a scene
  109502. */
  109503. export class SimplicationQueueSceneComponent implements ISceneComponent {
  109504. /**
  109505. * The component name helpfull to identify the component in the list of scene components.
  109506. */
  109507. readonly name: string;
  109508. /**
  109509. * The scene the component belongs to.
  109510. */
  109511. scene: Scene;
  109512. /**
  109513. * Creates a new instance of the component for the given scene
  109514. * @param scene Defines the scene to register the component in
  109515. */
  109516. constructor(scene: Scene);
  109517. /**
  109518. * Registers the component in a given scene
  109519. */
  109520. register(): void;
  109521. /**
  109522. * Rebuilds the elements related to this component in case of
  109523. * context lost for instance.
  109524. */
  109525. rebuild(): void;
  109526. /**
  109527. * Disposes the component and the associated ressources
  109528. */
  109529. dispose(): void;
  109530. private _beforeCameraUpdate;
  109531. }
  109532. }
  109533. declare module BABYLON {
  109534. /**
  109535. * Class used to enable access to IndexedDB
  109536. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109537. */
  109538. export class Database implements IOfflineProvider {
  109539. private _callbackManifestChecked;
  109540. private _currentSceneUrl;
  109541. private _db;
  109542. private _enableSceneOffline;
  109543. private _enableTexturesOffline;
  109544. private _manifestVersionFound;
  109545. private _mustUpdateRessources;
  109546. private _hasReachedQuota;
  109547. private _isSupported;
  109548. private _idbFactory;
  109549. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  109550. private static IsUASupportingBlobStorage;
  109551. /**
  109552. * Gets a boolean indicating if Database storate is enabled (off by default)
  109553. */
  109554. static IDBStorageEnabled: boolean;
  109555. /**
  109556. * Gets a boolean indicating if scene must be saved in the database
  109557. */
  109558. readonly enableSceneOffline: boolean;
  109559. /**
  109560. * Gets a boolean indicating if textures must be saved in the database
  109561. */
  109562. readonly enableTexturesOffline: boolean;
  109563. /**
  109564. * Creates a new Database
  109565. * @param urlToScene defines the url to load the scene
  109566. * @param callbackManifestChecked defines the callback to use when manifest is checked
  109567. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  109568. */
  109569. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  109570. private static _ParseURL;
  109571. private static _ReturnFullUrlLocation;
  109572. private _checkManifestFile;
  109573. /**
  109574. * Open the database and make it available
  109575. * @param successCallback defines the callback to call on success
  109576. * @param errorCallback defines the callback to call on error
  109577. */
  109578. open(successCallback: () => void, errorCallback: () => void): void;
  109579. /**
  109580. * Loads an image from the database
  109581. * @param url defines the url to load from
  109582. * @param image defines the target DOM image
  109583. */
  109584. loadImage(url: string, image: HTMLImageElement): void;
  109585. private _loadImageFromDBAsync;
  109586. private _saveImageIntoDBAsync;
  109587. private _checkVersionFromDB;
  109588. private _loadVersionFromDBAsync;
  109589. private _saveVersionIntoDBAsync;
  109590. /**
  109591. * Loads a file from database
  109592. * @param url defines the URL to load from
  109593. * @param sceneLoaded defines a callback to call on success
  109594. * @param progressCallBack defines a callback to call when progress changed
  109595. * @param errorCallback defines a callback to call on error
  109596. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  109597. */
  109598. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  109599. private _loadFileAsync;
  109600. private _saveFileAsync;
  109601. /**
  109602. * Validates if xhr data is correct
  109603. * @param xhr defines the request to validate
  109604. * @param dataType defines the expected data type
  109605. * @returns true if data is correct
  109606. */
  109607. private static _ValidateXHRData;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. /** @hidden */
  109612. export var gpuUpdateParticlesPixelShader: {
  109613. name: string;
  109614. shader: string;
  109615. };
  109616. }
  109617. declare module BABYLON {
  109618. /** @hidden */
  109619. export var gpuUpdateParticlesVertexShader: {
  109620. name: string;
  109621. shader: string;
  109622. };
  109623. }
  109624. declare module BABYLON {
  109625. /** @hidden */
  109626. export var clipPlaneFragmentDeclaration2: {
  109627. name: string;
  109628. shader: string;
  109629. };
  109630. }
  109631. declare module BABYLON {
  109632. /** @hidden */
  109633. export var gpuRenderParticlesPixelShader: {
  109634. name: string;
  109635. shader: string;
  109636. };
  109637. }
  109638. declare module BABYLON {
  109639. /** @hidden */
  109640. export var clipPlaneVertexDeclaration2: {
  109641. name: string;
  109642. shader: string;
  109643. };
  109644. }
  109645. declare module BABYLON {
  109646. /** @hidden */
  109647. export var gpuRenderParticlesVertexShader: {
  109648. name: string;
  109649. shader: string;
  109650. };
  109651. }
  109652. declare module BABYLON {
  109653. /**
  109654. * This represents a GPU particle system in Babylon
  109655. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  109656. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  109657. */
  109658. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  109659. /**
  109660. * The layer mask we are rendering the particles through.
  109661. */
  109662. layerMask: number;
  109663. private _capacity;
  109664. private _activeCount;
  109665. private _currentActiveCount;
  109666. private _accumulatedCount;
  109667. private _renderEffect;
  109668. private _updateEffect;
  109669. private _buffer0;
  109670. private _buffer1;
  109671. private _spriteBuffer;
  109672. private _updateVAO;
  109673. private _renderVAO;
  109674. private _targetIndex;
  109675. private _sourceBuffer;
  109676. private _targetBuffer;
  109677. private _engine;
  109678. private _currentRenderId;
  109679. private _started;
  109680. private _stopped;
  109681. private _timeDelta;
  109682. private _randomTexture;
  109683. private _randomTexture2;
  109684. private _attributesStrideSize;
  109685. private _updateEffectOptions;
  109686. private _randomTextureSize;
  109687. private _actualFrame;
  109688. private readonly _rawTextureWidth;
  109689. /**
  109690. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  109691. */
  109692. static readonly IsSupported: boolean;
  109693. /**
  109694. * An event triggered when the system is disposed.
  109695. */
  109696. onDisposeObservable: Observable<GPUParticleSystem>;
  109697. /**
  109698. * Gets the maximum number of particles active at the same time.
  109699. * @returns The max number of active particles.
  109700. */
  109701. getCapacity(): number;
  109702. /**
  109703. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  109704. * to override the particles.
  109705. */
  109706. forceDepthWrite: boolean;
  109707. /**
  109708. * Gets or set the number of active particles
  109709. */
  109710. activeParticleCount: number;
  109711. private _preWarmDone;
  109712. /**
  109713. * Is this system ready to be used/rendered
  109714. * @return true if the system is ready
  109715. */
  109716. isReady(): boolean;
  109717. /**
  109718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  109719. * @returns True if it has been started, otherwise false.
  109720. */
  109721. isStarted(): boolean;
  109722. /**
  109723. * Starts the particle system and begins to emit
  109724. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  109725. */
  109726. start(delay?: number): void;
  109727. /**
  109728. * Stops the particle system.
  109729. */
  109730. stop(): void;
  109731. /**
  109732. * Remove all active particles
  109733. */
  109734. reset(): void;
  109735. /**
  109736. * Returns the string "GPUParticleSystem"
  109737. * @returns a string containing the class name
  109738. */
  109739. getClassName(): string;
  109740. private _colorGradientsTexture;
  109741. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  109742. /**
  109743. * Adds a new color gradient
  109744. * @param gradient defines the gradient to use (between 0 and 1)
  109745. * @param color1 defines the color to affect to the specified gradient
  109746. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  109747. * @returns the current particle system
  109748. */
  109749. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  109750. /**
  109751. * Remove a specific color gradient
  109752. * @param gradient defines the gradient to remove
  109753. * @returns the current particle system
  109754. */
  109755. removeColorGradient(gradient: number): GPUParticleSystem;
  109756. private _angularSpeedGradientsTexture;
  109757. private _sizeGradientsTexture;
  109758. private _velocityGradientsTexture;
  109759. private _limitVelocityGradientsTexture;
  109760. private _dragGradientsTexture;
  109761. private _addFactorGradient;
  109762. /**
  109763. * Adds a new size gradient
  109764. * @param gradient defines the gradient to use (between 0 and 1)
  109765. * @param factor defines the size factor to affect to the specified gradient
  109766. * @returns the current particle system
  109767. */
  109768. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  109769. /**
  109770. * Remove a specific size gradient
  109771. * @param gradient defines the gradient to remove
  109772. * @returns the current particle system
  109773. */
  109774. removeSizeGradient(gradient: number): GPUParticleSystem;
  109775. /**
  109776. * Adds a new angular speed gradient
  109777. * @param gradient defines the gradient to use (between 0 and 1)
  109778. * @param factor defines the angular speed to affect to the specified gradient
  109779. * @returns the current particle system
  109780. */
  109781. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  109782. /**
  109783. * Remove a specific angular speed gradient
  109784. * @param gradient defines the gradient to remove
  109785. * @returns the current particle system
  109786. */
  109787. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  109788. /**
  109789. * Adds a new velocity gradient
  109790. * @param gradient defines the gradient to use (between 0 and 1)
  109791. * @param factor defines the velocity to affect to the specified gradient
  109792. * @returns the current particle system
  109793. */
  109794. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109795. /**
  109796. * Remove a specific velocity gradient
  109797. * @param gradient defines the gradient to remove
  109798. * @returns the current particle system
  109799. */
  109800. removeVelocityGradient(gradient: number): GPUParticleSystem;
  109801. /**
  109802. * Adds a new limit velocity gradient
  109803. * @param gradient defines the gradient to use (between 0 and 1)
  109804. * @param factor defines the limit velocity value to affect to the specified gradient
  109805. * @returns the current particle system
  109806. */
  109807. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109808. /**
  109809. * Remove a specific limit velocity gradient
  109810. * @param gradient defines the gradient to remove
  109811. * @returns the current particle system
  109812. */
  109813. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  109814. /**
  109815. * Adds a new drag gradient
  109816. * @param gradient defines the gradient to use (between 0 and 1)
  109817. * @param factor defines the drag value to affect to the specified gradient
  109818. * @returns the current particle system
  109819. */
  109820. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  109821. /**
  109822. * Remove a specific drag gradient
  109823. * @param gradient defines the gradient to remove
  109824. * @returns the current particle system
  109825. */
  109826. removeDragGradient(gradient: number): GPUParticleSystem;
  109827. /**
  109828. * Not supported by GPUParticleSystem
  109829. * @param gradient defines the gradient to use (between 0 and 1)
  109830. * @param factor defines the emit rate value to affect to the specified gradient
  109831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109832. * @returns the current particle system
  109833. */
  109834. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109835. /**
  109836. * Not supported by GPUParticleSystem
  109837. * @param gradient defines the gradient to remove
  109838. * @returns the current particle system
  109839. */
  109840. removeEmitRateGradient(gradient: number): IParticleSystem;
  109841. /**
  109842. * Not supported by GPUParticleSystem
  109843. * @param gradient defines the gradient to use (between 0 and 1)
  109844. * @param factor defines the start size value to affect to the specified gradient
  109845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109846. * @returns the current particle system
  109847. */
  109848. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109849. /**
  109850. * Not supported by GPUParticleSystem
  109851. * @param gradient defines the gradient to remove
  109852. * @returns the current particle system
  109853. */
  109854. removeStartSizeGradient(gradient: number): IParticleSystem;
  109855. /**
  109856. * Not supported by GPUParticleSystem
  109857. * @param gradient defines the gradient to use (between 0 and 1)
  109858. * @param min defines the color remap minimal range
  109859. * @param max defines the color remap maximal range
  109860. * @returns the current particle system
  109861. */
  109862. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109863. /**
  109864. * Not supported by GPUParticleSystem
  109865. * @param gradient defines the gradient to remove
  109866. * @returns the current particle system
  109867. */
  109868. removeColorRemapGradient(): IParticleSystem;
  109869. /**
  109870. * Not supported by GPUParticleSystem
  109871. * @param gradient defines the gradient to use (between 0 and 1)
  109872. * @param min defines the alpha remap minimal range
  109873. * @param max defines the alpha remap maximal range
  109874. * @returns the current particle system
  109875. */
  109876. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109877. /**
  109878. * Not supported by GPUParticleSystem
  109879. * @param gradient defines the gradient to remove
  109880. * @returns the current particle system
  109881. */
  109882. removeAlphaRemapGradient(): IParticleSystem;
  109883. /**
  109884. * Not supported by GPUParticleSystem
  109885. * @param gradient defines the gradient to use (between 0 and 1)
  109886. * @param color defines the color to affect to the specified gradient
  109887. * @returns the current particle system
  109888. */
  109889. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  109890. /**
  109891. * Not supported by GPUParticleSystem
  109892. * @param gradient defines the gradient to remove
  109893. * @returns the current particle system
  109894. */
  109895. removeRampGradient(): IParticleSystem;
  109896. /**
  109897. * Not supported by GPUParticleSystem
  109898. * @returns the list of ramp gradients
  109899. */
  109900. getRampGradients(): Nullable<Array<Color3Gradient>>;
  109901. /**
  109902. * Not supported by GPUParticleSystem
  109903. * Gets or sets a boolean indicating that ramp gradients must be used
  109904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  109905. */
  109906. useRampGradients: boolean;
  109907. /**
  109908. * Not supported by GPUParticleSystem
  109909. * @param gradient defines the gradient to use (between 0 and 1)
  109910. * @param factor defines the life time factor to affect to the specified gradient
  109911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109912. * @returns the current particle system
  109913. */
  109914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109915. /**
  109916. * Not supported by GPUParticleSystem
  109917. * @param gradient defines the gradient to remove
  109918. * @returns the current particle system
  109919. */
  109920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  109921. /**
  109922. * Instantiates a GPU particle system.
  109923. * 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.
  109924. * @param name The name of the particle system
  109925. * @param options The options used to create the system
  109926. * @param scene The scene the particle system belongs to
  109927. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109928. */
  109929. constructor(name: string, options: Partial<{
  109930. capacity: number;
  109931. randomTextureSize: number;
  109932. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  109933. protected _reset(): void;
  109934. private _createUpdateVAO;
  109935. private _createRenderVAO;
  109936. private _initialize;
  109937. /** @hidden */
  109938. _recreateUpdateEffect(): void;
  109939. /** @hidden */
  109940. _recreateRenderEffect(): void;
  109941. /**
  109942. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109943. * @param preWarm defines if we are in the pre-warmimg phase
  109944. */
  109945. animate(preWarm?: boolean): void;
  109946. private _createFactorGradientTexture;
  109947. private _createSizeGradientTexture;
  109948. private _createAngularSpeedGradientTexture;
  109949. private _createVelocityGradientTexture;
  109950. private _createLimitVelocityGradientTexture;
  109951. private _createDragGradientTexture;
  109952. private _createColorGradientTexture;
  109953. /**
  109954. * Renders the particle system in its current state
  109955. * @param preWarm defines if the system should only update the particles but not render them
  109956. * @returns the current number of particles
  109957. */
  109958. render(preWarm?: boolean): number;
  109959. /**
  109960. * Rebuilds the particle system
  109961. */
  109962. rebuild(): void;
  109963. private _releaseBuffers;
  109964. private _releaseVAOs;
  109965. /**
  109966. * Disposes the particle system and free the associated resources
  109967. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109968. */
  109969. dispose(disposeTexture?: boolean): void;
  109970. /**
  109971. * Clones the particle system.
  109972. * @param name The name of the cloned object
  109973. * @param newEmitter The new emitter to use
  109974. * @returns the cloned particle system
  109975. */
  109976. clone(name: string, newEmitter: any): GPUParticleSystem;
  109977. /**
  109978. * Serializes the particle system to a JSON object.
  109979. * @returns the JSON object
  109980. */
  109981. serialize(): any;
  109982. /**
  109983. * Parses a JSON object to create a GPU particle system.
  109984. * @param parsedParticleSystem The JSON object to parse
  109985. * @param scene The scene to create the particle system in
  109986. * @param rootUrl The root url to use to load external dependencies like texture
  109987. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109988. * @returns the parsed GPU particle system
  109989. */
  109990. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  109991. }
  109992. }
  109993. declare module BABYLON {
  109994. /**
  109995. * Represents a set of particle systems working together to create a specific effect
  109996. */
  109997. export class ParticleSystemSet implements IDisposable {
  109998. private _emitterCreationOptions;
  109999. private _emitterNode;
  110000. /**
  110001. * Gets the particle system list
  110002. */
  110003. systems: IParticleSystem[];
  110004. /**
  110005. * Gets the emitter node used with this set
  110006. */
  110007. readonly emitterNode: Nullable<TransformNode>;
  110008. /**
  110009. * Creates a new emitter mesh as a sphere
  110010. * @param options defines the options used to create the sphere
  110011. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110012. * @param scene defines the hosting scene
  110013. */
  110014. setEmitterAsSphere(options: {
  110015. diameter: number;
  110016. segments: number;
  110017. color: Color3;
  110018. }, renderingGroupId: number, scene: Scene): void;
  110019. /**
  110020. * Starts all particle systems of the set
  110021. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110022. */
  110023. start(emitter?: AbstractMesh): void;
  110024. /**
  110025. * Release all associated resources
  110026. */
  110027. dispose(): void;
  110028. /**
  110029. * Serialize the set into a JSON compatible object
  110030. * @returns a JSON compatible representation of the set
  110031. */
  110032. serialize(): any;
  110033. /**
  110034. * Parse a new ParticleSystemSet from a serialized source
  110035. * @param data defines a JSON compatible representation of the set
  110036. * @param scene defines the hosting scene
  110037. * @param gpu defines if we want GPU particles or CPU particles
  110038. * @returns a new ParticleSystemSet
  110039. */
  110040. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110041. }
  110042. }
  110043. declare module BABYLON {
  110044. /**
  110045. * This class is made for on one-liner static method to help creating particle system set.
  110046. */
  110047. export class ParticleHelper {
  110048. /**
  110049. * Gets or sets base Assets URL
  110050. */
  110051. static BaseAssetsUrl: string;
  110052. /**
  110053. * Create a default particle system that you can tweak
  110054. * @param emitter defines the emitter to use
  110055. * @param capacity defines the system capacity (default is 500 particles)
  110056. * @param scene defines the hosting scene
  110057. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110058. * @returns the new Particle system
  110059. */
  110060. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110061. /**
  110062. * This is the main static method (one-liner) of this helper to create different particle systems
  110063. * @param type This string represents the type to the particle system to create
  110064. * @param scene The scene where the particle system should live
  110065. * @param gpu If the system will use gpu
  110066. * @returns the ParticleSystemSet created
  110067. */
  110068. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110069. /**
  110070. * Static function used to export a particle system to a ParticleSystemSet variable.
  110071. * Please note that the emitter shape is not exported
  110072. * @param systems defines the particle systems to export
  110073. * @returns the created particle system set
  110074. */
  110075. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110076. }
  110077. }
  110078. declare module BABYLON {
  110079. interface Engine {
  110080. /**
  110081. * Create an effect to use with particle systems.
  110082. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110083. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110084. * @param uniformsNames defines a list of attribute names
  110085. * @param samplers defines an array of string used to represent textures
  110086. * @param defines defines the string containing the defines to use to compile the shaders
  110087. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110088. * @param onCompiled defines a function to call when the effect creation is successful
  110089. * @param onError defines a function to call when the effect creation has failed
  110090. * @returns the new Effect
  110091. */
  110092. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110093. }
  110094. interface Mesh {
  110095. /**
  110096. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110097. * @returns an array of IParticleSystem
  110098. */
  110099. getEmittedParticleSystems(): IParticleSystem[];
  110100. /**
  110101. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110102. * @returns an array of IParticleSystem
  110103. */
  110104. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110105. }
  110106. /**
  110107. * @hidden
  110108. */
  110109. export var _IDoNeedToBeInTheBuild: number;
  110110. }
  110111. declare module BABYLON {
  110112. interface Scene {
  110113. /** @hidden (Backing field) */
  110114. _physicsEngine: Nullable<IPhysicsEngine>;
  110115. /**
  110116. * Gets the current physics engine
  110117. * @returns a IPhysicsEngine or null if none attached
  110118. */
  110119. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110120. /**
  110121. * Enables physics to the current scene
  110122. * @param gravity defines the scene's gravity for the physics engine
  110123. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110124. * @return a boolean indicating if the physics engine was initialized
  110125. */
  110126. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110127. /**
  110128. * Disables and disposes the physics engine associated with the scene
  110129. */
  110130. disablePhysicsEngine(): void;
  110131. /**
  110132. * Gets a boolean indicating if there is an active physics engine
  110133. * @returns a boolean indicating if there is an active physics engine
  110134. */
  110135. isPhysicsEnabled(): boolean;
  110136. /**
  110137. * Deletes a physics compound impostor
  110138. * @param compound defines the compound to delete
  110139. */
  110140. deleteCompoundImpostor(compound: any): void;
  110141. /**
  110142. * An event triggered when physic simulation is about to be run
  110143. */
  110144. onBeforePhysicsObservable: Observable<Scene>;
  110145. /**
  110146. * An event triggered when physic simulation has been done
  110147. */
  110148. onAfterPhysicsObservable: Observable<Scene>;
  110149. }
  110150. interface AbstractMesh {
  110151. /** @hidden */
  110152. _physicsImpostor: Nullable<PhysicsImpostor>;
  110153. /**
  110154. * Gets or sets impostor used for physic simulation
  110155. * @see http://doc.babylonjs.com/features/physics_engine
  110156. */
  110157. physicsImpostor: Nullable<PhysicsImpostor>;
  110158. /**
  110159. * Gets the current physics impostor
  110160. * @see http://doc.babylonjs.com/features/physics_engine
  110161. * @returns a physics impostor or null
  110162. */
  110163. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110164. /** Apply a physic impulse to the mesh
  110165. * @param force defines the force to apply
  110166. * @param contactPoint defines where to apply the force
  110167. * @returns the current mesh
  110168. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110169. */
  110170. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110171. /**
  110172. * Creates a physic joint between two meshes
  110173. * @param otherMesh defines the other mesh to use
  110174. * @param pivot1 defines the pivot to use on this mesh
  110175. * @param pivot2 defines the pivot to use on the other mesh
  110176. * @param options defines additional options (can be plugin dependent)
  110177. * @returns the current mesh
  110178. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110179. */
  110180. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110181. /** @hidden */
  110182. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110183. }
  110184. /**
  110185. * Defines the physics engine scene component responsible to manage a physics engine
  110186. */
  110187. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110188. /**
  110189. * The component name helpful to identify the component in the list of scene components.
  110190. */
  110191. readonly name: string;
  110192. /**
  110193. * The scene the component belongs to.
  110194. */
  110195. scene: Scene;
  110196. /**
  110197. * Creates a new instance of the component for the given scene
  110198. * @param scene Defines the scene to register the component in
  110199. */
  110200. constructor(scene: Scene);
  110201. /**
  110202. * Registers the component in a given scene
  110203. */
  110204. register(): void;
  110205. /**
  110206. * Rebuilds the elements related to this component in case of
  110207. * context lost for instance.
  110208. */
  110209. rebuild(): void;
  110210. /**
  110211. * Disposes the component and the associated ressources
  110212. */
  110213. dispose(): void;
  110214. }
  110215. }
  110216. declare module BABYLON {
  110217. /**
  110218. * A helper for physics simulations
  110219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110220. */
  110221. export class PhysicsHelper {
  110222. private _scene;
  110223. private _physicsEngine;
  110224. /**
  110225. * Initializes the Physics helper
  110226. * @param scene Babylon.js scene
  110227. */
  110228. constructor(scene: Scene);
  110229. /**
  110230. * Applies a radial explosion impulse
  110231. * @param origin the origin of the explosion
  110232. * @param radiusOrEventOptions the radius or the options of radial explosion
  110233. * @param strength the explosion strength
  110234. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110235. * @returns A physics radial explosion event, or null
  110236. */
  110237. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110238. /**
  110239. * Applies a radial explosion force
  110240. * @param origin the origin of the explosion
  110241. * @param radiusOrEventOptions the radius or the options of radial explosion
  110242. * @param strength the explosion strength
  110243. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110244. * @returns A physics radial explosion event, or null
  110245. */
  110246. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110247. /**
  110248. * Creates a gravitational field
  110249. * @param origin the origin of the explosion
  110250. * @param radiusOrEventOptions the radius or the options of radial explosion
  110251. * @param strength the explosion strength
  110252. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110253. * @returns A physics gravitational field event, or null
  110254. */
  110255. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110256. /**
  110257. * Creates a physics updraft event
  110258. * @param origin the origin of the updraft
  110259. * @param radiusOrEventOptions the radius or the options of the updraft
  110260. * @param strength the strength of the updraft
  110261. * @param height the height of the updraft
  110262. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110263. * @returns A physics updraft event, or null
  110264. */
  110265. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110266. /**
  110267. * Creates a physics vortex event
  110268. * @param origin the of the vortex
  110269. * @param radiusOrEventOptions the radius or the options of the vortex
  110270. * @param strength the strength of the vortex
  110271. * @param height the height of the vortex
  110272. * @returns a Physics vortex event, or null
  110273. * A physics vortex event or null
  110274. */
  110275. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110276. }
  110277. /**
  110278. * Represents a physics radial explosion event
  110279. */
  110280. class PhysicsRadialExplosionEvent {
  110281. private _scene;
  110282. private _options;
  110283. private _sphere;
  110284. private _dataFetched;
  110285. /**
  110286. * Initializes a radial explosioin event
  110287. * @param _scene BabylonJS scene
  110288. * @param _options The options for the vortex event
  110289. */
  110290. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110291. /**
  110292. * Returns the data related to the radial explosion event (sphere).
  110293. * @returns The radial explosion event data
  110294. */
  110295. getData(): PhysicsRadialExplosionEventData;
  110296. /**
  110297. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110298. * @param impostor A physics imposter
  110299. * @param origin the origin of the explosion
  110300. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110301. */
  110302. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110303. /**
  110304. * Triggers affecterd impostors callbacks
  110305. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110306. */
  110307. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110308. /**
  110309. * Disposes the sphere.
  110310. * @param force Specifies if the sphere should be disposed by force
  110311. */
  110312. dispose(force?: boolean): void;
  110313. /*** Helpers ***/
  110314. private _prepareSphere;
  110315. private _intersectsWithSphere;
  110316. }
  110317. /**
  110318. * Represents a gravitational field event
  110319. */
  110320. class PhysicsGravitationalFieldEvent {
  110321. private _physicsHelper;
  110322. private _scene;
  110323. private _origin;
  110324. private _options;
  110325. private _tickCallback;
  110326. private _sphere;
  110327. private _dataFetched;
  110328. /**
  110329. * Initializes the physics gravitational field event
  110330. * @param _physicsHelper A physics helper
  110331. * @param _scene BabylonJS scene
  110332. * @param _origin The origin position of the gravitational field event
  110333. * @param _options The options for the vortex event
  110334. */
  110335. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110336. /**
  110337. * Returns the data related to the gravitational field event (sphere).
  110338. * @returns A gravitational field event
  110339. */
  110340. getData(): PhysicsGravitationalFieldEventData;
  110341. /**
  110342. * Enables the gravitational field.
  110343. */
  110344. enable(): void;
  110345. /**
  110346. * Disables the gravitational field.
  110347. */
  110348. disable(): void;
  110349. /**
  110350. * Disposes the sphere.
  110351. * @param force The force to dispose from the gravitational field event
  110352. */
  110353. dispose(force?: boolean): void;
  110354. private _tick;
  110355. }
  110356. /**
  110357. * Represents a physics updraft event
  110358. */
  110359. class PhysicsUpdraftEvent {
  110360. private _scene;
  110361. private _origin;
  110362. private _options;
  110363. private _physicsEngine;
  110364. private _originTop;
  110365. private _originDirection;
  110366. private _tickCallback;
  110367. private _cylinder;
  110368. private _cylinderPosition;
  110369. private _dataFetched;
  110370. /**
  110371. * Initializes the physics updraft event
  110372. * @param _scene BabylonJS scene
  110373. * @param _origin The origin position of the updraft
  110374. * @param _options The options for the updraft event
  110375. */
  110376. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110377. /**
  110378. * Returns the data related to the updraft event (cylinder).
  110379. * @returns A physics updraft event
  110380. */
  110381. getData(): PhysicsUpdraftEventData;
  110382. /**
  110383. * Enables the updraft.
  110384. */
  110385. enable(): void;
  110386. /**
  110387. * Disables the updraft.
  110388. */
  110389. disable(): void;
  110390. /**
  110391. * Disposes the cylinder.
  110392. * @param force Specifies if the updraft should be disposed by force
  110393. */
  110394. dispose(force?: boolean): void;
  110395. private getImpostorHitData;
  110396. private _tick;
  110397. /*** Helpers ***/
  110398. private _prepareCylinder;
  110399. private _intersectsWithCylinder;
  110400. }
  110401. /**
  110402. * Represents a physics vortex event
  110403. */
  110404. class PhysicsVortexEvent {
  110405. private _scene;
  110406. private _origin;
  110407. private _options;
  110408. private _physicsEngine;
  110409. private _originTop;
  110410. private _tickCallback;
  110411. private _cylinder;
  110412. private _cylinderPosition;
  110413. private _dataFetched;
  110414. /**
  110415. * Initializes the physics vortex event
  110416. * @param _scene The BabylonJS scene
  110417. * @param _origin The origin position of the vortex
  110418. * @param _options The options for the vortex event
  110419. */
  110420. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110421. /**
  110422. * Returns the data related to the vortex event (cylinder).
  110423. * @returns The physics vortex event data
  110424. */
  110425. getData(): PhysicsVortexEventData;
  110426. /**
  110427. * Enables the vortex.
  110428. */
  110429. enable(): void;
  110430. /**
  110431. * Disables the cortex.
  110432. */
  110433. disable(): void;
  110434. /**
  110435. * Disposes the sphere.
  110436. * @param force
  110437. */
  110438. dispose(force?: boolean): void;
  110439. private getImpostorHitData;
  110440. private _tick;
  110441. /*** Helpers ***/
  110442. private _prepareCylinder;
  110443. private _intersectsWithCylinder;
  110444. }
  110445. /**
  110446. * Options fot the radial explosion event
  110447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110448. */
  110449. export class PhysicsRadialExplosionEventOptions {
  110450. /**
  110451. * The radius of the sphere for the radial explosion.
  110452. */
  110453. radius: number;
  110454. /**
  110455. * The strenth of the explosion.
  110456. */
  110457. strength: number;
  110458. /**
  110459. * The strenght of the force in correspondence to the distance of the affected object
  110460. */
  110461. falloff: PhysicsRadialImpulseFalloff;
  110462. /**
  110463. * Sphere options for the radial explosion.
  110464. */
  110465. sphere: {
  110466. segments: number;
  110467. diameter: number;
  110468. };
  110469. /**
  110470. * Sphere options for the radial explosion.
  110471. */
  110472. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110473. }
  110474. /**
  110475. * Options fot the updraft event
  110476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110477. */
  110478. export class PhysicsUpdraftEventOptions {
  110479. /**
  110480. * The radius of the cylinder for the vortex
  110481. */
  110482. radius: number;
  110483. /**
  110484. * The strenth of the updraft.
  110485. */
  110486. strength: number;
  110487. /**
  110488. * The height of the cylinder for the updraft.
  110489. */
  110490. height: number;
  110491. /**
  110492. * The mode for the the updraft.
  110493. */
  110494. updraftMode: PhysicsUpdraftMode;
  110495. }
  110496. /**
  110497. * Options fot the vortex event
  110498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110499. */
  110500. export class PhysicsVortexEventOptions {
  110501. /**
  110502. * The radius of the cylinder for the vortex
  110503. */
  110504. radius: number;
  110505. /**
  110506. * The strenth of the vortex.
  110507. */
  110508. strength: number;
  110509. /**
  110510. * The height of the cylinder for the vortex.
  110511. */
  110512. height: number;
  110513. /**
  110514. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  110515. */
  110516. centripetalForceThreshold: number;
  110517. /**
  110518. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  110519. */
  110520. centripetalForceMultiplier: number;
  110521. /**
  110522. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  110523. */
  110524. centrifugalForceMultiplier: number;
  110525. /**
  110526. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  110527. */
  110528. updraftForceMultiplier: number;
  110529. }
  110530. /**
  110531. * The strenght of the force in correspondence to the distance of the affected object
  110532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110533. */
  110534. export enum PhysicsRadialImpulseFalloff {
  110535. /** Defines that impulse is constant in strength across it's whole radius */
  110536. Constant = 0,
  110537. /** Defines that impulse gets weaker if it's further from the origin */
  110538. Linear = 1
  110539. }
  110540. /**
  110541. * The strength of the force in correspondence to the distance of the affected object
  110542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110543. */
  110544. export enum PhysicsUpdraftMode {
  110545. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110546. Center = 0,
  110547. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110548. Perpendicular = 1
  110549. }
  110550. /**
  110551. * Interface for a physics hit data
  110552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110553. */
  110554. export interface PhysicsHitData {
  110555. /**
  110556. * The force applied at the contact point
  110557. */
  110558. force: Vector3;
  110559. /**
  110560. * The contact point
  110561. */
  110562. contactPoint: Vector3;
  110563. /**
  110564. * The distance from the origin to the contact point
  110565. */
  110566. distanceFromOrigin: number;
  110567. }
  110568. /**
  110569. * Interface for radial explosion event data
  110570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110571. */
  110572. export interface PhysicsRadialExplosionEventData {
  110573. /**
  110574. * A sphere used for the radial explosion event
  110575. */
  110576. sphere: Mesh;
  110577. }
  110578. /**
  110579. * Interface for gravitational field event data
  110580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110581. */
  110582. export interface PhysicsGravitationalFieldEventData {
  110583. /**
  110584. * A sphere mesh used for the gravitational field event
  110585. */
  110586. sphere: Mesh;
  110587. }
  110588. /**
  110589. * Interface for updraft event data
  110590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110591. */
  110592. export interface PhysicsUpdraftEventData {
  110593. /**
  110594. * A cylinder used for the updraft event
  110595. */
  110596. cylinder: Mesh;
  110597. }
  110598. /**
  110599. * Interface for vortex event data
  110600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110601. */
  110602. export interface PhysicsVortexEventData {
  110603. /**
  110604. * A cylinder used for the vortex event
  110605. */
  110606. cylinder: Mesh;
  110607. }
  110608. /**
  110609. * Interface for an affected physics impostor
  110610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110611. */
  110612. export interface PhysicsAffectedImpostorWithData {
  110613. /**
  110614. * The impostor affected by the effect
  110615. */
  110616. impostor: PhysicsImpostor;
  110617. /**
  110618. * The data about the hit/horce from the explosion
  110619. */
  110620. hitData: PhysicsHitData;
  110621. }
  110622. }
  110623. declare module BABYLON {
  110624. /** @hidden */
  110625. export var blackAndWhitePixelShader: {
  110626. name: string;
  110627. shader: string;
  110628. };
  110629. }
  110630. declare module BABYLON {
  110631. /**
  110632. * Post process used to render in black and white
  110633. */
  110634. export class BlackAndWhitePostProcess extends PostProcess {
  110635. /**
  110636. * Linear about to convert he result to black and white (default: 1)
  110637. */
  110638. degree: number;
  110639. /**
  110640. * Creates a black and white post process
  110641. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  110642. * @param name The name of the effect.
  110643. * @param options The required width/height ratio to downsize to before computing the render pass.
  110644. * @param camera The camera to apply the render pass to.
  110645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110646. * @param engine The engine which the post process will be applied. (default: current engine)
  110647. * @param reusable If the post process can be reused on the same frame. (default: false)
  110648. */
  110649. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110650. }
  110651. }
  110652. declare module BABYLON {
  110653. /**
  110654. * This represents a set of one or more post processes in Babylon.
  110655. * A post process can be used to apply a shader to a texture after it is rendered.
  110656. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110657. */
  110658. export class PostProcessRenderEffect {
  110659. private _postProcesses;
  110660. private _getPostProcesses;
  110661. private _singleInstance;
  110662. private _cameras;
  110663. private _indicesForCamera;
  110664. /**
  110665. * Name of the effect
  110666. * @hidden
  110667. */
  110668. _name: string;
  110669. /**
  110670. * Instantiates a post process render effect.
  110671. * A post process can be used to apply a shader to a texture after it is rendered.
  110672. * @param engine The engine the effect is tied to
  110673. * @param name The name of the effect
  110674. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  110675. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  110676. */
  110677. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  110678. /**
  110679. * Checks if all the post processes in the effect are supported.
  110680. */
  110681. readonly isSupported: boolean;
  110682. /**
  110683. * Updates the current state of the effect
  110684. * @hidden
  110685. */
  110686. _update(): void;
  110687. /**
  110688. * Attaches the effect on cameras
  110689. * @param cameras The camera to attach to.
  110690. * @hidden
  110691. */
  110692. _attachCameras(cameras: Camera): void;
  110693. /**
  110694. * Attaches the effect on cameras
  110695. * @param cameras The camera to attach to.
  110696. * @hidden
  110697. */
  110698. _attachCameras(cameras: Camera[]): void;
  110699. /**
  110700. * Detatches the effect on cameras
  110701. * @param cameras The camera to detatch from.
  110702. * @hidden
  110703. */
  110704. _detachCameras(cameras: Camera): void;
  110705. /**
  110706. * Detatches the effect on cameras
  110707. * @param cameras The camera to detatch from.
  110708. * @hidden
  110709. */
  110710. _detachCameras(cameras: Camera[]): void;
  110711. /**
  110712. * Enables the effect on given cameras
  110713. * @param cameras The camera to enable.
  110714. * @hidden
  110715. */
  110716. _enable(cameras: Camera): void;
  110717. /**
  110718. * Enables the effect on given cameras
  110719. * @param cameras The camera to enable.
  110720. * @hidden
  110721. */
  110722. _enable(cameras: Nullable<Camera[]>): void;
  110723. /**
  110724. * Disables the effect on the given cameras
  110725. * @param cameras The camera to disable.
  110726. * @hidden
  110727. */
  110728. _disable(cameras: Camera): void;
  110729. /**
  110730. * Disables the effect on the given cameras
  110731. * @param cameras The camera to disable.
  110732. * @hidden
  110733. */
  110734. _disable(cameras: Nullable<Camera[]>): void;
  110735. /**
  110736. * Gets a list of the post processes contained in the effect.
  110737. * @param camera The camera to get the post processes on.
  110738. * @returns The list of the post processes in the effect.
  110739. */
  110740. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  110741. }
  110742. }
  110743. declare module BABYLON {
  110744. /** @hidden */
  110745. export var extractHighlightsPixelShader: {
  110746. name: string;
  110747. shader: string;
  110748. };
  110749. }
  110750. declare module BABYLON {
  110751. /**
  110752. * 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.
  110753. */
  110754. export class ExtractHighlightsPostProcess extends PostProcess {
  110755. /**
  110756. * The luminance threshold, pixels below this value will be set to black.
  110757. */
  110758. threshold: number;
  110759. /** @hidden */
  110760. _exposure: number;
  110761. /**
  110762. * Post process which has the input texture to be used when performing highlight extraction
  110763. * @hidden
  110764. */
  110765. _inputPostProcess: Nullable<PostProcess>;
  110766. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110767. }
  110768. }
  110769. declare module BABYLON {
  110770. /** @hidden */
  110771. export var bloomMergePixelShader: {
  110772. name: string;
  110773. shader: string;
  110774. };
  110775. }
  110776. declare module BABYLON {
  110777. /**
  110778. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110779. */
  110780. export class BloomMergePostProcess extends PostProcess {
  110781. /** Weight of the bloom to be added to the original input. */
  110782. weight: number;
  110783. /**
  110784. * Creates a new instance of @see BloomMergePostProcess
  110785. * @param name The name of the effect.
  110786. * @param originalFromInput Post process which's input will be used for the merge.
  110787. * @param blurred Blurred highlights post process which's output will be used.
  110788. * @param weight Weight of the bloom to be added to the original input.
  110789. * @param options The required width/height ratio to downsize to before computing the render pass.
  110790. * @param camera The camera to apply the render pass to.
  110791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110792. * @param engine The engine which the post process will be applied. (default: current engine)
  110793. * @param reusable If the post process can be reused on the same frame. (default: false)
  110794. * @param textureType Type of textures used when performing the post process. (default: 0)
  110795. * @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)
  110796. */
  110797. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  110798. /** Weight of the bloom to be added to the original input. */
  110799. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110800. }
  110801. }
  110802. declare module BABYLON {
  110803. /**
  110804. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  110805. */
  110806. export class BloomEffect extends PostProcessRenderEffect {
  110807. private bloomScale;
  110808. /**
  110809. * @hidden Internal
  110810. */
  110811. _effects: Array<PostProcess>;
  110812. /**
  110813. * @hidden Internal
  110814. */
  110815. _downscale: ExtractHighlightsPostProcess;
  110816. private _blurX;
  110817. private _blurY;
  110818. private _merge;
  110819. /**
  110820. * The luminance threshold to find bright areas of the image to bloom.
  110821. */
  110822. threshold: number;
  110823. /**
  110824. * The strength of the bloom.
  110825. */
  110826. weight: number;
  110827. /**
  110828. * Specifies the size of the bloom blur kernel, relative to the final output size
  110829. */
  110830. kernel: number;
  110831. /**
  110832. * Creates a new instance of @see BloomEffect
  110833. * @param scene The scene the effect belongs to.
  110834. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  110835. * @param bloomKernel The size of the kernel to be used when applying the blur.
  110836. * @param bloomWeight The the strength of bloom.
  110837. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110838. * @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)
  110839. */
  110840. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  110841. /**
  110842. * Disposes each of the internal effects for a given camera.
  110843. * @param camera The camera to dispose the effect on.
  110844. */
  110845. disposeEffects(camera: Camera): void;
  110846. /**
  110847. * @hidden Internal
  110848. */
  110849. _updateEffects(): void;
  110850. /**
  110851. * Internal
  110852. * @returns if all the contained post processes are ready.
  110853. * @hidden
  110854. */
  110855. _isReady(): boolean;
  110856. }
  110857. }
  110858. declare module BABYLON {
  110859. /** @hidden */
  110860. export var chromaticAberrationPixelShader: {
  110861. name: string;
  110862. shader: string;
  110863. };
  110864. }
  110865. declare module BABYLON {
  110866. /**
  110867. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  110868. */
  110869. export class ChromaticAberrationPostProcess extends PostProcess {
  110870. /**
  110871. * The amount of seperation of rgb channels (default: 30)
  110872. */
  110873. aberrationAmount: number;
  110874. /**
  110875. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  110876. */
  110877. radialIntensity: number;
  110878. /**
  110879. * 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))
  110880. */
  110881. direction: Vector2;
  110882. /**
  110883. * 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))
  110884. */
  110885. centerPosition: Vector2;
  110886. /**
  110887. * Creates a new instance ChromaticAberrationPostProcess
  110888. * @param name The name of the effect.
  110889. * @param screenWidth The width of the screen to apply the effect on.
  110890. * @param screenHeight The height of the screen to apply the effect on.
  110891. * @param options The required width/height ratio to downsize to before computing the render pass.
  110892. * @param camera The camera to apply the render pass to.
  110893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110894. * @param engine The engine which the post process will be applied. (default: current engine)
  110895. * @param reusable If the post process can be reused on the same frame. (default: false)
  110896. * @param textureType Type of textures used when performing the post process. (default: 0)
  110897. * @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)
  110898. */
  110899. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110900. }
  110901. }
  110902. declare module BABYLON {
  110903. /** @hidden */
  110904. export var circleOfConfusionPixelShader: {
  110905. name: string;
  110906. shader: string;
  110907. };
  110908. }
  110909. declare module BABYLON {
  110910. /**
  110911. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  110912. */
  110913. export class CircleOfConfusionPostProcess extends PostProcess {
  110914. /**
  110915. * 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.
  110916. */
  110917. lensSize: number;
  110918. /**
  110919. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110920. */
  110921. fStop: number;
  110922. /**
  110923. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110924. */
  110925. focusDistance: number;
  110926. /**
  110927. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  110928. */
  110929. focalLength: number;
  110930. private _depthTexture;
  110931. /**
  110932. * Creates a new instance CircleOfConfusionPostProcess
  110933. * @param name The name of the effect.
  110934. * @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.
  110935. * @param options The required width/height ratio to downsize to before computing the render pass.
  110936. * @param camera The camera to apply the render pass to.
  110937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110938. * @param engine The engine which the post process will be applied. (default: current engine)
  110939. * @param reusable If the post process can be reused on the same frame. (default: false)
  110940. * @param textureType Type of textures used when performing the post process. (default: 0)
  110941. * @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)
  110942. */
  110943. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110944. /**
  110945. * 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.
  110946. */
  110947. depthTexture: RenderTargetTexture;
  110948. }
  110949. }
  110950. declare module BABYLON {
  110951. /** @hidden */
  110952. export var colorCorrectionPixelShader: {
  110953. name: string;
  110954. shader: string;
  110955. };
  110956. }
  110957. declare module BABYLON {
  110958. /**
  110959. *
  110960. * This post-process allows the modification of rendered colors by using
  110961. * a 'look-up table' (LUT). This effect is also called Color Grading.
  110962. *
  110963. * The object needs to be provided an url to a texture containing the color
  110964. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  110965. * Use an image editing software to tweak the LUT to match your needs.
  110966. *
  110967. * For an example of a color LUT, see here:
  110968. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  110969. * For explanations on color grading, see here:
  110970. * @see http://udn.epicgames.com/Three/ColorGrading.html
  110971. *
  110972. */
  110973. export class ColorCorrectionPostProcess extends PostProcess {
  110974. private _colorTableTexture;
  110975. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110976. }
  110977. }
  110978. declare module BABYLON {
  110979. /** @hidden */
  110980. export var convolutionPixelShader: {
  110981. name: string;
  110982. shader: string;
  110983. };
  110984. }
  110985. declare module BABYLON {
  110986. /**
  110987. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  110988. * input texture to perform effects such as edge detection or sharpening
  110989. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110990. */
  110991. export class ConvolutionPostProcess extends PostProcess {
  110992. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110993. kernel: number[];
  110994. /**
  110995. * Creates a new instance ConvolutionPostProcess
  110996. * @param name The name of the effect.
  110997. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  110998. * @param options The required width/height ratio to downsize to before computing the render pass.
  110999. * @param camera The camera to apply the render pass to.
  111000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111001. * @param engine The engine which the post process will be applied. (default: current engine)
  111002. * @param reusable If the post process can be reused on the same frame. (default: false)
  111003. * @param textureType Type of textures used when performing the post process. (default: 0)
  111004. */
  111005. constructor(name: string,
  111006. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111007. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111008. /**
  111009. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111010. */
  111011. static EdgeDetect0Kernel: number[];
  111012. /**
  111013. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111014. */
  111015. static EdgeDetect1Kernel: number[];
  111016. /**
  111017. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111018. */
  111019. static EdgeDetect2Kernel: number[];
  111020. /**
  111021. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111022. */
  111023. static SharpenKernel: number[];
  111024. /**
  111025. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111026. */
  111027. static EmbossKernel: number[];
  111028. /**
  111029. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111030. */
  111031. static GaussianKernel: number[];
  111032. }
  111033. }
  111034. declare module BABYLON {
  111035. /**
  111036. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111037. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111038. * based on samples that have a large difference in distance than the center pixel.
  111039. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111040. */
  111041. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111042. direction: Vector2;
  111043. /**
  111044. * Creates a new instance CircleOfConfusionPostProcess
  111045. * @param name The name of the effect.
  111046. * @param scene The scene the effect belongs to.
  111047. * @param direction The direction the blur should be applied.
  111048. * @param kernel The size of the kernel used to blur.
  111049. * @param options The required width/height ratio to downsize to before computing the render pass.
  111050. * @param camera The camera to apply the render pass to.
  111051. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111052. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111054. * @param engine The engine which the post process will be applied. (default: current engine)
  111055. * @param reusable If the post process can be reused on the same frame. (default: false)
  111056. * @param textureType Type of textures used when performing the post process. (default: 0)
  111057. * @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)
  111058. */
  111059. 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);
  111060. }
  111061. }
  111062. declare module BABYLON {
  111063. /** @hidden */
  111064. export var depthOfFieldMergePixelShader: {
  111065. name: string;
  111066. shader: string;
  111067. };
  111068. }
  111069. declare module BABYLON {
  111070. /**
  111071. * Options to be set when merging outputs from the default pipeline.
  111072. */
  111073. export class DepthOfFieldMergePostProcessOptions {
  111074. /**
  111075. * The original image to merge on top of
  111076. */
  111077. originalFromInput: PostProcess;
  111078. /**
  111079. * Parameters to perform the merge of the depth of field effect
  111080. */
  111081. depthOfField?: {
  111082. circleOfConfusion: PostProcess;
  111083. blurSteps: Array<PostProcess>;
  111084. };
  111085. /**
  111086. * Parameters to perform the merge of bloom effect
  111087. */
  111088. bloom?: {
  111089. blurred: PostProcess;
  111090. weight: number;
  111091. };
  111092. }
  111093. /**
  111094. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111095. */
  111096. export class DepthOfFieldMergePostProcess extends PostProcess {
  111097. private blurSteps;
  111098. /**
  111099. * Creates a new instance of DepthOfFieldMergePostProcess
  111100. * @param name The name of the effect.
  111101. * @param originalFromInput Post process which's input will be used for the merge.
  111102. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111103. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111104. * @param options The required width/height ratio to downsize to before computing the render pass.
  111105. * @param camera The camera to apply the render pass to.
  111106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111107. * @param engine The engine which the post process will be applied. (default: current engine)
  111108. * @param reusable If the post process can be reused on the same frame. (default: false)
  111109. * @param textureType Type of textures used when performing the post process. (default: 0)
  111110. * @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)
  111111. */
  111112. 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);
  111113. /**
  111114. * Updates the effect with the current post process compile time values and recompiles the shader.
  111115. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111116. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111117. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111118. * @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
  111119. * @param onCompiled Called when the shader has been compiled.
  111120. * @param onError Called if there is an error when compiling a shader.
  111121. */
  111122. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111123. }
  111124. }
  111125. declare module BABYLON {
  111126. /**
  111127. * Specifies the level of max blur that should be applied when using the depth of field effect
  111128. */
  111129. export enum DepthOfFieldEffectBlurLevel {
  111130. /**
  111131. * Subtle blur
  111132. */
  111133. Low = 0,
  111134. /**
  111135. * Medium blur
  111136. */
  111137. Medium = 1,
  111138. /**
  111139. * Large blur
  111140. */
  111141. High = 2
  111142. }
  111143. /**
  111144. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111145. */
  111146. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111147. private _circleOfConfusion;
  111148. /**
  111149. * @hidden Internal, blurs from high to low
  111150. */
  111151. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111152. private _depthOfFieldBlurY;
  111153. private _dofMerge;
  111154. /**
  111155. * @hidden Internal post processes in depth of field effect
  111156. */
  111157. _effects: Array<PostProcess>;
  111158. /**
  111159. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111160. */
  111161. focalLength: number;
  111162. /**
  111163. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111164. */
  111165. fStop: number;
  111166. /**
  111167. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111168. */
  111169. focusDistance: number;
  111170. /**
  111171. * 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.
  111172. */
  111173. lensSize: number;
  111174. /**
  111175. * Creates a new instance DepthOfFieldEffect
  111176. * @param scene The scene the effect belongs to.
  111177. * @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.
  111178. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111179. * @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)
  111180. */
  111181. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111182. /**
  111183. * 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.
  111184. */
  111185. depthTexture: RenderTargetTexture;
  111186. /**
  111187. * Disposes each of the internal effects for a given camera.
  111188. * @param camera The camera to dispose the effect on.
  111189. */
  111190. disposeEffects(camera: Camera): void;
  111191. /**
  111192. * @hidden Internal
  111193. */
  111194. _updateEffects(): void;
  111195. /**
  111196. * Internal
  111197. * @returns if all the contained post processes are ready.
  111198. * @hidden
  111199. */
  111200. _isReady(): boolean;
  111201. }
  111202. }
  111203. declare module BABYLON {
  111204. /** @hidden */
  111205. export var displayPassPixelShader: {
  111206. name: string;
  111207. shader: string;
  111208. };
  111209. }
  111210. declare module BABYLON {
  111211. /**
  111212. * DisplayPassPostProcess which produces an output the same as it's input
  111213. */
  111214. export class DisplayPassPostProcess extends PostProcess {
  111215. /**
  111216. * Creates the DisplayPassPostProcess
  111217. * @param name The name of the effect.
  111218. * @param options The required width/height ratio to downsize to before computing the render pass.
  111219. * @param camera The camera to apply the render pass to.
  111220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111221. * @param engine The engine which the post process will be applied. (default: current engine)
  111222. * @param reusable If the post process can be reused on the same frame. (default: false)
  111223. */
  111224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111225. }
  111226. }
  111227. declare module BABYLON {
  111228. /** @hidden */
  111229. export var filterPixelShader: {
  111230. name: string;
  111231. shader: string;
  111232. };
  111233. }
  111234. declare module BABYLON {
  111235. /**
  111236. * Applies a kernel filter to the image
  111237. */
  111238. export class FilterPostProcess extends PostProcess {
  111239. /** The matrix to be applied to the image */
  111240. kernelMatrix: Matrix;
  111241. /**
  111242. *
  111243. * @param name The name of the effect.
  111244. * @param kernelMatrix The matrix to be applied to the image
  111245. * @param options The required width/height ratio to downsize to before computing the render pass.
  111246. * @param camera The camera to apply the render pass to.
  111247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111248. * @param engine The engine which the post process will be applied. (default: current engine)
  111249. * @param reusable If the post process can be reused on the same frame. (default: false)
  111250. */
  111251. constructor(name: string,
  111252. /** The matrix to be applied to the image */
  111253. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111254. }
  111255. }
  111256. declare module BABYLON {
  111257. /** @hidden */
  111258. export var fxaaPixelShader: {
  111259. name: string;
  111260. shader: string;
  111261. };
  111262. }
  111263. declare module BABYLON {
  111264. /** @hidden */
  111265. export var fxaaVertexShader: {
  111266. name: string;
  111267. shader: string;
  111268. };
  111269. }
  111270. declare module BABYLON {
  111271. /**
  111272. * Fxaa post process
  111273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111274. */
  111275. export class FxaaPostProcess extends PostProcess {
  111276. /** @hidden */
  111277. texelWidth: number;
  111278. /** @hidden */
  111279. texelHeight: number;
  111280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111281. private _getDefines;
  111282. }
  111283. }
  111284. declare module BABYLON {
  111285. /** @hidden */
  111286. export var grainPixelShader: {
  111287. name: string;
  111288. shader: string;
  111289. };
  111290. }
  111291. declare module BABYLON {
  111292. /**
  111293. * The GrainPostProcess adds noise to the image at mid luminance levels
  111294. */
  111295. export class GrainPostProcess extends PostProcess {
  111296. /**
  111297. * The intensity of the grain added (default: 30)
  111298. */
  111299. intensity: number;
  111300. /**
  111301. * If the grain should be randomized on every frame
  111302. */
  111303. animated: boolean;
  111304. /**
  111305. * Creates a new instance of @see GrainPostProcess
  111306. * @param name The name of the effect.
  111307. * @param options The required width/height ratio to downsize to before computing the render pass.
  111308. * @param camera The camera to apply the render pass to.
  111309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111310. * @param engine The engine which the post process will be applied. (default: current engine)
  111311. * @param reusable If the post process can be reused on the same frame. (default: false)
  111312. * @param textureType Type of textures used when performing the post process. (default: 0)
  111313. * @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)
  111314. */
  111315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111316. }
  111317. }
  111318. declare module BABYLON {
  111319. /** @hidden */
  111320. export var highlightsPixelShader: {
  111321. name: string;
  111322. shader: string;
  111323. };
  111324. }
  111325. declare module BABYLON {
  111326. /**
  111327. * Extracts highlights from the image
  111328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111329. */
  111330. export class HighlightsPostProcess extends PostProcess {
  111331. /**
  111332. * Extracts highlights from the image
  111333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111334. * @param name The name of the effect.
  111335. * @param options The required width/height ratio to downsize to before computing the render pass.
  111336. * @param camera The camera to apply the render pass to.
  111337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111338. * @param engine The engine which the post process will be applied. (default: current engine)
  111339. * @param reusable If the post process can be reused on the same frame. (default: false)
  111340. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111341. */
  111342. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111343. }
  111344. }
  111345. declare module BABYLON {
  111346. /** @hidden */
  111347. export var mrtFragmentDeclaration: {
  111348. name: string;
  111349. shader: string;
  111350. };
  111351. }
  111352. declare module BABYLON {
  111353. /** @hidden */
  111354. export var geometryPixelShader: {
  111355. name: string;
  111356. shader: string;
  111357. };
  111358. }
  111359. declare module BABYLON {
  111360. /** @hidden */
  111361. export var geometryVertexShader: {
  111362. name: string;
  111363. shader: string;
  111364. };
  111365. }
  111366. declare module BABYLON {
  111367. /**
  111368. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111369. */
  111370. export class GeometryBufferRenderer {
  111371. /**
  111372. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111373. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111374. */
  111375. static readonly POSITION_TEXTURE_TYPE: number;
  111376. /**
  111377. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111378. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111379. */
  111380. static readonly VELOCITY_TEXTURE_TYPE: number;
  111381. /**
  111382. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111383. * in order to compute objects velocities when enableVelocity is set to "true"
  111384. * @hidden
  111385. */
  111386. _previousTransformationMatrices: {
  111387. [index: number]: Matrix;
  111388. };
  111389. private _scene;
  111390. private _multiRenderTarget;
  111391. private _ratio;
  111392. private _enablePosition;
  111393. private _enableVelocity;
  111394. private _positionIndex;
  111395. private _velocityIndex;
  111396. protected _effect: Effect;
  111397. protected _cachedDefines: string;
  111398. /**
  111399. * Set the render list (meshes to be rendered) used in the G buffer.
  111400. */
  111401. renderList: Mesh[];
  111402. /**
  111403. * Gets wether or not G buffer are supported by the running hardware.
  111404. * This requires draw buffer supports
  111405. */
  111406. readonly isSupported: boolean;
  111407. /**
  111408. * Returns the index of the given texture type in the G-Buffer textures array
  111409. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111410. * @returns the index of the given texture type in the G-Buffer textures array
  111411. */
  111412. getTextureIndex(textureType: number): number;
  111413. /**
  111414. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111415. */
  111416. /**
  111417. * Sets whether or not objects positions are enabled for the G buffer.
  111418. */
  111419. enablePosition: boolean;
  111420. /**
  111421. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111422. */
  111423. /**
  111424. * Sets wether or not objects velocities are enabled for the G buffer.
  111425. */
  111426. enableVelocity: boolean;
  111427. /**
  111428. * Gets the scene associated with the buffer.
  111429. */
  111430. readonly scene: Scene;
  111431. /**
  111432. * Gets the ratio used by the buffer during its creation.
  111433. * How big is the buffer related to the main canvas.
  111434. */
  111435. readonly ratio: number;
  111436. /** @hidden */
  111437. static _SceneComponentInitialization: (scene: Scene) => void;
  111438. /**
  111439. * Creates a new G Buffer for the scene
  111440. * @param scene The scene the buffer belongs to
  111441. * @param ratio How big is the buffer related to the main canvas.
  111442. */
  111443. constructor(scene: Scene, ratio?: number);
  111444. /**
  111445. * Checks wether everything is ready to render a submesh to the G buffer.
  111446. * @param subMesh the submesh to check readiness for
  111447. * @param useInstances is the mesh drawn using instance or not
  111448. * @returns true if ready otherwise false
  111449. */
  111450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111451. /**
  111452. * Gets the current underlying G Buffer.
  111453. * @returns the buffer
  111454. */
  111455. getGBuffer(): MultiRenderTarget;
  111456. /**
  111457. * Gets the number of samples used to render the buffer (anti aliasing).
  111458. */
  111459. /**
  111460. * Sets the number of samples used to render the buffer (anti aliasing).
  111461. */
  111462. samples: number;
  111463. /**
  111464. * Disposes the renderer and frees up associated resources.
  111465. */
  111466. dispose(): void;
  111467. protected _createRenderTargets(): void;
  111468. }
  111469. }
  111470. declare module BABYLON {
  111471. interface Scene {
  111472. /** @hidden (Backing field) */
  111473. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111474. /**
  111475. * Gets or Sets the current geometry buffer associated to the scene.
  111476. */
  111477. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111478. /**
  111479. * Enables a GeometryBufferRender and associates it with the scene
  111480. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111481. * @returns the GeometryBufferRenderer
  111482. */
  111483. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  111484. /**
  111485. * Disables the GeometryBufferRender associated with the scene
  111486. */
  111487. disableGeometryBufferRenderer(): void;
  111488. }
  111489. /**
  111490. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  111491. * in several rendering techniques.
  111492. */
  111493. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  111494. /**
  111495. * The component name helpful to identify the component in the list of scene components.
  111496. */
  111497. readonly name: string;
  111498. /**
  111499. * The scene the component belongs to.
  111500. */
  111501. scene: Scene;
  111502. /**
  111503. * Creates a new instance of the component for the given scene
  111504. * @param scene Defines the scene to register the component in
  111505. */
  111506. constructor(scene: Scene);
  111507. /**
  111508. * Registers the component in a given scene
  111509. */
  111510. register(): void;
  111511. /**
  111512. * Rebuilds the elements related to this component in case of
  111513. * context lost for instance.
  111514. */
  111515. rebuild(): void;
  111516. /**
  111517. * Disposes the component and the associated ressources
  111518. */
  111519. dispose(): void;
  111520. private _gatherRenderTargets;
  111521. }
  111522. }
  111523. declare module BABYLON {
  111524. /** @hidden */
  111525. export var motionBlurPixelShader: {
  111526. name: string;
  111527. shader: string;
  111528. };
  111529. }
  111530. declare module BABYLON {
  111531. /**
  111532. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  111533. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  111534. * As an example, all you have to do is to create the post-process:
  111535. * var mb = new BABYLON.MotionBlurPostProcess(
  111536. * 'mb', // The name of the effect.
  111537. * scene, // The scene containing the objects to blur according to their velocity.
  111538. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  111539. * camera // The camera to apply the render pass to.
  111540. * );
  111541. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  111542. */
  111543. export class MotionBlurPostProcess extends PostProcess {
  111544. /**
  111545. * Defines how much the image is blurred by the movement. Default value is equal to 1
  111546. */
  111547. motionStrength: number;
  111548. /**
  111549. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  111550. */
  111551. /**
  111552. * Sets the number of iterations to be used for motion blur quality
  111553. */
  111554. motionBlurSamples: number;
  111555. private _motionBlurSamples;
  111556. private _geometryBufferRenderer;
  111557. /**
  111558. * Creates a new instance MotionBlurPostProcess
  111559. * @param name The name of the effect.
  111560. * @param scene The scene containing the objects to blur according to their velocity.
  111561. * @param options The required width/height ratio to downsize to before computing the render pass.
  111562. * @param camera The camera to apply the render pass to.
  111563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111564. * @param engine The engine which the post process will be applied. (default: current engine)
  111565. * @param reusable If the post process can be reused on the same frame. (default: false)
  111566. * @param textureType Type of textures used when performing the post process. (default: 0)
  111567. * @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)
  111568. */
  111569. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111570. /**
  111571. * Disposes the post process.
  111572. * @param camera The camera to dispose the post process on.
  111573. */
  111574. dispose(camera?: Camera): void;
  111575. }
  111576. }
  111577. declare module BABYLON {
  111578. /** @hidden */
  111579. export var refractionPixelShader: {
  111580. name: string;
  111581. shader: string;
  111582. };
  111583. }
  111584. declare module BABYLON {
  111585. /**
  111586. * Post process which applies a refractin texture
  111587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111588. */
  111589. export class RefractionPostProcess extends PostProcess {
  111590. /** the base color of the refraction (used to taint the rendering) */
  111591. color: Color3;
  111592. /** simulated refraction depth */
  111593. depth: number;
  111594. /** the coefficient of the base color (0 to remove base color tainting) */
  111595. colorLevel: number;
  111596. private _refTexture;
  111597. private _ownRefractionTexture;
  111598. /**
  111599. * Gets or sets the refraction texture
  111600. * Please note that you are responsible for disposing the texture if you set it manually
  111601. */
  111602. refractionTexture: Texture;
  111603. /**
  111604. * Initializes the RefractionPostProcess
  111605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111606. * @param name The name of the effect.
  111607. * @param refractionTextureUrl Url of the refraction texture to use
  111608. * @param color the base color of the refraction (used to taint the rendering)
  111609. * @param depth simulated refraction depth
  111610. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  111611. * @param camera The camera to apply the render pass to.
  111612. * @param options The required width/height ratio to downsize to before computing the render pass.
  111613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111614. * @param engine The engine which the post process will be applied. (default: current engine)
  111615. * @param reusable If the post process can be reused on the same frame. (default: false)
  111616. */
  111617. constructor(name: string, refractionTextureUrl: string,
  111618. /** the base color of the refraction (used to taint the rendering) */
  111619. color: Color3,
  111620. /** simulated refraction depth */
  111621. depth: number,
  111622. /** the coefficient of the base color (0 to remove base color tainting) */
  111623. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111624. /**
  111625. * Disposes of the post process
  111626. * @param camera Camera to dispose post process on
  111627. */
  111628. dispose(camera: Camera): void;
  111629. }
  111630. }
  111631. declare module BABYLON {
  111632. /** @hidden */
  111633. export var sharpenPixelShader: {
  111634. name: string;
  111635. shader: string;
  111636. };
  111637. }
  111638. declare module BABYLON {
  111639. /**
  111640. * The SharpenPostProcess applies a sharpen kernel to every pixel
  111641. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111642. */
  111643. export class SharpenPostProcess extends PostProcess {
  111644. /**
  111645. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  111646. */
  111647. colorAmount: number;
  111648. /**
  111649. * How much sharpness should be applied (default: 0.3)
  111650. */
  111651. edgeAmount: number;
  111652. /**
  111653. * Creates a new instance ConvolutionPostProcess
  111654. * @param name The name of the effect.
  111655. * @param options The required width/height ratio to downsize to before computing the render pass.
  111656. * @param camera The camera to apply the render pass to.
  111657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111658. * @param engine The engine which the post process will be applied. (default: current engine)
  111659. * @param reusable If the post process can be reused on the same frame. (default: false)
  111660. * @param textureType Type of textures used when performing the post process. (default: 0)
  111661. * @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)
  111662. */
  111663. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * PostProcessRenderPipeline
  111669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111670. */
  111671. export class PostProcessRenderPipeline {
  111672. private engine;
  111673. private _renderEffects;
  111674. private _renderEffectsForIsolatedPass;
  111675. /**
  111676. * List of inspectable custom properties (used by the Inspector)
  111677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111678. */
  111679. inspectableCustomProperties: IInspectable[];
  111680. /**
  111681. * @hidden
  111682. */
  111683. protected _cameras: Camera[];
  111684. /** @hidden */
  111685. _name: string;
  111686. /**
  111687. * Gets pipeline name
  111688. */
  111689. readonly name: string;
  111690. /**
  111691. * Initializes a PostProcessRenderPipeline
  111692. * @param engine engine to add the pipeline to
  111693. * @param name name of the pipeline
  111694. */
  111695. constructor(engine: Engine, name: string);
  111696. /**
  111697. * Gets the class name
  111698. * @returns "PostProcessRenderPipeline"
  111699. */
  111700. getClassName(): string;
  111701. /**
  111702. * If all the render effects in the pipeline are supported
  111703. */
  111704. readonly isSupported: boolean;
  111705. /**
  111706. * Adds an effect to the pipeline
  111707. * @param renderEffect the effect to add
  111708. */
  111709. addEffect(renderEffect: PostProcessRenderEffect): void;
  111710. /** @hidden */
  111711. _rebuild(): void;
  111712. /** @hidden */
  111713. _enableEffect(renderEffectName: string, cameras: Camera): void;
  111714. /** @hidden */
  111715. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  111716. /** @hidden */
  111717. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111718. /** @hidden */
  111719. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111720. /** @hidden */
  111721. _attachCameras(cameras: Camera, unique: boolean): void;
  111722. /** @hidden */
  111723. _attachCameras(cameras: Camera[], unique: boolean): void;
  111724. /** @hidden */
  111725. _detachCameras(cameras: Camera): void;
  111726. /** @hidden */
  111727. _detachCameras(cameras: Nullable<Camera[]>): void;
  111728. /** @hidden */
  111729. _update(): void;
  111730. /** @hidden */
  111731. _reset(): void;
  111732. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  111733. /**
  111734. * Disposes of the pipeline
  111735. */
  111736. dispose(): void;
  111737. }
  111738. }
  111739. declare module BABYLON {
  111740. /**
  111741. * PostProcessRenderPipelineManager class
  111742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111743. */
  111744. export class PostProcessRenderPipelineManager {
  111745. private _renderPipelines;
  111746. /**
  111747. * Initializes a PostProcessRenderPipelineManager
  111748. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111749. */
  111750. constructor();
  111751. /**
  111752. * Gets the list of supported render pipelines
  111753. */
  111754. readonly supportedPipelines: PostProcessRenderPipeline[];
  111755. /**
  111756. * Adds a pipeline to the manager
  111757. * @param renderPipeline The pipeline to add
  111758. */
  111759. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  111760. /**
  111761. * Attaches a camera to the pipeline
  111762. * @param renderPipelineName The name of the pipeline to attach to
  111763. * @param cameras the camera to attach
  111764. * @param unique if the camera can be attached multiple times to the pipeline
  111765. */
  111766. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  111767. /**
  111768. * Detaches a camera from the pipeline
  111769. * @param renderPipelineName The name of the pipeline to detach from
  111770. * @param cameras the camera to detach
  111771. */
  111772. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  111773. /**
  111774. * Enables an effect by name on a pipeline
  111775. * @param renderPipelineName the name of the pipeline to enable the effect in
  111776. * @param renderEffectName the name of the effect to enable
  111777. * @param cameras the cameras that the effect should be enabled on
  111778. */
  111779. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111780. /**
  111781. * Disables an effect by name on a pipeline
  111782. * @param renderPipelineName the name of the pipeline to disable the effect in
  111783. * @param renderEffectName the name of the effect to disable
  111784. * @param cameras the cameras that the effect should be disabled on
  111785. */
  111786. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111787. /**
  111788. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  111789. */
  111790. update(): void;
  111791. /** @hidden */
  111792. _rebuild(): void;
  111793. /**
  111794. * Disposes of the manager and pipelines
  111795. */
  111796. dispose(): void;
  111797. }
  111798. }
  111799. declare module BABYLON {
  111800. interface Scene {
  111801. /** @hidden (Backing field) */
  111802. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111803. /**
  111804. * Gets the postprocess render pipeline manager
  111805. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111806. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111807. */
  111808. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111809. }
  111810. /**
  111811. * Defines the Render Pipeline scene component responsible to rendering pipelines
  111812. */
  111813. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  111814. /**
  111815. * The component name helpfull to identify the component in the list of scene components.
  111816. */
  111817. readonly name: string;
  111818. /**
  111819. * The scene the component belongs to.
  111820. */
  111821. scene: Scene;
  111822. /**
  111823. * Creates a new instance of the component for the given scene
  111824. * @param scene Defines the scene to register the component in
  111825. */
  111826. constructor(scene: Scene);
  111827. /**
  111828. * Registers the component in a given scene
  111829. */
  111830. register(): void;
  111831. /**
  111832. * Rebuilds the elements related to this component in case of
  111833. * context lost for instance.
  111834. */
  111835. rebuild(): void;
  111836. /**
  111837. * Disposes the component and the associated ressources
  111838. */
  111839. dispose(): void;
  111840. private _gatherRenderTargets;
  111841. }
  111842. }
  111843. declare module BABYLON {
  111844. /**
  111845. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111846. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111847. */
  111848. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111849. private _scene;
  111850. private _camerasToBeAttached;
  111851. /**
  111852. * ID of the sharpen post process,
  111853. */
  111854. private readonly SharpenPostProcessId;
  111855. /**
  111856. * @ignore
  111857. * ID of the image processing post process;
  111858. */
  111859. readonly ImageProcessingPostProcessId: string;
  111860. /**
  111861. * @ignore
  111862. * ID of the Fast Approximate Anti-Aliasing post process;
  111863. */
  111864. readonly FxaaPostProcessId: string;
  111865. /**
  111866. * ID of the chromatic aberration post process,
  111867. */
  111868. private readonly ChromaticAberrationPostProcessId;
  111869. /**
  111870. * ID of the grain post process
  111871. */
  111872. private readonly GrainPostProcessId;
  111873. /**
  111874. * Sharpen post process which will apply a sharpen convolution to enhance edges
  111875. */
  111876. sharpen: SharpenPostProcess;
  111877. private _sharpenEffect;
  111878. private bloom;
  111879. /**
  111880. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  111881. */
  111882. depthOfField: DepthOfFieldEffect;
  111883. /**
  111884. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111885. */
  111886. fxaa: FxaaPostProcess;
  111887. /**
  111888. * Image post processing pass used to perform operations such as tone mapping or color grading.
  111889. */
  111890. imageProcessing: ImageProcessingPostProcess;
  111891. /**
  111892. * Chromatic aberration post process which will shift rgb colors in the image
  111893. */
  111894. chromaticAberration: ChromaticAberrationPostProcess;
  111895. private _chromaticAberrationEffect;
  111896. /**
  111897. * Grain post process which add noise to the image
  111898. */
  111899. grain: GrainPostProcess;
  111900. private _grainEffect;
  111901. /**
  111902. * Glow post process which adds a glow to emissive areas of the image
  111903. */
  111904. private _glowLayer;
  111905. /**
  111906. * Animations which can be used to tweak settings over a period of time
  111907. */
  111908. animations: Animation[];
  111909. private _imageProcessingConfigurationObserver;
  111910. private _sharpenEnabled;
  111911. private _bloomEnabled;
  111912. private _depthOfFieldEnabled;
  111913. private _depthOfFieldBlurLevel;
  111914. private _fxaaEnabled;
  111915. private _imageProcessingEnabled;
  111916. private _defaultPipelineTextureType;
  111917. private _bloomScale;
  111918. private _chromaticAberrationEnabled;
  111919. private _grainEnabled;
  111920. private _buildAllowed;
  111921. /**
  111922. * Gets active scene
  111923. */
  111924. readonly scene: Scene;
  111925. /**
  111926. * Enable or disable the sharpen process from the pipeline
  111927. */
  111928. sharpenEnabled: boolean;
  111929. private _resizeObserver;
  111930. private _hardwareScaleLevel;
  111931. private _bloomKernel;
  111932. /**
  111933. * Specifies the size of the bloom blur kernel, relative to the final output size
  111934. */
  111935. bloomKernel: number;
  111936. /**
  111937. * Specifies the weight of the bloom in the final rendering
  111938. */
  111939. private _bloomWeight;
  111940. /**
  111941. * Specifies the luma threshold for the area that will be blurred by the bloom
  111942. */
  111943. private _bloomThreshold;
  111944. private _hdr;
  111945. /**
  111946. * The strength of the bloom.
  111947. */
  111948. bloomWeight: number;
  111949. /**
  111950. * The strength of the bloom.
  111951. */
  111952. bloomThreshold: number;
  111953. /**
  111954. * The scale of the bloom, lower value will provide better performance.
  111955. */
  111956. bloomScale: number;
  111957. /**
  111958. * Enable or disable the bloom from the pipeline
  111959. */
  111960. bloomEnabled: boolean;
  111961. private _rebuildBloom;
  111962. /**
  111963. * If the depth of field is enabled.
  111964. */
  111965. depthOfFieldEnabled: boolean;
  111966. /**
  111967. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111968. */
  111969. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  111970. /**
  111971. * If the anti aliasing is enabled.
  111972. */
  111973. fxaaEnabled: boolean;
  111974. private _samples;
  111975. /**
  111976. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111977. */
  111978. samples: number;
  111979. /**
  111980. * If image processing is enabled.
  111981. */
  111982. imageProcessingEnabled: boolean;
  111983. /**
  111984. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  111985. */
  111986. glowLayerEnabled: boolean;
  111987. /**
  111988. * Enable or disable the chromaticAberration process from the pipeline
  111989. */
  111990. chromaticAberrationEnabled: boolean;
  111991. /**
  111992. * Enable or disable the grain process from the pipeline
  111993. */
  111994. grainEnabled: boolean;
  111995. /**
  111996. * @constructor
  111997. * @param name - The rendering pipeline name (default: "")
  111998. * @param hdr - If high dynamic range textures should be used (default: true)
  111999. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112000. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112001. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112002. */
  112003. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112004. /**
  112005. * Get the class name
  112006. * @returns "DefaultRenderingPipeline"
  112007. */
  112008. getClassName(): string;
  112009. /**
  112010. * Force the compilation of the entire pipeline.
  112011. */
  112012. prepare(): void;
  112013. private _hasCleared;
  112014. private _prevPostProcess;
  112015. private _prevPrevPostProcess;
  112016. private _setAutoClearAndTextureSharing;
  112017. private _depthOfFieldSceneObserver;
  112018. private _buildPipeline;
  112019. private _disposePostProcesses;
  112020. /**
  112021. * Adds a camera to the pipeline
  112022. * @param camera the camera to be added
  112023. */
  112024. addCamera(camera: Camera): void;
  112025. /**
  112026. * Removes a camera from the pipeline
  112027. * @param camera the camera to remove
  112028. */
  112029. removeCamera(camera: Camera): void;
  112030. /**
  112031. * Dispose of the pipeline and stop all post processes
  112032. */
  112033. dispose(): void;
  112034. /**
  112035. * Serialize the rendering pipeline (Used when exporting)
  112036. * @returns the serialized object
  112037. */
  112038. serialize(): any;
  112039. /**
  112040. * Parse the serialized pipeline
  112041. * @param source Source pipeline.
  112042. * @param scene The scene to load the pipeline to.
  112043. * @param rootUrl The URL of the serialized pipeline.
  112044. * @returns An instantiated pipeline from the serialized object.
  112045. */
  112046. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112047. }
  112048. }
  112049. declare module BABYLON {
  112050. /** @hidden */
  112051. export var lensHighlightsPixelShader: {
  112052. name: string;
  112053. shader: string;
  112054. };
  112055. }
  112056. declare module BABYLON {
  112057. /** @hidden */
  112058. export var depthOfFieldPixelShader: {
  112059. name: string;
  112060. shader: string;
  112061. };
  112062. }
  112063. declare module BABYLON {
  112064. /**
  112065. * BABYLON.JS Chromatic Aberration GLSL Shader
  112066. * Author: Olivier Guyot
  112067. * Separates very slightly R, G and B colors on the edges of the screen
  112068. * Inspired by Francois Tarlier & Martins Upitis
  112069. */
  112070. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112071. /**
  112072. * @ignore
  112073. * The chromatic aberration PostProcess id in the pipeline
  112074. */
  112075. LensChromaticAberrationEffect: string;
  112076. /**
  112077. * @ignore
  112078. * The highlights enhancing PostProcess id in the pipeline
  112079. */
  112080. HighlightsEnhancingEffect: string;
  112081. /**
  112082. * @ignore
  112083. * The depth-of-field PostProcess id in the pipeline
  112084. */
  112085. LensDepthOfFieldEffect: string;
  112086. private _scene;
  112087. private _depthTexture;
  112088. private _grainTexture;
  112089. private _chromaticAberrationPostProcess;
  112090. private _highlightsPostProcess;
  112091. private _depthOfFieldPostProcess;
  112092. private _edgeBlur;
  112093. private _grainAmount;
  112094. private _chromaticAberration;
  112095. private _distortion;
  112096. private _highlightsGain;
  112097. private _highlightsThreshold;
  112098. private _dofDistance;
  112099. private _dofAperture;
  112100. private _dofDarken;
  112101. private _dofPentagon;
  112102. private _blurNoise;
  112103. /**
  112104. * @constructor
  112105. *
  112106. * Effect parameters are as follow:
  112107. * {
  112108. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112109. * edge_blur: number; // from 0 to x (1 for realism)
  112110. * distortion: number; // from 0 to x (1 for realism)
  112111. * grain_amount: number; // from 0 to 1
  112112. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112113. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112114. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112115. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112116. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112117. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112118. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112119. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112120. * }
  112121. * Note: if an effect parameter is unset, effect is disabled
  112122. *
  112123. * @param name The rendering pipeline name
  112124. * @param parameters - An object containing all parameters (see above)
  112125. * @param scene The scene linked to this pipeline
  112126. * @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)
  112127. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112128. */
  112129. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112130. /**
  112131. * Get the class name
  112132. * @returns "LensRenderingPipeline"
  112133. */
  112134. getClassName(): string;
  112135. /**
  112136. * Gets associated scene
  112137. */
  112138. readonly scene: Scene;
  112139. /**
  112140. * Gets or sets the edge blur
  112141. */
  112142. edgeBlur: number;
  112143. /**
  112144. * Gets or sets the grain amount
  112145. */
  112146. grainAmount: number;
  112147. /**
  112148. * Gets or sets the chromatic aberration amount
  112149. */
  112150. chromaticAberration: number;
  112151. /**
  112152. * Gets or sets the depth of field aperture
  112153. */
  112154. dofAperture: number;
  112155. /**
  112156. * Gets or sets the edge distortion
  112157. */
  112158. edgeDistortion: number;
  112159. /**
  112160. * Gets or sets the depth of field distortion
  112161. */
  112162. dofDistortion: number;
  112163. /**
  112164. * Gets or sets the darken out of focus amount
  112165. */
  112166. darkenOutOfFocus: number;
  112167. /**
  112168. * Gets or sets a boolean indicating if blur noise is enabled
  112169. */
  112170. blurNoise: boolean;
  112171. /**
  112172. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112173. */
  112174. pentagonBokeh: boolean;
  112175. /**
  112176. * Gets or sets the highlight grain amount
  112177. */
  112178. highlightsGain: number;
  112179. /**
  112180. * Gets or sets the highlight threshold
  112181. */
  112182. highlightsThreshold: number;
  112183. /**
  112184. * Sets the amount of blur at the edges
  112185. * @param amount blur amount
  112186. */
  112187. setEdgeBlur(amount: number): void;
  112188. /**
  112189. * Sets edge blur to 0
  112190. */
  112191. disableEdgeBlur(): void;
  112192. /**
  112193. * Sets the amout of grain
  112194. * @param amount Amount of grain
  112195. */
  112196. setGrainAmount(amount: number): void;
  112197. /**
  112198. * Set grain amount to 0
  112199. */
  112200. disableGrain(): void;
  112201. /**
  112202. * Sets the chromatic aberration amount
  112203. * @param amount amount of chromatic aberration
  112204. */
  112205. setChromaticAberration(amount: number): void;
  112206. /**
  112207. * Sets chromatic aberration amount to 0
  112208. */
  112209. disableChromaticAberration(): void;
  112210. /**
  112211. * Sets the EdgeDistortion amount
  112212. * @param amount amount of EdgeDistortion
  112213. */
  112214. setEdgeDistortion(amount: number): void;
  112215. /**
  112216. * Sets edge distortion to 0
  112217. */
  112218. disableEdgeDistortion(): void;
  112219. /**
  112220. * Sets the FocusDistance amount
  112221. * @param amount amount of FocusDistance
  112222. */
  112223. setFocusDistance(amount: number): void;
  112224. /**
  112225. * Disables depth of field
  112226. */
  112227. disableDepthOfField(): void;
  112228. /**
  112229. * Sets the Aperture amount
  112230. * @param amount amount of Aperture
  112231. */
  112232. setAperture(amount: number): void;
  112233. /**
  112234. * Sets the DarkenOutOfFocus amount
  112235. * @param amount amount of DarkenOutOfFocus
  112236. */
  112237. setDarkenOutOfFocus(amount: number): void;
  112238. private _pentagonBokehIsEnabled;
  112239. /**
  112240. * Creates a pentagon bokeh effect
  112241. */
  112242. enablePentagonBokeh(): void;
  112243. /**
  112244. * Disables the pentagon bokeh effect
  112245. */
  112246. disablePentagonBokeh(): void;
  112247. /**
  112248. * Enables noise blur
  112249. */
  112250. enableNoiseBlur(): void;
  112251. /**
  112252. * Disables noise blur
  112253. */
  112254. disableNoiseBlur(): void;
  112255. /**
  112256. * Sets the HighlightsGain amount
  112257. * @param amount amount of HighlightsGain
  112258. */
  112259. setHighlightsGain(amount: number): void;
  112260. /**
  112261. * Sets the HighlightsThreshold amount
  112262. * @param amount amount of HighlightsThreshold
  112263. */
  112264. setHighlightsThreshold(amount: number): void;
  112265. /**
  112266. * Disables highlights
  112267. */
  112268. disableHighlights(): void;
  112269. /**
  112270. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112271. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112272. */
  112273. dispose(disableDepthRender?: boolean): void;
  112274. private _createChromaticAberrationPostProcess;
  112275. private _createHighlightsPostProcess;
  112276. private _createDepthOfFieldPostProcess;
  112277. private _createGrainTexture;
  112278. }
  112279. }
  112280. declare module BABYLON {
  112281. /** @hidden */
  112282. export var ssao2PixelShader: {
  112283. name: string;
  112284. shader: string;
  112285. };
  112286. }
  112287. declare module BABYLON {
  112288. /** @hidden */
  112289. export var ssaoCombinePixelShader: {
  112290. name: string;
  112291. shader: string;
  112292. };
  112293. }
  112294. declare module BABYLON {
  112295. /**
  112296. * Render pipeline to produce ssao effect
  112297. */
  112298. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112299. /**
  112300. * @ignore
  112301. * The PassPostProcess id in the pipeline that contains the original scene color
  112302. */
  112303. SSAOOriginalSceneColorEffect: string;
  112304. /**
  112305. * @ignore
  112306. * The SSAO PostProcess id in the pipeline
  112307. */
  112308. SSAORenderEffect: string;
  112309. /**
  112310. * @ignore
  112311. * The horizontal blur PostProcess id in the pipeline
  112312. */
  112313. SSAOBlurHRenderEffect: string;
  112314. /**
  112315. * @ignore
  112316. * The vertical blur PostProcess id in the pipeline
  112317. */
  112318. SSAOBlurVRenderEffect: string;
  112319. /**
  112320. * @ignore
  112321. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112322. */
  112323. SSAOCombineRenderEffect: string;
  112324. /**
  112325. * The output strength of the SSAO post-process. Default value is 1.0.
  112326. */
  112327. totalStrength: number;
  112328. /**
  112329. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112330. */
  112331. maxZ: number;
  112332. /**
  112333. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112334. */
  112335. minZAspect: number;
  112336. private _samples;
  112337. /**
  112338. * Number of samples used for the SSAO calculations. Default value is 8
  112339. */
  112340. samples: number;
  112341. private _textureSamples;
  112342. /**
  112343. * Number of samples to use for antialiasing
  112344. */
  112345. textureSamples: number;
  112346. /**
  112347. * Ratio object used for SSAO ratio and blur ratio
  112348. */
  112349. private _ratio;
  112350. /**
  112351. * Dynamically generated sphere sampler.
  112352. */
  112353. private _sampleSphere;
  112354. /**
  112355. * Blur filter offsets
  112356. */
  112357. private _samplerOffsets;
  112358. private _expensiveBlur;
  112359. /**
  112360. * If bilateral blur should be used
  112361. */
  112362. expensiveBlur: boolean;
  112363. /**
  112364. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112365. */
  112366. radius: number;
  112367. /**
  112368. * The base color of the SSAO post-process
  112369. * The final result is "base + ssao" between [0, 1]
  112370. */
  112371. base: number;
  112372. /**
  112373. * Support test.
  112374. */
  112375. static readonly IsSupported: boolean;
  112376. private _scene;
  112377. private _depthTexture;
  112378. private _normalTexture;
  112379. private _randomTexture;
  112380. private _originalColorPostProcess;
  112381. private _ssaoPostProcess;
  112382. private _blurHPostProcess;
  112383. private _blurVPostProcess;
  112384. private _ssaoCombinePostProcess;
  112385. private _firstUpdate;
  112386. /**
  112387. * Gets active scene
  112388. */
  112389. readonly scene: Scene;
  112390. /**
  112391. * @constructor
  112392. * @param name The rendering pipeline name
  112393. * @param scene The scene linked to this pipeline
  112394. * @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 }
  112395. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112396. */
  112397. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112398. /**
  112399. * Get the class name
  112400. * @returns "SSAO2RenderingPipeline"
  112401. */
  112402. getClassName(): string;
  112403. /**
  112404. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112405. */
  112406. dispose(disableGeometryBufferRenderer?: boolean): void;
  112407. private _createBlurPostProcess;
  112408. /** @hidden */
  112409. _rebuild(): void;
  112410. private _bits;
  112411. private _radicalInverse_VdC;
  112412. private _hammersley;
  112413. private _hemisphereSample_uniform;
  112414. private _generateHemisphere;
  112415. private _createSSAOPostProcess;
  112416. private _createSSAOCombinePostProcess;
  112417. private _createRandomTexture;
  112418. /**
  112419. * Serialize the rendering pipeline (Used when exporting)
  112420. * @returns the serialized object
  112421. */
  112422. serialize(): any;
  112423. /**
  112424. * Parse the serialized pipeline
  112425. * @param source Source pipeline.
  112426. * @param scene The scene to load the pipeline to.
  112427. * @param rootUrl The URL of the serialized pipeline.
  112428. * @returns An instantiated pipeline from the serialized object.
  112429. */
  112430. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112431. }
  112432. }
  112433. declare module BABYLON {
  112434. /** @hidden */
  112435. export var ssaoPixelShader: {
  112436. name: string;
  112437. shader: string;
  112438. };
  112439. }
  112440. declare module BABYLON {
  112441. /**
  112442. * Render pipeline to produce ssao effect
  112443. */
  112444. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112445. /**
  112446. * @ignore
  112447. * The PassPostProcess id in the pipeline that contains the original scene color
  112448. */
  112449. SSAOOriginalSceneColorEffect: string;
  112450. /**
  112451. * @ignore
  112452. * The SSAO PostProcess id in the pipeline
  112453. */
  112454. SSAORenderEffect: string;
  112455. /**
  112456. * @ignore
  112457. * The horizontal blur PostProcess id in the pipeline
  112458. */
  112459. SSAOBlurHRenderEffect: string;
  112460. /**
  112461. * @ignore
  112462. * The vertical blur PostProcess id in the pipeline
  112463. */
  112464. SSAOBlurVRenderEffect: string;
  112465. /**
  112466. * @ignore
  112467. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112468. */
  112469. SSAOCombineRenderEffect: string;
  112470. /**
  112471. * The output strength of the SSAO post-process. Default value is 1.0.
  112472. */
  112473. totalStrength: number;
  112474. /**
  112475. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112476. */
  112477. radius: number;
  112478. /**
  112479. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112480. * Must not be equal to fallOff and superior to fallOff.
  112481. * Default value is 0.0075
  112482. */
  112483. area: number;
  112484. /**
  112485. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  112486. * Must not be equal to area and inferior to area.
  112487. * Default value is 0.000001
  112488. */
  112489. fallOff: number;
  112490. /**
  112491. * The base color of the SSAO post-process
  112492. * The final result is "base + ssao" between [0, 1]
  112493. */
  112494. base: number;
  112495. private _scene;
  112496. private _depthTexture;
  112497. private _randomTexture;
  112498. private _originalColorPostProcess;
  112499. private _ssaoPostProcess;
  112500. private _blurHPostProcess;
  112501. private _blurVPostProcess;
  112502. private _ssaoCombinePostProcess;
  112503. private _firstUpdate;
  112504. /**
  112505. * Gets active scene
  112506. */
  112507. readonly scene: Scene;
  112508. /**
  112509. * @constructor
  112510. * @param name - The rendering pipeline name
  112511. * @param scene - The scene linked to this pipeline
  112512. * @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 }
  112513. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  112514. */
  112515. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112516. /**
  112517. * Get the class name
  112518. * @returns "SSAORenderingPipeline"
  112519. */
  112520. getClassName(): string;
  112521. /**
  112522. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112523. */
  112524. dispose(disableDepthRender?: boolean): void;
  112525. private _createBlurPostProcess;
  112526. /** @hidden */
  112527. _rebuild(): void;
  112528. private _createSSAOPostProcess;
  112529. private _createSSAOCombinePostProcess;
  112530. private _createRandomTexture;
  112531. }
  112532. }
  112533. declare module BABYLON {
  112534. /** @hidden */
  112535. export var standardPixelShader: {
  112536. name: string;
  112537. shader: string;
  112538. };
  112539. }
  112540. declare module BABYLON {
  112541. /**
  112542. * Standard rendering pipeline
  112543. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112544. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  112545. */
  112546. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112547. /**
  112548. * Public members
  112549. */
  112550. /**
  112551. * Post-process which contains the original scene color before the pipeline applies all the effects
  112552. */
  112553. originalPostProcess: Nullable<PostProcess>;
  112554. /**
  112555. * Post-process used to down scale an image x4
  112556. */
  112557. downSampleX4PostProcess: Nullable<PostProcess>;
  112558. /**
  112559. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  112560. */
  112561. brightPassPostProcess: Nullable<PostProcess>;
  112562. /**
  112563. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  112564. */
  112565. blurHPostProcesses: PostProcess[];
  112566. /**
  112567. * Post-process array storing all the vertical blur post-processes used by the pipeline
  112568. */
  112569. blurVPostProcesses: PostProcess[];
  112570. /**
  112571. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  112572. */
  112573. textureAdderPostProcess: Nullable<PostProcess>;
  112574. /**
  112575. * Post-process used to create volumetric lighting effect
  112576. */
  112577. volumetricLightPostProcess: Nullable<PostProcess>;
  112578. /**
  112579. * Post-process used to smooth the previous volumetric light post-process on the X axis
  112580. */
  112581. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  112582. /**
  112583. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  112584. */
  112585. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  112586. /**
  112587. * Post-process used to merge the volumetric light effect and the real scene color
  112588. */
  112589. volumetricLightMergePostProces: Nullable<PostProcess>;
  112590. /**
  112591. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  112592. */
  112593. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  112594. /**
  112595. * Base post-process used to calculate the average luminance of the final image for HDR
  112596. */
  112597. luminancePostProcess: Nullable<PostProcess>;
  112598. /**
  112599. * Post-processes used to create down sample post-processes in order to get
  112600. * the average luminance of the final image for HDR
  112601. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  112602. */
  112603. luminanceDownSamplePostProcesses: PostProcess[];
  112604. /**
  112605. * Post-process used to create a HDR effect (light adaptation)
  112606. */
  112607. hdrPostProcess: Nullable<PostProcess>;
  112608. /**
  112609. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  112610. */
  112611. textureAdderFinalPostProcess: Nullable<PostProcess>;
  112612. /**
  112613. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  112614. */
  112615. lensFlareFinalPostProcess: Nullable<PostProcess>;
  112616. /**
  112617. * Post-process used to merge the final HDR post-process and the real scene color
  112618. */
  112619. hdrFinalPostProcess: Nullable<PostProcess>;
  112620. /**
  112621. * Post-process used to create a lens flare effect
  112622. */
  112623. lensFlarePostProcess: Nullable<PostProcess>;
  112624. /**
  112625. * Post-process that merges the result of the lens flare post-process and the real scene color
  112626. */
  112627. lensFlareComposePostProcess: Nullable<PostProcess>;
  112628. /**
  112629. * Post-process used to create a motion blur effect
  112630. */
  112631. motionBlurPostProcess: Nullable<PostProcess>;
  112632. /**
  112633. * Post-process used to create a depth of field effect
  112634. */
  112635. depthOfFieldPostProcess: Nullable<PostProcess>;
  112636. /**
  112637. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112638. */
  112639. fxaaPostProcess: Nullable<FxaaPostProcess>;
  112640. /**
  112641. * Represents the brightness threshold in order to configure the illuminated surfaces
  112642. */
  112643. brightThreshold: number;
  112644. /**
  112645. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  112646. */
  112647. blurWidth: number;
  112648. /**
  112649. * Sets if the blur for highlighted surfaces must be only horizontal
  112650. */
  112651. horizontalBlur: boolean;
  112652. /**
  112653. * Gets the overall exposure used by the pipeline
  112654. */
  112655. /**
  112656. * Sets the overall exposure used by the pipeline
  112657. */
  112658. exposure: number;
  112659. /**
  112660. * Texture used typically to simulate "dirty" on camera lens
  112661. */
  112662. lensTexture: Nullable<Texture>;
  112663. /**
  112664. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  112665. */
  112666. volumetricLightCoefficient: number;
  112667. /**
  112668. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  112669. */
  112670. volumetricLightPower: number;
  112671. /**
  112672. * Used the set the blur intensity to smooth the volumetric lights
  112673. */
  112674. volumetricLightBlurScale: number;
  112675. /**
  112676. * Light (spot or directional) used to generate the volumetric lights rays
  112677. * The source light must have a shadow generate so the pipeline can get its
  112678. * depth map
  112679. */
  112680. sourceLight: Nullable<SpotLight | DirectionalLight>;
  112681. /**
  112682. * For eye adaptation, represents the minimum luminance the eye can see
  112683. */
  112684. hdrMinimumLuminance: number;
  112685. /**
  112686. * For eye adaptation, represents the decrease luminance speed
  112687. */
  112688. hdrDecreaseRate: number;
  112689. /**
  112690. * For eye adaptation, represents the increase luminance speed
  112691. */
  112692. hdrIncreaseRate: number;
  112693. /**
  112694. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  112695. */
  112696. /**
  112697. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  112698. */
  112699. hdrAutoExposure: boolean;
  112700. /**
  112701. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  112702. */
  112703. lensColorTexture: Nullable<Texture>;
  112704. /**
  112705. * The overall strengh for the lens flare effect
  112706. */
  112707. lensFlareStrength: number;
  112708. /**
  112709. * Dispersion coefficient for lens flare ghosts
  112710. */
  112711. lensFlareGhostDispersal: number;
  112712. /**
  112713. * Main lens flare halo width
  112714. */
  112715. lensFlareHaloWidth: number;
  112716. /**
  112717. * Based on the lens distortion effect, defines how much the lens flare result
  112718. * is distorted
  112719. */
  112720. lensFlareDistortionStrength: number;
  112721. /**
  112722. * Lens star texture must be used to simulate rays on the flares and is available
  112723. * in the documentation
  112724. */
  112725. lensStarTexture: Nullable<Texture>;
  112726. /**
  112727. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  112728. * flare effect by taking account of the dirt texture
  112729. */
  112730. lensFlareDirtTexture: Nullable<Texture>;
  112731. /**
  112732. * Represents the focal length for the depth of field effect
  112733. */
  112734. depthOfFieldDistance: number;
  112735. /**
  112736. * Represents the blur intensity for the blurred part of the depth of field effect
  112737. */
  112738. depthOfFieldBlurWidth: number;
  112739. /**
  112740. * For motion blur, defines how much the image is blurred by the movement
  112741. */
  112742. motionStrength: number;
  112743. /**
  112744. * List of animations for the pipeline (IAnimatable implementation)
  112745. */
  112746. animations: Animation[];
  112747. /**
  112748. * Private members
  112749. */
  112750. private _scene;
  112751. private _currentDepthOfFieldSource;
  112752. private _basePostProcess;
  112753. private _fixedExposure;
  112754. private _currentExposure;
  112755. private _hdrAutoExposure;
  112756. private _hdrCurrentLuminance;
  112757. private _floatTextureType;
  112758. private _ratio;
  112759. private _bloomEnabled;
  112760. private _depthOfFieldEnabled;
  112761. private _vlsEnabled;
  112762. private _lensFlareEnabled;
  112763. private _hdrEnabled;
  112764. private _motionBlurEnabled;
  112765. private _fxaaEnabled;
  112766. private _motionBlurSamples;
  112767. private _volumetricLightStepsCount;
  112768. private _samples;
  112769. /**
  112770. * @ignore
  112771. * Specifies if the bloom pipeline is enabled
  112772. */
  112773. BloomEnabled: boolean;
  112774. /**
  112775. * @ignore
  112776. * Specifies if the depth of field pipeline is enabed
  112777. */
  112778. DepthOfFieldEnabled: boolean;
  112779. /**
  112780. * @ignore
  112781. * Specifies if the lens flare pipeline is enabed
  112782. */
  112783. LensFlareEnabled: boolean;
  112784. /**
  112785. * @ignore
  112786. * Specifies if the HDR pipeline is enabled
  112787. */
  112788. HDREnabled: boolean;
  112789. /**
  112790. * @ignore
  112791. * Specifies if the volumetric lights scattering effect is enabled
  112792. */
  112793. VLSEnabled: boolean;
  112794. /**
  112795. * @ignore
  112796. * Specifies if the motion blur effect is enabled
  112797. */
  112798. MotionBlurEnabled: boolean;
  112799. /**
  112800. * Specifies if anti-aliasing is enabled
  112801. */
  112802. fxaaEnabled: boolean;
  112803. /**
  112804. * Specifies the number of steps used to calculate the volumetric lights
  112805. * Typically in interval [50, 200]
  112806. */
  112807. volumetricLightStepsCount: number;
  112808. /**
  112809. * Specifies the number of samples used for the motion blur effect
  112810. * Typically in interval [16, 64]
  112811. */
  112812. motionBlurSamples: number;
  112813. /**
  112814. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112815. */
  112816. samples: number;
  112817. /**
  112818. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112819. * @constructor
  112820. * @param name The rendering pipeline name
  112821. * @param scene The scene linked to this pipeline
  112822. * @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)
  112823. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  112824. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112825. */
  112826. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  112827. private _buildPipeline;
  112828. private _createDownSampleX4PostProcess;
  112829. private _createBrightPassPostProcess;
  112830. private _createBlurPostProcesses;
  112831. private _createTextureAdderPostProcess;
  112832. private _createVolumetricLightPostProcess;
  112833. private _createLuminancePostProcesses;
  112834. private _createHdrPostProcess;
  112835. private _createLensFlarePostProcess;
  112836. private _createDepthOfFieldPostProcess;
  112837. private _createMotionBlurPostProcess;
  112838. private _getDepthTexture;
  112839. private _disposePostProcesses;
  112840. /**
  112841. * Dispose of the pipeline and stop all post processes
  112842. */
  112843. dispose(): void;
  112844. /**
  112845. * Serialize the rendering pipeline (Used when exporting)
  112846. * @returns the serialized object
  112847. */
  112848. serialize(): any;
  112849. /**
  112850. * Parse the serialized pipeline
  112851. * @param source Source pipeline.
  112852. * @param scene The scene to load the pipeline to.
  112853. * @param rootUrl The URL of the serialized pipeline.
  112854. * @returns An instantiated pipeline from the serialized object.
  112855. */
  112856. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  112857. /**
  112858. * Luminance steps
  112859. */
  112860. static LuminanceSteps: number;
  112861. }
  112862. }
  112863. declare module BABYLON {
  112864. /** @hidden */
  112865. export var tonemapPixelShader: {
  112866. name: string;
  112867. shader: string;
  112868. };
  112869. }
  112870. declare module BABYLON {
  112871. /** Defines operator used for tonemapping */
  112872. export enum TonemappingOperator {
  112873. /** Hable */
  112874. Hable = 0,
  112875. /** Reinhard */
  112876. Reinhard = 1,
  112877. /** HejiDawson */
  112878. HejiDawson = 2,
  112879. /** Photographic */
  112880. Photographic = 3
  112881. }
  112882. /**
  112883. * Defines a post process to apply tone mapping
  112884. */
  112885. export class TonemapPostProcess extends PostProcess {
  112886. private _operator;
  112887. /** Defines the required exposure adjustement */
  112888. exposureAdjustment: number;
  112889. /**
  112890. * Creates a new TonemapPostProcess
  112891. * @param name defines the name of the postprocess
  112892. * @param _operator defines the operator to use
  112893. * @param exposureAdjustment defines the required exposure adjustement
  112894. * @param camera defines the camera to use (can be null)
  112895. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  112896. * @param engine defines the hosting engine (can be ignore if camera is set)
  112897. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112898. */
  112899. constructor(name: string, _operator: TonemappingOperator,
  112900. /** Defines the required exposure adjustement */
  112901. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  112902. }
  112903. }
  112904. declare module BABYLON {
  112905. /** @hidden */
  112906. export var depthVertexShader: {
  112907. name: string;
  112908. shader: string;
  112909. };
  112910. }
  112911. declare module BABYLON {
  112912. /** @hidden */
  112913. export var volumetricLightScatteringPixelShader: {
  112914. name: string;
  112915. shader: string;
  112916. };
  112917. }
  112918. declare module BABYLON {
  112919. /** @hidden */
  112920. export var volumetricLightScatteringPassPixelShader: {
  112921. name: string;
  112922. shader: string;
  112923. };
  112924. }
  112925. declare module BABYLON {
  112926. /**
  112927. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  112928. */
  112929. export class VolumetricLightScatteringPostProcess extends PostProcess {
  112930. private _volumetricLightScatteringPass;
  112931. private _volumetricLightScatteringRTT;
  112932. private _viewPort;
  112933. private _screenCoordinates;
  112934. private _cachedDefines;
  112935. /**
  112936. * If not undefined, the mesh position is computed from the attached node position
  112937. */
  112938. attachedNode: {
  112939. position: Vector3;
  112940. };
  112941. /**
  112942. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  112943. */
  112944. customMeshPosition: Vector3;
  112945. /**
  112946. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  112947. */
  112948. useCustomMeshPosition: boolean;
  112949. /**
  112950. * If the post-process should inverse the light scattering direction
  112951. */
  112952. invert: boolean;
  112953. /**
  112954. * The internal mesh used by the post-process
  112955. */
  112956. mesh: Mesh;
  112957. /**
  112958. * @hidden
  112959. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  112960. */
  112961. useDiffuseColor: boolean;
  112962. /**
  112963. * Array containing the excluded meshes not rendered in the internal pass
  112964. */
  112965. excludedMeshes: AbstractMesh[];
  112966. /**
  112967. * Controls the overall intensity of the post-process
  112968. */
  112969. exposure: number;
  112970. /**
  112971. * Dissipates each sample's contribution in range [0, 1]
  112972. */
  112973. decay: number;
  112974. /**
  112975. * Controls the overall intensity of each sample
  112976. */
  112977. weight: number;
  112978. /**
  112979. * Controls the density of each sample
  112980. */
  112981. density: number;
  112982. /**
  112983. * @constructor
  112984. * @param name The post-process name
  112985. * @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)
  112986. * @param camera The camera that the post-process will be attached to
  112987. * @param mesh The mesh used to create the light scattering
  112988. * @param samples The post-process quality, default 100
  112989. * @param samplingModeThe post-process filtering mode
  112990. * @param engine The babylon engine
  112991. * @param reusable If the post-process is reusable
  112992. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  112993. */
  112994. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  112995. /**
  112996. * Returns the string "VolumetricLightScatteringPostProcess"
  112997. * @returns "VolumetricLightScatteringPostProcess"
  112998. */
  112999. getClassName(): string;
  113000. private _isReady;
  113001. /**
  113002. * Sets the new light position for light scattering effect
  113003. * @param position The new custom light position
  113004. */
  113005. setCustomMeshPosition(position: Vector3): void;
  113006. /**
  113007. * Returns the light position for light scattering effect
  113008. * @return Vector3 The custom light position
  113009. */
  113010. getCustomMeshPosition(): Vector3;
  113011. /**
  113012. * Disposes the internal assets and detaches the post-process from the camera
  113013. */
  113014. dispose(camera: Camera): void;
  113015. /**
  113016. * Returns the render target texture used by the post-process
  113017. * @return the render target texture used by the post-process
  113018. */
  113019. getPass(): RenderTargetTexture;
  113020. private _meshExcluded;
  113021. private _createPass;
  113022. private _updateMeshScreenCoordinates;
  113023. /**
  113024. * Creates a default mesh for the Volumeric Light Scattering post-process
  113025. * @param name The mesh name
  113026. * @param scene The scene where to create the mesh
  113027. * @return the default mesh
  113028. */
  113029. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113030. }
  113031. }
  113032. declare module BABYLON {
  113033. interface Scene {
  113034. /** @hidden (Backing field) */
  113035. _boundingBoxRenderer: BoundingBoxRenderer;
  113036. /** @hidden (Backing field) */
  113037. _forceShowBoundingBoxes: boolean;
  113038. /**
  113039. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113040. */
  113041. forceShowBoundingBoxes: boolean;
  113042. /**
  113043. * Gets the bounding box renderer associated with the scene
  113044. * @returns a BoundingBoxRenderer
  113045. */
  113046. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113047. }
  113048. interface AbstractMesh {
  113049. /** @hidden (Backing field) */
  113050. _showBoundingBox: boolean;
  113051. /**
  113052. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113053. */
  113054. showBoundingBox: boolean;
  113055. }
  113056. /**
  113057. * Component responsible of rendering the bounding box of the meshes in a scene.
  113058. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113059. */
  113060. export class BoundingBoxRenderer implements ISceneComponent {
  113061. /**
  113062. * The component name helpfull to identify the component in the list of scene components.
  113063. */
  113064. readonly name: string;
  113065. /**
  113066. * The scene the component belongs to.
  113067. */
  113068. scene: Scene;
  113069. /**
  113070. * Color of the bounding box lines placed in front of an object
  113071. */
  113072. frontColor: Color3;
  113073. /**
  113074. * Color of the bounding box lines placed behind an object
  113075. */
  113076. backColor: Color3;
  113077. /**
  113078. * Defines if the renderer should show the back lines or not
  113079. */
  113080. showBackLines: boolean;
  113081. /**
  113082. * @hidden
  113083. */
  113084. renderList: SmartArray<BoundingBox>;
  113085. private _colorShader;
  113086. private _vertexBuffers;
  113087. private _indexBuffer;
  113088. /**
  113089. * Instantiates a new bounding box renderer in a scene.
  113090. * @param scene the scene the renderer renders in
  113091. */
  113092. constructor(scene: Scene);
  113093. /**
  113094. * Registers the component in a given scene
  113095. */
  113096. register(): void;
  113097. private _evaluateSubMesh;
  113098. private _activeMesh;
  113099. private _prepareRessources;
  113100. private _createIndexBuffer;
  113101. /**
  113102. * Rebuilds the elements related to this component in case of
  113103. * context lost for instance.
  113104. */
  113105. rebuild(): void;
  113106. /**
  113107. * @hidden
  113108. */
  113109. reset(): void;
  113110. /**
  113111. * Render the bounding boxes of a specific rendering group
  113112. * @param renderingGroupId defines the rendering group to render
  113113. */
  113114. render(renderingGroupId: number): void;
  113115. /**
  113116. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113117. * @param mesh Define the mesh to render the occlusion bounding box for
  113118. */
  113119. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113120. /**
  113121. * Dispose and release the resources attached to this renderer.
  113122. */
  113123. dispose(): void;
  113124. }
  113125. }
  113126. declare module BABYLON {
  113127. /** @hidden */
  113128. export var depthPixelShader: {
  113129. name: string;
  113130. shader: string;
  113131. };
  113132. }
  113133. declare module BABYLON {
  113134. /**
  113135. * This represents a depth renderer in Babylon.
  113136. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113137. */
  113138. export class DepthRenderer {
  113139. private _scene;
  113140. private _depthMap;
  113141. private _effect;
  113142. private _cachedDefines;
  113143. private _camera;
  113144. /**
  113145. * Specifiess that the depth renderer will only be used within
  113146. * the camera it is created for.
  113147. * This can help forcing its rendering during the camera processing.
  113148. */
  113149. useOnlyInActiveCamera: boolean;
  113150. /** @hidden */
  113151. static _SceneComponentInitialization: (scene: Scene) => void;
  113152. /**
  113153. * Instantiates a depth renderer
  113154. * @param scene The scene the renderer belongs to
  113155. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113156. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113157. */
  113158. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113159. /**
  113160. * Creates the depth rendering effect and checks if the effect is ready.
  113161. * @param subMesh The submesh to be used to render the depth map of
  113162. * @param useInstances If multiple world instances should be used
  113163. * @returns if the depth renderer is ready to render the depth map
  113164. */
  113165. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113166. /**
  113167. * Gets the texture which the depth map will be written to.
  113168. * @returns The depth map texture
  113169. */
  113170. getDepthMap(): RenderTargetTexture;
  113171. /**
  113172. * Disposes of the depth renderer.
  113173. */
  113174. dispose(): void;
  113175. }
  113176. }
  113177. declare module BABYLON {
  113178. interface Scene {
  113179. /** @hidden (Backing field) */
  113180. _depthRenderer: {
  113181. [id: string]: DepthRenderer;
  113182. };
  113183. /**
  113184. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113185. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113186. * @returns the created depth renderer
  113187. */
  113188. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113189. /**
  113190. * Disables a depth renderer for a given camera
  113191. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113192. */
  113193. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113194. }
  113195. /**
  113196. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113197. * in several rendering techniques.
  113198. */
  113199. export class DepthRendererSceneComponent implements ISceneComponent {
  113200. /**
  113201. * The component name helpfull to identify the component in the list of scene components.
  113202. */
  113203. readonly name: string;
  113204. /**
  113205. * The scene the component belongs to.
  113206. */
  113207. scene: Scene;
  113208. /**
  113209. * Creates a new instance of the component for the given scene
  113210. * @param scene Defines the scene to register the component in
  113211. */
  113212. constructor(scene: Scene);
  113213. /**
  113214. * Registers the component in a given scene
  113215. */
  113216. register(): void;
  113217. /**
  113218. * Rebuilds the elements related to this component in case of
  113219. * context lost for instance.
  113220. */
  113221. rebuild(): void;
  113222. /**
  113223. * Disposes the component and the associated ressources
  113224. */
  113225. dispose(): void;
  113226. private _gatherRenderTargets;
  113227. private _gatherActiveCameraRenderTargets;
  113228. }
  113229. }
  113230. declare module BABYLON {
  113231. /** @hidden */
  113232. export var outlinePixelShader: {
  113233. name: string;
  113234. shader: string;
  113235. };
  113236. }
  113237. declare module BABYLON {
  113238. /** @hidden */
  113239. export var outlineVertexShader: {
  113240. name: string;
  113241. shader: string;
  113242. };
  113243. }
  113244. declare module BABYLON {
  113245. interface Scene {
  113246. /** @hidden */
  113247. _outlineRenderer: OutlineRenderer;
  113248. /**
  113249. * Gets the outline renderer associated with the scene
  113250. * @returns a OutlineRenderer
  113251. */
  113252. getOutlineRenderer(): OutlineRenderer;
  113253. }
  113254. interface AbstractMesh {
  113255. /** @hidden (Backing field) */
  113256. _renderOutline: boolean;
  113257. /**
  113258. * Gets or sets a boolean indicating if the outline must be rendered as well
  113259. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113260. */
  113261. renderOutline: boolean;
  113262. /** @hidden (Backing field) */
  113263. _renderOverlay: boolean;
  113264. /**
  113265. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113266. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113267. */
  113268. renderOverlay: boolean;
  113269. }
  113270. /**
  113271. * This class is responsible to draw bothe outline/overlay of meshes.
  113272. * It should not be used directly but through the available method on mesh.
  113273. */
  113274. export class OutlineRenderer implements ISceneComponent {
  113275. /**
  113276. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113277. */
  113278. private static _StencilReference;
  113279. /**
  113280. * The name of the component. Each component must have a unique name.
  113281. */
  113282. name: string;
  113283. /**
  113284. * The scene the component belongs to.
  113285. */
  113286. scene: Scene;
  113287. /**
  113288. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113289. */
  113290. zOffset: number;
  113291. private _engine;
  113292. private _effect;
  113293. private _cachedDefines;
  113294. private _savedDepthWrite;
  113295. /**
  113296. * Instantiates a new outline renderer. (There could be only one per scene).
  113297. * @param scene Defines the scene it belongs to
  113298. */
  113299. constructor(scene: Scene);
  113300. /**
  113301. * Register the component to one instance of a scene.
  113302. */
  113303. register(): void;
  113304. /**
  113305. * Rebuilds the elements related to this component in case of
  113306. * context lost for instance.
  113307. */
  113308. rebuild(): void;
  113309. /**
  113310. * Disposes the component and the associated ressources.
  113311. */
  113312. dispose(): void;
  113313. /**
  113314. * Renders the outline in the canvas.
  113315. * @param subMesh Defines the sumesh to render
  113316. * @param batch Defines the batch of meshes in case of instances
  113317. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113318. */
  113319. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113320. /**
  113321. * Returns whether or not the outline renderer is ready for a given submesh.
  113322. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113323. * @param subMesh Defines the submesh to check readyness for
  113324. * @param useInstances Defines wheter wee are trying to render instances or not
  113325. * @returns true if ready otherwise false
  113326. */
  113327. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113328. private _beforeRenderingMesh;
  113329. private _afterRenderingMesh;
  113330. }
  113331. }
  113332. declare module BABYLON {
  113333. /**
  113334. * Defines the list of states available for a task inside a AssetsManager
  113335. */
  113336. export enum AssetTaskState {
  113337. /**
  113338. * Initialization
  113339. */
  113340. INIT = 0,
  113341. /**
  113342. * Running
  113343. */
  113344. RUNNING = 1,
  113345. /**
  113346. * Done
  113347. */
  113348. DONE = 2,
  113349. /**
  113350. * Error
  113351. */
  113352. ERROR = 3
  113353. }
  113354. /**
  113355. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113356. */
  113357. export abstract class AbstractAssetTask {
  113358. /**
  113359. * Task name
  113360. */ name: string;
  113361. /**
  113362. * Callback called when the task is successful
  113363. */
  113364. onSuccess: (task: any) => void;
  113365. /**
  113366. * Callback called when the task is not successful
  113367. */
  113368. onError: (task: any, message?: string, exception?: any) => void;
  113369. /**
  113370. * Creates a new AssetsManager
  113371. * @param name defines the name of the task
  113372. */
  113373. constructor(
  113374. /**
  113375. * Task name
  113376. */ name: string);
  113377. private _isCompleted;
  113378. private _taskState;
  113379. private _errorObject;
  113380. /**
  113381. * Get if the task is completed
  113382. */
  113383. readonly isCompleted: boolean;
  113384. /**
  113385. * Gets the current state of the task
  113386. */
  113387. readonly taskState: AssetTaskState;
  113388. /**
  113389. * Gets the current error object (if task is in error)
  113390. */
  113391. readonly errorObject: {
  113392. message?: string;
  113393. exception?: any;
  113394. };
  113395. /**
  113396. * Internal only
  113397. * @hidden
  113398. */
  113399. _setErrorObject(message?: string, exception?: any): void;
  113400. /**
  113401. * Execute the current task
  113402. * @param scene defines the scene where you want your assets to be loaded
  113403. * @param onSuccess is a callback called when the task is successfully executed
  113404. * @param onError is a callback called if an error occurs
  113405. */
  113406. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113407. /**
  113408. * Execute the current task
  113409. * @param scene defines the scene where you want your assets to be loaded
  113410. * @param onSuccess is a callback called when the task is successfully executed
  113411. * @param onError is a callback called if an error occurs
  113412. */
  113413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113414. /**
  113415. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113416. * This can be used with failed tasks that have the reason for failure fixed.
  113417. */
  113418. reset(): void;
  113419. private onErrorCallback;
  113420. private onDoneCallback;
  113421. }
  113422. /**
  113423. * Define the interface used by progress events raised during assets loading
  113424. */
  113425. export interface IAssetsProgressEvent {
  113426. /**
  113427. * Defines the number of remaining tasks to process
  113428. */
  113429. remainingCount: number;
  113430. /**
  113431. * Defines the total number of tasks
  113432. */
  113433. totalCount: number;
  113434. /**
  113435. * Defines the task that was just processed
  113436. */
  113437. task: AbstractAssetTask;
  113438. }
  113439. /**
  113440. * Class used to share progress information about assets loading
  113441. */
  113442. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113443. /**
  113444. * Defines the number of remaining tasks to process
  113445. */
  113446. remainingCount: number;
  113447. /**
  113448. * Defines the total number of tasks
  113449. */
  113450. totalCount: number;
  113451. /**
  113452. * Defines the task that was just processed
  113453. */
  113454. task: AbstractAssetTask;
  113455. /**
  113456. * Creates a AssetsProgressEvent
  113457. * @param remainingCount defines the number of remaining tasks to process
  113458. * @param totalCount defines the total number of tasks
  113459. * @param task defines the task that was just processed
  113460. */
  113461. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113462. }
  113463. /**
  113464. * Define a task used by AssetsManager to load meshes
  113465. */
  113466. export class MeshAssetTask extends AbstractAssetTask {
  113467. /**
  113468. * Defines the name of the task
  113469. */
  113470. name: string;
  113471. /**
  113472. * Defines the list of mesh's names you want to load
  113473. */
  113474. meshesNames: any;
  113475. /**
  113476. * Defines the root url to use as a base to load your meshes and associated resources
  113477. */
  113478. rootUrl: string;
  113479. /**
  113480. * Defines the filename of the scene to load from
  113481. */
  113482. sceneFilename: string;
  113483. /**
  113484. * Gets the list of loaded meshes
  113485. */
  113486. loadedMeshes: Array<AbstractMesh>;
  113487. /**
  113488. * Gets the list of loaded particle systems
  113489. */
  113490. loadedParticleSystems: Array<IParticleSystem>;
  113491. /**
  113492. * Gets the list of loaded skeletons
  113493. */
  113494. loadedSkeletons: Array<Skeleton>;
  113495. /**
  113496. * Gets the list of loaded animation groups
  113497. */
  113498. loadedAnimationGroups: Array<AnimationGroup>;
  113499. /**
  113500. * Callback called when the task is successful
  113501. */
  113502. onSuccess: (task: MeshAssetTask) => void;
  113503. /**
  113504. * Callback called when the task is successful
  113505. */
  113506. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  113507. /**
  113508. * Creates a new MeshAssetTask
  113509. * @param name defines the name of the task
  113510. * @param meshesNames defines the list of mesh's names you want to load
  113511. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  113512. * @param sceneFilename defines the filename of the scene to load from
  113513. */
  113514. constructor(
  113515. /**
  113516. * Defines the name of the task
  113517. */
  113518. name: string,
  113519. /**
  113520. * Defines the list of mesh's names you want to load
  113521. */
  113522. meshesNames: any,
  113523. /**
  113524. * Defines the root url to use as a base to load your meshes and associated resources
  113525. */
  113526. rootUrl: string,
  113527. /**
  113528. * Defines the filename of the scene to load from
  113529. */
  113530. sceneFilename: string);
  113531. /**
  113532. * Execute the current task
  113533. * @param scene defines the scene where you want your assets to be loaded
  113534. * @param onSuccess is a callback called when the task is successfully executed
  113535. * @param onError is a callback called if an error occurs
  113536. */
  113537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113538. }
  113539. /**
  113540. * Define a task used by AssetsManager to load text content
  113541. */
  113542. export class TextFileAssetTask extends AbstractAssetTask {
  113543. /**
  113544. * Defines the name of the task
  113545. */
  113546. name: string;
  113547. /**
  113548. * Defines the location of the file to load
  113549. */
  113550. url: string;
  113551. /**
  113552. * Gets the loaded text string
  113553. */
  113554. text: string;
  113555. /**
  113556. * Callback called when the task is successful
  113557. */
  113558. onSuccess: (task: TextFileAssetTask) => void;
  113559. /**
  113560. * Callback called when the task is successful
  113561. */
  113562. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  113563. /**
  113564. * Creates a new TextFileAssetTask object
  113565. * @param name defines the name of the task
  113566. * @param url defines the location of the file to load
  113567. */
  113568. constructor(
  113569. /**
  113570. * Defines the name of the task
  113571. */
  113572. name: string,
  113573. /**
  113574. * Defines the location of the file to load
  113575. */
  113576. url: string);
  113577. /**
  113578. * Execute the current task
  113579. * @param scene defines the scene where you want your assets to be loaded
  113580. * @param onSuccess is a callback called when the task is successfully executed
  113581. * @param onError is a callback called if an error occurs
  113582. */
  113583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113584. }
  113585. /**
  113586. * Define a task used by AssetsManager to load binary data
  113587. */
  113588. export class BinaryFileAssetTask extends AbstractAssetTask {
  113589. /**
  113590. * Defines the name of the task
  113591. */
  113592. name: string;
  113593. /**
  113594. * Defines the location of the file to load
  113595. */
  113596. url: string;
  113597. /**
  113598. * Gets the lodaded data (as an array buffer)
  113599. */
  113600. data: ArrayBuffer;
  113601. /**
  113602. * Callback called when the task is successful
  113603. */
  113604. onSuccess: (task: BinaryFileAssetTask) => void;
  113605. /**
  113606. * Callback called when the task is successful
  113607. */
  113608. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  113609. /**
  113610. * Creates a new BinaryFileAssetTask object
  113611. * @param name defines the name of the new task
  113612. * @param url defines the location of the file to load
  113613. */
  113614. constructor(
  113615. /**
  113616. * Defines the name of the task
  113617. */
  113618. name: string,
  113619. /**
  113620. * Defines the location of the file to load
  113621. */
  113622. url: string);
  113623. /**
  113624. * Execute the current task
  113625. * @param scene defines the scene where you want your assets to be loaded
  113626. * @param onSuccess is a callback called when the task is successfully executed
  113627. * @param onError is a callback called if an error occurs
  113628. */
  113629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113630. }
  113631. /**
  113632. * Define a task used by AssetsManager to load images
  113633. */
  113634. export class ImageAssetTask extends AbstractAssetTask {
  113635. /**
  113636. * Defines the name of the task
  113637. */
  113638. name: string;
  113639. /**
  113640. * Defines the location of the image to load
  113641. */
  113642. url: string;
  113643. /**
  113644. * Gets the loaded images
  113645. */
  113646. image: HTMLImageElement;
  113647. /**
  113648. * Callback called when the task is successful
  113649. */
  113650. onSuccess: (task: ImageAssetTask) => void;
  113651. /**
  113652. * Callback called when the task is successful
  113653. */
  113654. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  113655. /**
  113656. * Creates a new ImageAssetTask
  113657. * @param name defines the name of the task
  113658. * @param url defines the location of the image to load
  113659. */
  113660. constructor(
  113661. /**
  113662. * Defines the name of the task
  113663. */
  113664. name: string,
  113665. /**
  113666. * Defines the location of the image to load
  113667. */
  113668. url: string);
  113669. /**
  113670. * Execute the current task
  113671. * @param scene defines the scene where you want your assets to be loaded
  113672. * @param onSuccess is a callback called when the task is successfully executed
  113673. * @param onError is a callback called if an error occurs
  113674. */
  113675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113676. }
  113677. /**
  113678. * Defines the interface used by texture loading tasks
  113679. */
  113680. export interface ITextureAssetTask<TEX extends BaseTexture> {
  113681. /**
  113682. * Gets the loaded texture
  113683. */
  113684. texture: TEX;
  113685. }
  113686. /**
  113687. * Define a task used by AssetsManager to load 2D textures
  113688. */
  113689. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  113690. /**
  113691. * Defines the name of the task
  113692. */
  113693. name: string;
  113694. /**
  113695. * Defines the location of the file to load
  113696. */
  113697. url: string;
  113698. /**
  113699. * Defines if mipmap should not be generated (default is false)
  113700. */
  113701. noMipmap?: boolean | undefined;
  113702. /**
  113703. * Defines if texture must be inverted on Y axis (default is false)
  113704. */
  113705. invertY?: boolean | undefined;
  113706. /**
  113707. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113708. */
  113709. samplingMode: number;
  113710. /**
  113711. * Gets the loaded texture
  113712. */
  113713. texture: Texture;
  113714. /**
  113715. * Callback called when the task is successful
  113716. */
  113717. onSuccess: (task: TextureAssetTask) => void;
  113718. /**
  113719. * Callback called when the task is successful
  113720. */
  113721. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  113722. /**
  113723. * Creates a new TextureAssetTask object
  113724. * @param name defines the name of the task
  113725. * @param url defines the location of the file to load
  113726. * @param noMipmap defines if mipmap should not be generated (default is false)
  113727. * @param invertY defines if texture must be inverted on Y axis (default is false)
  113728. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113729. */
  113730. constructor(
  113731. /**
  113732. * Defines the name of the task
  113733. */
  113734. name: string,
  113735. /**
  113736. * Defines the location of the file to load
  113737. */
  113738. url: string,
  113739. /**
  113740. * Defines if mipmap should not be generated (default is false)
  113741. */
  113742. noMipmap?: boolean | undefined,
  113743. /**
  113744. * Defines if texture must be inverted on Y axis (default is false)
  113745. */
  113746. invertY?: boolean | undefined,
  113747. /**
  113748. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113749. */
  113750. samplingMode?: number);
  113751. /**
  113752. * Execute the current task
  113753. * @param scene defines the scene where you want your assets to be loaded
  113754. * @param onSuccess is a callback called when the task is successfully executed
  113755. * @param onError is a callback called if an error occurs
  113756. */
  113757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113758. }
  113759. /**
  113760. * Define a task used by AssetsManager to load cube textures
  113761. */
  113762. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  113763. /**
  113764. * Defines the name of the task
  113765. */
  113766. name: string;
  113767. /**
  113768. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113769. */
  113770. url: string;
  113771. /**
  113772. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113773. */
  113774. extensions?: string[] | undefined;
  113775. /**
  113776. * Defines if mipmaps should not be generated (default is false)
  113777. */
  113778. noMipmap?: boolean | undefined;
  113779. /**
  113780. * Defines the explicit list of files (undefined by default)
  113781. */
  113782. files?: string[] | undefined;
  113783. /**
  113784. * Gets the loaded texture
  113785. */
  113786. texture: CubeTexture;
  113787. /**
  113788. * Callback called when the task is successful
  113789. */
  113790. onSuccess: (task: CubeTextureAssetTask) => void;
  113791. /**
  113792. * Callback called when the task is successful
  113793. */
  113794. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  113795. /**
  113796. * Creates a new CubeTextureAssetTask
  113797. * @param name defines the name of the task
  113798. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113799. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113800. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113801. * @param files defines the explicit list of files (undefined by default)
  113802. */
  113803. constructor(
  113804. /**
  113805. * Defines the name of the task
  113806. */
  113807. name: string,
  113808. /**
  113809. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113810. */
  113811. url: string,
  113812. /**
  113813. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113814. */
  113815. extensions?: string[] | undefined,
  113816. /**
  113817. * Defines if mipmaps should not be generated (default is false)
  113818. */
  113819. noMipmap?: boolean | undefined,
  113820. /**
  113821. * Defines the explicit list of files (undefined by default)
  113822. */
  113823. files?: string[] | undefined);
  113824. /**
  113825. * Execute the current task
  113826. * @param scene defines the scene where you want your assets to be loaded
  113827. * @param onSuccess is a callback called when the task is successfully executed
  113828. * @param onError is a callback called if an error occurs
  113829. */
  113830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113831. }
  113832. /**
  113833. * Define a task used by AssetsManager to load HDR cube textures
  113834. */
  113835. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  113836. /**
  113837. * Defines the name of the task
  113838. */
  113839. name: string;
  113840. /**
  113841. * Defines the location of the file to load
  113842. */
  113843. url: string;
  113844. /**
  113845. * Defines the desired size (the more it increases the longer the generation will be)
  113846. */
  113847. size: number;
  113848. /**
  113849. * Defines if mipmaps should not be generated (default is false)
  113850. */
  113851. noMipmap: boolean;
  113852. /**
  113853. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113854. */
  113855. generateHarmonics: boolean;
  113856. /**
  113857. * 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)
  113858. */
  113859. gammaSpace: boolean;
  113860. /**
  113861. * Internal Use Only
  113862. */
  113863. reserved: boolean;
  113864. /**
  113865. * Gets the loaded texture
  113866. */
  113867. texture: HDRCubeTexture;
  113868. /**
  113869. * Callback called when the task is successful
  113870. */
  113871. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  113872. /**
  113873. * Callback called when the task is successful
  113874. */
  113875. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  113876. /**
  113877. * Creates a new HDRCubeTextureAssetTask object
  113878. * @param name defines the name of the task
  113879. * @param url defines the location of the file to load
  113880. * @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.
  113881. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113882. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113883. * @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)
  113884. * @param reserved Internal use only
  113885. */
  113886. constructor(
  113887. /**
  113888. * Defines the name of the task
  113889. */
  113890. name: string,
  113891. /**
  113892. * Defines the location of the file to load
  113893. */
  113894. url: string,
  113895. /**
  113896. * Defines the desired size (the more it increases the longer the generation will be)
  113897. */
  113898. size: number,
  113899. /**
  113900. * Defines if mipmaps should not be generated (default is false)
  113901. */
  113902. noMipmap?: boolean,
  113903. /**
  113904. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113905. */
  113906. generateHarmonics?: boolean,
  113907. /**
  113908. * 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)
  113909. */
  113910. gammaSpace?: boolean,
  113911. /**
  113912. * Internal Use Only
  113913. */
  113914. reserved?: boolean);
  113915. /**
  113916. * Execute the current task
  113917. * @param scene defines the scene where you want your assets to be loaded
  113918. * @param onSuccess is a callback called when the task is successfully executed
  113919. * @param onError is a callback called if an error occurs
  113920. */
  113921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113922. }
  113923. /**
  113924. * Define a task used by AssetsManager to load Equirectangular cube textures
  113925. */
  113926. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  113927. /**
  113928. * Defines the name of the task
  113929. */
  113930. name: string;
  113931. /**
  113932. * Defines the location of the file to load
  113933. */
  113934. url: string;
  113935. /**
  113936. * Defines the desired size (the more it increases the longer the generation will be)
  113937. */
  113938. size: number;
  113939. /**
  113940. * Defines if mipmaps should not be generated (default is false)
  113941. */
  113942. noMipmap: boolean;
  113943. /**
  113944. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113945. * but the standard material would require them in Gamma space) (default is true)
  113946. */
  113947. gammaSpace: boolean;
  113948. /**
  113949. * Gets the loaded texture
  113950. */
  113951. texture: EquiRectangularCubeTexture;
  113952. /**
  113953. * Callback called when the task is successful
  113954. */
  113955. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  113956. /**
  113957. * Callback called when the task is successful
  113958. */
  113959. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  113960. /**
  113961. * Creates a new EquiRectangularCubeTextureAssetTask object
  113962. * @param name defines the name of the task
  113963. * @param url defines the location of the file to load
  113964. * @param size defines the desired size (the more it increases the longer the generation will be)
  113965. * If the size is omitted this implies you are using a preprocessed cubemap.
  113966. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113967. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  113968. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  113969. * (default is true)
  113970. */
  113971. constructor(
  113972. /**
  113973. * Defines the name of the task
  113974. */
  113975. name: string,
  113976. /**
  113977. * Defines the location of the file to load
  113978. */
  113979. url: string,
  113980. /**
  113981. * Defines the desired size (the more it increases the longer the generation will be)
  113982. */
  113983. size: number,
  113984. /**
  113985. * Defines if mipmaps should not be generated (default is false)
  113986. */
  113987. noMipmap?: boolean,
  113988. /**
  113989. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113990. * but the standard material would require them in Gamma space) (default is true)
  113991. */
  113992. gammaSpace?: boolean);
  113993. /**
  113994. * Execute the current task
  113995. * @param scene defines the scene where you want your assets to be loaded
  113996. * @param onSuccess is a callback called when the task is successfully executed
  113997. * @param onError is a callback called if an error occurs
  113998. */
  113999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114000. }
  114001. /**
  114002. * This class can be used to easily import assets into a scene
  114003. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114004. */
  114005. export class AssetsManager {
  114006. private _scene;
  114007. private _isLoading;
  114008. protected _tasks: AbstractAssetTask[];
  114009. protected _waitingTasksCount: number;
  114010. protected _totalTasksCount: number;
  114011. /**
  114012. * Callback called when all tasks are processed
  114013. */
  114014. onFinish: (tasks: AbstractAssetTask[]) => void;
  114015. /**
  114016. * Callback called when a task is successful
  114017. */
  114018. onTaskSuccess: (task: AbstractAssetTask) => void;
  114019. /**
  114020. * Callback called when a task had an error
  114021. */
  114022. onTaskError: (task: AbstractAssetTask) => void;
  114023. /**
  114024. * Callback called when a task is done (whatever the result is)
  114025. */
  114026. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114027. /**
  114028. * Observable called when all tasks are processed
  114029. */
  114030. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114031. /**
  114032. * Observable called when a task had an error
  114033. */
  114034. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114035. /**
  114036. * Observable called when all tasks were executed
  114037. */
  114038. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114039. /**
  114040. * Observable called when a task is done (whatever the result is)
  114041. */
  114042. onProgressObservable: Observable<IAssetsProgressEvent>;
  114043. /**
  114044. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114046. */
  114047. useDefaultLoadingScreen: boolean;
  114048. /**
  114049. * Creates a new AssetsManager
  114050. * @param scene defines the scene to work on
  114051. */
  114052. constructor(scene: Scene);
  114053. /**
  114054. * Add a MeshAssetTask to the list of active tasks
  114055. * @param taskName defines the name of the new task
  114056. * @param meshesNames defines the name of meshes to load
  114057. * @param rootUrl defines the root url to use to locate files
  114058. * @param sceneFilename defines the filename of the scene file
  114059. * @returns a new MeshAssetTask object
  114060. */
  114061. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114062. /**
  114063. * Add a TextFileAssetTask to the list of active tasks
  114064. * @param taskName defines the name of the new task
  114065. * @param url defines the url of the file to load
  114066. * @returns a new TextFileAssetTask object
  114067. */
  114068. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114069. /**
  114070. * Add a BinaryFileAssetTask to the list of active tasks
  114071. * @param taskName defines the name of the new task
  114072. * @param url defines the url of the file to load
  114073. * @returns a new BinaryFileAssetTask object
  114074. */
  114075. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114076. /**
  114077. * Add a ImageAssetTask to the list of active tasks
  114078. * @param taskName defines the name of the new task
  114079. * @param url defines the url of the file to load
  114080. * @returns a new ImageAssetTask object
  114081. */
  114082. addImageTask(taskName: string, url: string): ImageAssetTask;
  114083. /**
  114084. * Add a TextureAssetTask to the list of active tasks
  114085. * @param taskName defines the name of the new task
  114086. * @param url defines the url of the file to load
  114087. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114088. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114089. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114090. * @returns a new TextureAssetTask object
  114091. */
  114092. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114093. /**
  114094. * Add a CubeTextureAssetTask to the list of active tasks
  114095. * @param taskName defines the name of the new task
  114096. * @param url defines the url of the file to load
  114097. * @param extensions defines the extension to use to load the cube map (can be null)
  114098. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114099. * @param files defines the list of files to load (can be null)
  114100. * @returns a new CubeTextureAssetTask object
  114101. */
  114102. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114103. /**
  114104. *
  114105. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114106. * @param taskName defines the name of the new task
  114107. * @param url defines the url of the file to load
  114108. * @param size defines the size you want for the cubemap (can be null)
  114109. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114110. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114111. * @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)
  114112. * @param reserved Internal use only
  114113. * @returns a new HDRCubeTextureAssetTask object
  114114. */
  114115. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114116. /**
  114117. *
  114118. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114119. * @param taskName defines the name of the new task
  114120. * @param url defines the url of the file to load
  114121. * @param size defines the size you want for the cubemap (can be null)
  114122. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114123. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114124. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114125. * @returns a new EquiRectangularCubeTextureAssetTask object
  114126. */
  114127. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114128. /**
  114129. * Remove a task from the assets manager.
  114130. * @param task the task to remove
  114131. */
  114132. removeTask(task: AbstractAssetTask): void;
  114133. private _decreaseWaitingTasksCount;
  114134. private _runTask;
  114135. /**
  114136. * Reset the AssetsManager and remove all tasks
  114137. * @return the current instance of the AssetsManager
  114138. */
  114139. reset(): AssetsManager;
  114140. /**
  114141. * Start the loading process
  114142. * @return the current instance of the AssetsManager
  114143. */
  114144. load(): AssetsManager;
  114145. /**
  114146. * Start the loading process as an async operation
  114147. * @return a promise returning the list of failed tasks
  114148. */
  114149. loadAsync(): Promise<void>;
  114150. }
  114151. }
  114152. declare module BABYLON {
  114153. /**
  114154. * Wrapper class for promise with external resolve and reject.
  114155. */
  114156. export class Deferred<T> {
  114157. /**
  114158. * The promise associated with this deferred object.
  114159. */
  114160. readonly promise: Promise<T>;
  114161. private _resolve;
  114162. private _reject;
  114163. /**
  114164. * The resolve method of the promise associated with this deferred object.
  114165. */
  114166. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114167. /**
  114168. * The reject method of the promise associated with this deferred object.
  114169. */
  114170. readonly reject: (reason?: any) => void;
  114171. /**
  114172. * Constructor for this deferred object.
  114173. */
  114174. constructor();
  114175. }
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114180. */
  114181. export class MeshExploder {
  114182. private _centerMesh;
  114183. private _meshes;
  114184. private _meshesOrigins;
  114185. private _toCenterVectors;
  114186. private _scaledDirection;
  114187. private _newPosition;
  114188. private _centerPosition;
  114189. /**
  114190. * Explodes meshes from a center mesh.
  114191. * @param meshes The meshes to explode.
  114192. * @param centerMesh The mesh to be center of explosion.
  114193. */
  114194. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114195. private _setCenterMesh;
  114196. /**
  114197. * Get class name
  114198. * @returns "MeshExploder"
  114199. */
  114200. getClassName(): string;
  114201. /**
  114202. * "Exploded meshes"
  114203. * @returns Array of meshes with the centerMesh at index 0.
  114204. */
  114205. getMeshes(): Array<Mesh>;
  114206. /**
  114207. * Explodes meshes giving a specific direction
  114208. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114209. */
  114210. explode(direction?: number): void;
  114211. }
  114212. }
  114213. declare module BABYLON {
  114214. /**
  114215. * Class used to help managing file picking and drag'n'drop
  114216. */
  114217. export class FilesInput {
  114218. /**
  114219. * List of files ready to be loaded
  114220. */
  114221. static readonly FilesToLoad: {
  114222. [key: string]: File;
  114223. };
  114224. /**
  114225. * Callback called when a file is processed
  114226. */
  114227. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114228. private _engine;
  114229. private _currentScene;
  114230. private _sceneLoadedCallback;
  114231. private _progressCallback;
  114232. private _additionalRenderLoopLogicCallback;
  114233. private _textureLoadingCallback;
  114234. private _startingProcessingFilesCallback;
  114235. private _onReloadCallback;
  114236. private _errorCallback;
  114237. private _elementToMonitor;
  114238. private _sceneFileToLoad;
  114239. private _filesToLoad;
  114240. /**
  114241. * Creates a new FilesInput
  114242. * @param engine defines the rendering engine
  114243. * @param scene defines the hosting scene
  114244. * @param sceneLoadedCallback callback called when scene is loaded
  114245. * @param progressCallback callback called to track progress
  114246. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114247. * @param textureLoadingCallback callback called when a texture is loading
  114248. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114249. * @param onReloadCallback callback called when a reload is requested
  114250. * @param errorCallback callback call if an error occurs
  114251. */
  114252. 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);
  114253. private _dragEnterHandler;
  114254. private _dragOverHandler;
  114255. private _dropHandler;
  114256. /**
  114257. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114258. * @param elementToMonitor defines the DOM element to track
  114259. */
  114260. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114261. /**
  114262. * Release all associated resources
  114263. */
  114264. dispose(): void;
  114265. private renderFunction;
  114266. private drag;
  114267. private drop;
  114268. private _traverseFolder;
  114269. private _processFiles;
  114270. /**
  114271. * Load files from a drop event
  114272. * @param event defines the drop event to use as source
  114273. */
  114274. loadFiles(event: any): void;
  114275. private _processReload;
  114276. /**
  114277. * Reload the current scene from the loaded files
  114278. */
  114279. reload(): void;
  114280. }
  114281. }
  114282. declare module BABYLON {
  114283. /**
  114284. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114286. */
  114287. export class SceneOptimization {
  114288. /**
  114289. * Defines the priority of this optimization (0 by default which means first in the list)
  114290. */
  114291. priority: number;
  114292. /**
  114293. * Gets a string describing the action executed by the current optimization
  114294. * @returns description string
  114295. */
  114296. getDescription(): string;
  114297. /**
  114298. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114299. * @param scene defines the current scene where to apply this optimization
  114300. * @param optimizer defines the current optimizer
  114301. * @returns true if everything that can be done was applied
  114302. */
  114303. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114304. /**
  114305. * Creates the SceneOptimization object
  114306. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114307. * @param desc defines the description associated with the optimization
  114308. */
  114309. constructor(
  114310. /**
  114311. * Defines the priority of this optimization (0 by default which means first in the list)
  114312. */
  114313. priority?: number);
  114314. }
  114315. /**
  114316. * Defines an optimization used to reduce the size of render target textures
  114317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114318. */
  114319. export class TextureOptimization extends SceneOptimization {
  114320. /**
  114321. * Defines the priority of this optimization (0 by default which means first in the list)
  114322. */
  114323. priority: number;
  114324. /**
  114325. * 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
  114326. */
  114327. maximumSize: number;
  114328. /**
  114329. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114330. */
  114331. step: number;
  114332. /**
  114333. * Gets a string describing the action executed by the current optimization
  114334. * @returns description string
  114335. */
  114336. getDescription(): string;
  114337. /**
  114338. * Creates the TextureOptimization object
  114339. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114340. * @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
  114341. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114342. */
  114343. constructor(
  114344. /**
  114345. * Defines the priority of this optimization (0 by default which means first in the list)
  114346. */
  114347. priority?: number,
  114348. /**
  114349. * 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
  114350. */
  114351. maximumSize?: number,
  114352. /**
  114353. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114354. */
  114355. step?: number);
  114356. /**
  114357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114358. * @param scene defines the current scene where to apply this optimization
  114359. * @param optimizer defines the current optimizer
  114360. * @returns true if everything that can be done was applied
  114361. */
  114362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114363. }
  114364. /**
  114365. * Defines an optimization used to increase or decrease the rendering resolution
  114366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114367. */
  114368. export class HardwareScalingOptimization extends SceneOptimization {
  114369. /**
  114370. * Defines the priority of this optimization (0 by default which means first in the list)
  114371. */
  114372. priority: number;
  114373. /**
  114374. * Defines the maximum scale to use (2 by default)
  114375. */
  114376. maximumScale: number;
  114377. /**
  114378. * Defines the step to use between two passes (0.5 by default)
  114379. */
  114380. step: number;
  114381. private _currentScale;
  114382. private _directionOffset;
  114383. /**
  114384. * Gets a string describing the action executed by the current optimization
  114385. * @return description string
  114386. */
  114387. getDescription(): string;
  114388. /**
  114389. * Creates the HardwareScalingOptimization object
  114390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114391. * @param maximumScale defines the maximum scale to use (2 by default)
  114392. * @param step defines the step to use between two passes (0.5 by default)
  114393. */
  114394. constructor(
  114395. /**
  114396. * Defines the priority of this optimization (0 by default which means first in the list)
  114397. */
  114398. priority?: number,
  114399. /**
  114400. * Defines the maximum scale to use (2 by default)
  114401. */
  114402. maximumScale?: number,
  114403. /**
  114404. * Defines the step to use between two passes (0.5 by default)
  114405. */
  114406. step?: number);
  114407. /**
  114408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114409. * @param scene defines the current scene where to apply this optimization
  114410. * @param optimizer defines the current optimizer
  114411. * @returns true if everything that can be done was applied
  114412. */
  114413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114414. }
  114415. /**
  114416. * Defines an optimization used to remove shadows
  114417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114418. */
  114419. export class ShadowsOptimization extends SceneOptimization {
  114420. /**
  114421. * Gets a string describing the action executed by the current optimization
  114422. * @return description string
  114423. */
  114424. getDescription(): string;
  114425. /**
  114426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114427. * @param scene defines the current scene where to apply this optimization
  114428. * @param optimizer defines the current optimizer
  114429. * @returns true if everything that can be done was applied
  114430. */
  114431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114432. }
  114433. /**
  114434. * Defines an optimization used to turn post-processes off
  114435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114436. */
  114437. export class PostProcessesOptimization extends SceneOptimization {
  114438. /**
  114439. * Gets a string describing the action executed by the current optimization
  114440. * @return description string
  114441. */
  114442. getDescription(): string;
  114443. /**
  114444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114445. * @param scene defines the current scene where to apply this optimization
  114446. * @param optimizer defines the current optimizer
  114447. * @returns true if everything that can be done was applied
  114448. */
  114449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114450. }
  114451. /**
  114452. * Defines an optimization used to turn lens flares off
  114453. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114454. */
  114455. export class LensFlaresOptimization extends SceneOptimization {
  114456. /**
  114457. * Gets a string describing the action executed by the current optimization
  114458. * @return description string
  114459. */
  114460. getDescription(): string;
  114461. /**
  114462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114463. * @param scene defines the current scene where to apply this optimization
  114464. * @param optimizer defines the current optimizer
  114465. * @returns true if everything that can be done was applied
  114466. */
  114467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114468. }
  114469. /**
  114470. * Defines an optimization based on user defined callback.
  114471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114472. */
  114473. export class CustomOptimization extends SceneOptimization {
  114474. /**
  114475. * Callback called to apply the custom optimization.
  114476. */
  114477. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114478. /**
  114479. * Callback called to get custom description
  114480. */
  114481. onGetDescription: () => string;
  114482. /**
  114483. * Gets a string describing the action executed by the current optimization
  114484. * @returns description string
  114485. */
  114486. getDescription(): string;
  114487. /**
  114488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114489. * @param scene defines the current scene where to apply this optimization
  114490. * @param optimizer defines the current optimizer
  114491. * @returns true if everything that can be done was applied
  114492. */
  114493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114494. }
  114495. /**
  114496. * Defines an optimization used to turn particles off
  114497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114498. */
  114499. export class ParticlesOptimization extends SceneOptimization {
  114500. /**
  114501. * Gets a string describing the action executed by the current optimization
  114502. * @return description string
  114503. */
  114504. getDescription(): string;
  114505. /**
  114506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114507. * @param scene defines the current scene where to apply this optimization
  114508. * @param optimizer defines the current optimizer
  114509. * @returns true if everything that can be done was applied
  114510. */
  114511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114512. }
  114513. /**
  114514. * Defines an optimization used to turn render targets off
  114515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114516. */
  114517. export class RenderTargetsOptimization extends SceneOptimization {
  114518. /**
  114519. * Gets a string describing the action executed by the current optimization
  114520. * @return description string
  114521. */
  114522. getDescription(): string;
  114523. /**
  114524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114525. * @param scene defines the current scene where to apply this optimization
  114526. * @param optimizer defines the current optimizer
  114527. * @returns true if everything that can be done was applied
  114528. */
  114529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114530. }
  114531. /**
  114532. * Defines an optimization used to merge meshes with compatible materials
  114533. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114534. */
  114535. export class MergeMeshesOptimization extends SceneOptimization {
  114536. private static _UpdateSelectionTree;
  114537. /**
  114538. * Gets or sets a boolean which defines if optimization octree has to be updated
  114539. */
  114540. /**
  114541. * Gets or sets a boolean which defines if optimization octree has to be updated
  114542. */
  114543. static UpdateSelectionTree: boolean;
  114544. /**
  114545. * Gets a string describing the action executed by the current optimization
  114546. * @return description string
  114547. */
  114548. getDescription(): string;
  114549. private _canBeMerged;
  114550. /**
  114551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114552. * @param scene defines the current scene where to apply this optimization
  114553. * @param optimizer defines the current optimizer
  114554. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  114555. * @returns true if everything that can be done was applied
  114556. */
  114557. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  114558. }
  114559. /**
  114560. * Defines a list of options used by SceneOptimizer
  114561. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114562. */
  114563. export class SceneOptimizerOptions {
  114564. /**
  114565. * Defines the target frame rate to reach (60 by default)
  114566. */
  114567. targetFrameRate: number;
  114568. /**
  114569. * Defines the interval between two checkes (2000ms by default)
  114570. */
  114571. trackerDuration: number;
  114572. /**
  114573. * Gets the list of optimizations to apply
  114574. */
  114575. optimizations: SceneOptimization[];
  114576. /**
  114577. * Creates a new list of options used by SceneOptimizer
  114578. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  114579. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  114580. */
  114581. constructor(
  114582. /**
  114583. * Defines the target frame rate to reach (60 by default)
  114584. */
  114585. targetFrameRate?: number,
  114586. /**
  114587. * Defines the interval between two checkes (2000ms by default)
  114588. */
  114589. trackerDuration?: number);
  114590. /**
  114591. * Add a new optimization
  114592. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  114593. * @returns the current SceneOptimizerOptions
  114594. */
  114595. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  114596. /**
  114597. * Add a new custom optimization
  114598. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  114599. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  114600. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114601. * @returns the current SceneOptimizerOptions
  114602. */
  114603. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  114604. /**
  114605. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  114606. * @param targetFrameRate defines the target frame rate (60 by default)
  114607. * @returns a SceneOptimizerOptions object
  114608. */
  114609. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114610. /**
  114611. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  114612. * @param targetFrameRate defines the target frame rate (60 by default)
  114613. * @returns a SceneOptimizerOptions object
  114614. */
  114615. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114616. /**
  114617. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  114618. * @param targetFrameRate defines the target frame rate (60 by default)
  114619. * @returns a SceneOptimizerOptions object
  114620. */
  114621. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114622. }
  114623. /**
  114624. * Class used to run optimizations in order to reach a target frame rate
  114625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114626. */
  114627. export class SceneOptimizer implements IDisposable {
  114628. private _isRunning;
  114629. private _options;
  114630. private _scene;
  114631. private _currentPriorityLevel;
  114632. private _targetFrameRate;
  114633. private _trackerDuration;
  114634. private _currentFrameRate;
  114635. private _sceneDisposeObserver;
  114636. private _improvementMode;
  114637. /**
  114638. * Defines an observable called when the optimizer reaches the target frame rate
  114639. */
  114640. onSuccessObservable: Observable<SceneOptimizer>;
  114641. /**
  114642. * Defines an observable called when the optimizer enables an optimization
  114643. */
  114644. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  114645. /**
  114646. * Defines an observable called when the optimizer is not able to reach the target frame rate
  114647. */
  114648. onFailureObservable: Observable<SceneOptimizer>;
  114649. /**
  114650. * Gets a boolean indicating if the optimizer is in improvement mode
  114651. */
  114652. readonly isInImprovementMode: boolean;
  114653. /**
  114654. * Gets the current priority level (0 at start)
  114655. */
  114656. readonly currentPriorityLevel: number;
  114657. /**
  114658. * Gets the current frame rate checked by the SceneOptimizer
  114659. */
  114660. readonly currentFrameRate: number;
  114661. /**
  114662. * Gets or sets the current target frame rate (60 by default)
  114663. */
  114664. /**
  114665. * Gets or sets the current target frame rate (60 by default)
  114666. */
  114667. targetFrameRate: number;
  114668. /**
  114669. * Gets or sets the current interval between two checks (every 2000ms by default)
  114670. */
  114671. /**
  114672. * Gets or sets the current interval between two checks (every 2000ms by default)
  114673. */
  114674. trackerDuration: number;
  114675. /**
  114676. * Gets the list of active optimizations
  114677. */
  114678. readonly optimizations: SceneOptimization[];
  114679. /**
  114680. * Creates a new SceneOptimizer
  114681. * @param scene defines the scene to work on
  114682. * @param options defines the options to use with the SceneOptimizer
  114683. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  114684. * @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)
  114685. */
  114686. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  114687. /**
  114688. * Stops the current optimizer
  114689. */
  114690. stop(): void;
  114691. /**
  114692. * Reset the optimizer to initial step (current priority level = 0)
  114693. */
  114694. reset(): void;
  114695. /**
  114696. * Start the optimizer. By default it will try to reach a specific framerate
  114697. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  114698. */
  114699. start(): void;
  114700. private _checkCurrentState;
  114701. /**
  114702. * Release all resources
  114703. */
  114704. dispose(): void;
  114705. /**
  114706. * Helper function to create a SceneOptimizer with one single line of code
  114707. * @param scene defines the scene to work on
  114708. * @param options defines the options to use with the SceneOptimizer
  114709. * @param onSuccess defines a callback to call on success
  114710. * @param onFailure defines a callback to call on failure
  114711. * @returns the new SceneOptimizer object
  114712. */
  114713. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  114714. }
  114715. }
  114716. declare module BABYLON {
  114717. /**
  114718. * Class used to serialize a scene into a string
  114719. */
  114720. export class SceneSerializer {
  114721. /**
  114722. * Clear cache used by a previous serialization
  114723. */
  114724. static ClearCache(): void;
  114725. /**
  114726. * Serialize a scene into a JSON compatible object
  114727. * @param scene defines the scene to serialize
  114728. * @returns a JSON compatible object
  114729. */
  114730. static Serialize(scene: Scene): any;
  114731. /**
  114732. * Serialize a mesh into a JSON compatible object
  114733. * @param toSerialize defines the mesh to serialize
  114734. * @param withParents defines if parents must be serialized as well
  114735. * @param withChildren defines if children must be serialized as well
  114736. * @returns a JSON compatible object
  114737. */
  114738. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  114739. }
  114740. }
  114741. declare module BABYLON {
  114742. /**
  114743. * Class used to host texture specific utilities
  114744. */
  114745. export class TextureTools {
  114746. /**
  114747. * Uses the GPU to create a copy texture rescaled at a given size
  114748. * @param texture Texture to copy from
  114749. * @param width defines the desired width
  114750. * @param height defines the desired height
  114751. * @param useBilinearMode defines if bilinear mode has to be used
  114752. * @return the generated texture
  114753. */
  114754. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  114755. }
  114756. }
  114757. declare module BABYLON {
  114758. /**
  114759. * This represents the different options avilable for the video capture.
  114760. */
  114761. export interface VideoRecorderOptions {
  114762. /** Defines the mime type of the video */
  114763. mimeType: string;
  114764. /** Defines the video the video should be recorded at */
  114765. fps: number;
  114766. /** Defines the chunk size for the recording data */
  114767. recordChunckSize: number;
  114768. /** The audio tracks to attach to the record */
  114769. audioTracks?: MediaStreamTrack[];
  114770. }
  114771. /**
  114772. * This can helps recording videos from BabylonJS.
  114773. * This is based on the available WebRTC functionalities of the browser.
  114774. *
  114775. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  114776. */
  114777. export class VideoRecorder {
  114778. private static readonly _defaultOptions;
  114779. /**
  114780. * Returns wehther or not the VideoRecorder is available in your browser.
  114781. * @param engine Defines the Babylon Engine to check the support for
  114782. * @returns true if supported otherwise false
  114783. */
  114784. static IsSupported(engine: Engine): boolean;
  114785. private readonly _options;
  114786. private _canvas;
  114787. private _mediaRecorder;
  114788. private _recordedChunks;
  114789. private _fileName;
  114790. private _resolve;
  114791. private _reject;
  114792. /**
  114793. * True wether a recording is already in progress.
  114794. */
  114795. readonly isRecording: boolean;
  114796. /**
  114797. * Create a new VideoCapture object which can help converting what you see in Babylon to
  114798. * a video file.
  114799. * @param engine Defines the BabylonJS Engine you wish to record
  114800. * @param options Defines options that can be used to customized the capture
  114801. */
  114802. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  114803. /**
  114804. * Stops the current recording before the default capture timeout passed in the startRecording
  114805. * functions.
  114806. */
  114807. stopRecording(): void;
  114808. /**
  114809. * Starts recording the canvas for a max duration specified in parameters.
  114810. * @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.
  114811. * @param maxDuration Defines the maximum recording time in seconds.
  114812. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  114813. * @return a promise callback at the end of the recording with the video data in Blob.
  114814. */
  114815. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  114816. /**
  114817. * Releases internal resources used during the recording.
  114818. */
  114819. dispose(): void;
  114820. private _handleDataAvailable;
  114821. private _handleError;
  114822. private _handleStop;
  114823. }
  114824. }
  114825. declare module BABYLON {
  114826. /**
  114827. * Helper class to push actions to a pool of workers.
  114828. */
  114829. export class WorkerPool implements IDisposable {
  114830. private _workerInfos;
  114831. private _pendingActions;
  114832. /**
  114833. * Constructor
  114834. * @param workers Array of workers to use for actions
  114835. */
  114836. constructor(workers: Array<Worker>);
  114837. /**
  114838. * Terminates all workers and clears any pending actions.
  114839. */
  114840. dispose(): void;
  114841. /**
  114842. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114843. * pended until a worker has completed its action.
  114844. * @param action The action to perform. Call onComplete when the action is complete.
  114845. */
  114846. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114847. private _execute;
  114848. }
  114849. }
  114850. declare module BABYLON {
  114851. /**
  114852. * Class containing a set of static utilities functions for screenshots
  114853. */
  114854. export class ScreenshotTools {
  114855. /**
  114856. * Captures a screenshot of the current rendering
  114857. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114858. * @param engine defines the rendering engine
  114859. * @param camera defines the source camera
  114860. * @param size This parameter can be set to a single number or to an object with the
  114861. * following (optional) properties: precision, width, height. If a single number is passed,
  114862. * it will be used for both width and height. If an object is passed, the screenshot size
  114863. * will be derived from the parameters. The precision property is a multiplier allowing
  114864. * rendering at a higher or lower resolution
  114865. * @param successCallback defines the callback receives a single parameter which contains the
  114866. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114867. * src parameter of an <img> to display it
  114868. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114869. * Check your browser for supported MIME types
  114870. */
  114871. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  114872. /**
  114873. * Generates an image screenshot from the specified camera.
  114874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114875. * @param engine The engine to use for rendering
  114876. * @param camera The camera to use for rendering
  114877. * @param size This parameter can be set to a single number or to an object with the
  114878. * following (optional) properties: precision, width, height. If a single number is passed,
  114879. * it will be used for both width and height. If an object is passed, the screenshot size
  114880. * will be derived from the parameters. The precision property is a multiplier allowing
  114881. * rendering at a higher or lower resolution
  114882. * @param successCallback The callback receives a single parameter which contains the
  114883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114884. * src parameter of an <img> to display it
  114885. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114886. * Check your browser for supported MIME types
  114887. * @param samples Texture samples (default: 1)
  114888. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114889. * @param fileName A name for for the downloaded file.
  114890. */
  114891. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114892. }
  114893. }
  114894. declare module BABYLON {
  114895. /**
  114896. * A cursor which tracks a point on a path
  114897. */
  114898. export class PathCursor {
  114899. private path;
  114900. /**
  114901. * Stores path cursor callbacks for when an onchange event is triggered
  114902. */
  114903. private _onchange;
  114904. /**
  114905. * The value of the path cursor
  114906. */
  114907. value: number;
  114908. /**
  114909. * The animation array of the path cursor
  114910. */
  114911. animations: Animation[];
  114912. /**
  114913. * Initializes the path cursor
  114914. * @param path The path to track
  114915. */
  114916. constructor(path: Path2);
  114917. /**
  114918. * Gets the cursor point on the path
  114919. * @returns A point on the path cursor at the cursor location
  114920. */
  114921. getPoint(): Vector3;
  114922. /**
  114923. * Moves the cursor ahead by the step amount
  114924. * @param step The amount to move the cursor forward
  114925. * @returns This path cursor
  114926. */
  114927. moveAhead(step?: number): PathCursor;
  114928. /**
  114929. * Moves the cursor behind by the step amount
  114930. * @param step The amount to move the cursor back
  114931. * @returns This path cursor
  114932. */
  114933. moveBack(step?: number): PathCursor;
  114934. /**
  114935. * Moves the cursor by the step amount
  114936. * If the step amount is greater than one, an exception is thrown
  114937. * @param step The amount to move the cursor
  114938. * @returns This path cursor
  114939. */
  114940. move(step: number): PathCursor;
  114941. /**
  114942. * Ensures that the value is limited between zero and one
  114943. * @returns This path cursor
  114944. */
  114945. private ensureLimits;
  114946. /**
  114947. * Runs onchange callbacks on change (used by the animation engine)
  114948. * @returns This path cursor
  114949. */
  114950. private raiseOnChange;
  114951. /**
  114952. * Executes a function on change
  114953. * @param f A path cursor onchange callback
  114954. * @returns This path cursor
  114955. */
  114956. onchange(f: (cursor: PathCursor) => void): PathCursor;
  114957. }
  114958. }
  114959. declare module BABYLON {
  114960. /** @hidden */
  114961. export var blurPixelShader: {
  114962. name: string;
  114963. shader: string;
  114964. };
  114965. }
  114966. declare module BABYLON {
  114967. /** @hidden */
  114968. export var bones300Declaration: {
  114969. name: string;
  114970. shader: string;
  114971. };
  114972. }
  114973. declare module BABYLON {
  114974. /** @hidden */
  114975. export var instances300Declaration: {
  114976. name: string;
  114977. shader: string;
  114978. };
  114979. }
  114980. declare module BABYLON {
  114981. /** @hidden */
  114982. export var pointCloudVertexDeclaration: {
  114983. name: string;
  114984. shader: string;
  114985. };
  114986. }
  114987. // Mixins
  114988. interface Window {
  114989. mozIndexedDB: IDBFactory;
  114990. webkitIndexedDB: IDBFactory;
  114991. msIndexedDB: IDBFactory;
  114992. webkitURL: typeof URL;
  114993. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  114994. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  114995. WebGLRenderingContext: WebGLRenderingContext;
  114996. MSGesture: MSGesture;
  114997. CANNON: any;
  114998. AudioContext: AudioContext;
  114999. webkitAudioContext: AudioContext;
  115000. PointerEvent: any;
  115001. Math: Math;
  115002. Uint8Array: Uint8ArrayConstructor;
  115003. Float32Array: Float32ArrayConstructor;
  115004. mozURL: typeof URL;
  115005. msURL: typeof URL;
  115006. VRFrameData: any; // WebVR, from specs 1.1
  115007. DracoDecoderModule: any;
  115008. setImmediate(handler: (...args: any[]) => void): number;
  115009. }
  115010. interface HTMLCanvasElement {
  115011. requestPointerLock(): void;
  115012. msRequestPointerLock?(): void;
  115013. mozRequestPointerLock?(): void;
  115014. webkitRequestPointerLock?(): void;
  115015. /** Track wether a record is in progress */
  115016. isRecording: boolean;
  115017. /** Capture Stream method defined by some browsers */
  115018. captureStream(fps?: number): MediaStream;
  115019. }
  115020. interface CanvasRenderingContext2D {
  115021. msImageSmoothingEnabled: boolean;
  115022. }
  115023. interface MouseEvent {
  115024. mozMovementX: number;
  115025. mozMovementY: number;
  115026. webkitMovementX: number;
  115027. webkitMovementY: number;
  115028. msMovementX: number;
  115029. msMovementY: number;
  115030. }
  115031. interface Navigator {
  115032. mozGetVRDevices: (any: any) => any;
  115033. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115034. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115035. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115036. webkitGetGamepads(): Gamepad[];
  115037. msGetGamepads(): Gamepad[];
  115038. webkitGamepads(): Gamepad[];
  115039. }
  115040. interface HTMLVideoElement {
  115041. mozSrcObject: any;
  115042. }
  115043. interface Math {
  115044. fround(x: number): number;
  115045. imul(a: number, b: number): number;
  115046. }
  115047. interface WebGLProgram {
  115048. context?: WebGLRenderingContext;
  115049. vertexShader?: WebGLShader;
  115050. fragmentShader?: WebGLShader;
  115051. isParallelCompiled: boolean;
  115052. onCompiled?: () => void;
  115053. }
  115054. interface WebGLRenderingContext {
  115055. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115056. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115057. vertexAttribDivisor(index: number, divisor: number): void;
  115058. createVertexArray(): any;
  115059. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115060. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115061. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115062. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115063. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115064. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115065. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115066. // Queries
  115067. createQuery(): WebGLQuery;
  115068. deleteQuery(query: WebGLQuery): void;
  115069. beginQuery(target: number, query: WebGLQuery): void;
  115070. endQuery(target: number): void;
  115071. getQueryParameter(query: WebGLQuery, pname: number): any;
  115072. getQuery(target: number, pname: number): any;
  115073. MAX_SAMPLES: number;
  115074. RGBA8: number;
  115075. READ_FRAMEBUFFER: number;
  115076. DRAW_FRAMEBUFFER: number;
  115077. UNIFORM_BUFFER: number;
  115078. HALF_FLOAT_OES: number;
  115079. RGBA16F: number;
  115080. RGBA32F: number;
  115081. R32F: number;
  115082. RG32F: number;
  115083. RGB32F: number;
  115084. R16F: number;
  115085. RG16F: number;
  115086. RGB16F: number;
  115087. RED: number;
  115088. RG: number;
  115089. R8: number;
  115090. RG8: number;
  115091. UNSIGNED_INT_24_8: number;
  115092. DEPTH24_STENCIL8: number;
  115093. /* Multiple Render Targets */
  115094. drawBuffers(buffers: number[]): void;
  115095. readBuffer(src: number): void;
  115096. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115097. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115098. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115099. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115100. // Occlusion Query
  115101. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115102. ANY_SAMPLES_PASSED: number;
  115103. QUERY_RESULT_AVAILABLE: number;
  115104. QUERY_RESULT: number;
  115105. }
  115106. interface WebGLBuffer {
  115107. references: number;
  115108. capacity: number;
  115109. is32Bits: boolean;
  115110. }
  115111. interface WebGLProgram {
  115112. transformFeedback?: WebGLTransformFeedback | null;
  115113. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115114. }
  115115. interface EXT_disjoint_timer_query {
  115116. QUERY_COUNTER_BITS_EXT: number;
  115117. TIME_ELAPSED_EXT: number;
  115118. TIMESTAMP_EXT: number;
  115119. GPU_DISJOINT_EXT: number;
  115120. QUERY_RESULT_EXT: number;
  115121. QUERY_RESULT_AVAILABLE_EXT: number;
  115122. queryCounterEXT(query: WebGLQuery, target: number): void;
  115123. createQueryEXT(): WebGLQuery;
  115124. beginQueryEXT(target: number, query: WebGLQuery): void;
  115125. endQueryEXT(target: number): void;
  115126. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115127. deleteQueryEXT(query: WebGLQuery): void;
  115128. }
  115129. interface WebGLUniformLocation {
  115130. _currentState: any;
  115131. }
  115132. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115133. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115134. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115135. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115136. interface WebGLRenderingContext {
  115137. readonly RASTERIZER_DISCARD: number;
  115138. readonly DEPTH_COMPONENT24: number;
  115139. readonly TEXTURE_3D: number;
  115140. readonly TEXTURE_2D_ARRAY: number;
  115141. readonly TEXTURE_COMPARE_FUNC: number;
  115142. readonly TEXTURE_COMPARE_MODE: number;
  115143. readonly COMPARE_REF_TO_TEXTURE: number;
  115144. readonly TEXTURE_WRAP_R: number;
  115145. readonly HALF_FLOAT: number;
  115146. readonly RGB8: number;
  115147. readonly RED_INTEGER: number;
  115148. readonly RG_INTEGER: number;
  115149. readonly RGB_INTEGER: number;
  115150. readonly RGBA_INTEGER: number;
  115151. readonly R8_SNORM: number;
  115152. readonly RG8_SNORM: number;
  115153. readonly RGB8_SNORM: number;
  115154. readonly RGBA8_SNORM: number;
  115155. readonly R8I: number;
  115156. readonly RG8I: number;
  115157. readonly RGB8I: number;
  115158. readonly RGBA8I: number;
  115159. readonly R8UI: number;
  115160. readonly RG8UI: number;
  115161. readonly RGB8UI: number;
  115162. readonly RGBA8UI: number;
  115163. readonly R16I: number;
  115164. readonly RG16I: number;
  115165. readonly RGB16I: number;
  115166. readonly RGBA16I: number;
  115167. readonly R16UI: number;
  115168. readonly RG16UI: number;
  115169. readonly RGB16UI: number;
  115170. readonly RGBA16UI: number;
  115171. readonly R32I: number;
  115172. readonly RG32I: number;
  115173. readonly RGB32I: number;
  115174. readonly RGBA32I: number;
  115175. readonly R32UI: number;
  115176. readonly RG32UI: number;
  115177. readonly RGB32UI: number;
  115178. readonly RGBA32UI: number;
  115179. readonly RGB10_A2UI: number;
  115180. readonly R11F_G11F_B10F: number;
  115181. readonly RGB9_E5: number;
  115182. readonly RGB10_A2: number;
  115183. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115184. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115185. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115186. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115187. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115188. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115189. 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;
  115190. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115191. readonly TRANSFORM_FEEDBACK: number;
  115192. readonly INTERLEAVED_ATTRIBS: number;
  115193. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115194. createTransformFeedback(): WebGLTransformFeedback;
  115195. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115196. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115197. beginTransformFeedback(primitiveMode: number): void;
  115198. endTransformFeedback(): void;
  115199. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115200. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115201. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115202. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115203. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115204. }
  115205. interface ImageBitmap {
  115206. readonly width: number;
  115207. readonly height: number;
  115208. close(): void;
  115209. }
  115210. interface WebGLQuery extends WebGLObject {
  115211. }
  115212. declare var WebGLQuery: {
  115213. prototype: WebGLQuery;
  115214. new(): WebGLQuery;
  115215. };
  115216. interface WebGLSampler extends WebGLObject {
  115217. }
  115218. declare var WebGLSampler: {
  115219. prototype: WebGLSampler;
  115220. new(): WebGLSampler;
  115221. };
  115222. interface WebGLSync extends WebGLObject {
  115223. }
  115224. declare var WebGLSync: {
  115225. prototype: WebGLSync;
  115226. new(): WebGLSync;
  115227. };
  115228. interface WebGLTransformFeedback extends WebGLObject {
  115229. }
  115230. declare var WebGLTransformFeedback: {
  115231. prototype: WebGLTransformFeedback;
  115232. new(): WebGLTransformFeedback;
  115233. };
  115234. interface WebGLVertexArrayObject extends WebGLObject {
  115235. }
  115236. declare var WebGLVertexArrayObject: {
  115237. prototype: WebGLVertexArrayObject;
  115238. new(): WebGLVertexArrayObject;
  115239. };
  115240. // Type definitions for WebVR API
  115241. // Project: https://w3c.github.io/webvr/
  115242. // Definitions by: six a <https://github.com/lostfictions>
  115243. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115244. interface VRDisplay extends EventTarget {
  115245. /**
  115246. * Dictionary of capabilities describing the VRDisplay.
  115247. */
  115248. readonly capabilities: VRDisplayCapabilities;
  115249. /**
  115250. * z-depth defining the far plane of the eye view frustum
  115251. * enables mapping of values in the render target depth
  115252. * attachment to scene coordinates. Initially set to 10000.0.
  115253. */
  115254. depthFar: number;
  115255. /**
  115256. * z-depth defining the near plane of the eye view frustum
  115257. * enables mapping of values in the render target depth
  115258. * attachment to scene coordinates. Initially set to 0.01.
  115259. */
  115260. depthNear: number;
  115261. /**
  115262. * An identifier for this distinct VRDisplay. Used as an
  115263. * association point in the Gamepad API.
  115264. */
  115265. readonly displayId: number;
  115266. /**
  115267. * A display name, a user-readable name identifying it.
  115268. */
  115269. readonly displayName: string;
  115270. readonly isConnected: boolean;
  115271. readonly isPresenting: boolean;
  115272. /**
  115273. * If this VRDisplay supports room-scale experiences, the optional
  115274. * stage attribute contains details on the room-scale parameters.
  115275. */
  115276. readonly stageParameters: VRStageParameters | null;
  115277. /**
  115278. * Passing the value returned by `requestAnimationFrame` to
  115279. * `cancelAnimationFrame` will unregister the callback.
  115280. * @param handle Define the hanle of the request to cancel
  115281. */
  115282. cancelAnimationFrame(handle: number): void;
  115283. /**
  115284. * Stops presenting to the VRDisplay.
  115285. * @returns a promise to know when it stopped
  115286. */
  115287. exitPresent(): Promise<void>;
  115288. /**
  115289. * Return the current VREyeParameters for the given eye.
  115290. * @param whichEye Define the eye we want the parameter for
  115291. * @returns the eye parameters
  115292. */
  115293. getEyeParameters(whichEye: string): VREyeParameters;
  115294. /**
  115295. * Populates the passed VRFrameData with the information required to render
  115296. * the current frame.
  115297. * @param frameData Define the data structure to populate
  115298. * @returns true if ok otherwise false
  115299. */
  115300. getFrameData(frameData: VRFrameData): boolean;
  115301. /**
  115302. * Get the layers currently being presented.
  115303. * @returns the list of VR layers
  115304. */
  115305. getLayers(): VRLayer[];
  115306. /**
  115307. * Return a VRPose containing the future predicted pose of the VRDisplay
  115308. * when the current frame will be presented. The value returned will not
  115309. * change until JavaScript has returned control to the browser.
  115310. *
  115311. * The VRPose will contain the position, orientation, velocity,
  115312. * and acceleration of each of these properties.
  115313. * @returns the pose object
  115314. */
  115315. getPose(): VRPose;
  115316. /**
  115317. * Return the current instantaneous pose of the VRDisplay, with no
  115318. * prediction applied.
  115319. * @returns the current instantaneous pose
  115320. */
  115321. getImmediatePose(): VRPose;
  115322. /**
  115323. * The callback passed to `requestAnimationFrame` will be called
  115324. * any time a new frame should be rendered. When the VRDisplay is
  115325. * presenting the callback will be called at the native refresh
  115326. * rate of the HMD. When not presenting this function acts
  115327. * identically to how window.requestAnimationFrame acts. Content should
  115328. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115329. * asynchronously from other displays and at differing refresh rates.
  115330. * @param callback Define the eaction to run next frame
  115331. * @returns the request handle it
  115332. */
  115333. requestAnimationFrame(callback: FrameRequestCallback): number;
  115334. /**
  115335. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115336. * Repeat calls while already presenting will update the VRLayers being displayed.
  115337. * @param layers Define the list of layer to present
  115338. * @returns a promise to know when the request has been fulfilled
  115339. */
  115340. requestPresent(layers: VRLayer[]): Promise<void>;
  115341. /**
  115342. * Reset the pose for this display, treating its current position and
  115343. * orientation as the "origin/zero" values. VRPose.position,
  115344. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115345. * updated when calling resetPose(). This should be called in only
  115346. * sitting-space experiences.
  115347. */
  115348. resetPose(): void;
  115349. /**
  115350. * The VRLayer provided to the VRDisplay will be captured and presented
  115351. * in the HMD. Calling this function has the same effect on the source
  115352. * canvas as any other operation that uses its source image, and canvases
  115353. * created without preserveDrawingBuffer set to true will be cleared.
  115354. * @param pose Define the pose to submit
  115355. */
  115356. submitFrame(pose?: VRPose): void;
  115357. }
  115358. declare var VRDisplay: {
  115359. prototype: VRDisplay;
  115360. new(): VRDisplay;
  115361. };
  115362. interface VRLayer {
  115363. leftBounds?: number[] | Float32Array | null;
  115364. rightBounds?: number[] | Float32Array | null;
  115365. source?: HTMLCanvasElement | null;
  115366. }
  115367. interface VRDisplayCapabilities {
  115368. readonly canPresent: boolean;
  115369. readonly hasExternalDisplay: boolean;
  115370. readonly hasOrientation: boolean;
  115371. readonly hasPosition: boolean;
  115372. readonly maxLayers: number;
  115373. }
  115374. interface VREyeParameters {
  115375. /** @deprecated */
  115376. readonly fieldOfView: VRFieldOfView;
  115377. readonly offset: Float32Array;
  115378. readonly renderHeight: number;
  115379. readonly renderWidth: number;
  115380. }
  115381. interface VRFieldOfView {
  115382. readonly downDegrees: number;
  115383. readonly leftDegrees: number;
  115384. readonly rightDegrees: number;
  115385. readonly upDegrees: number;
  115386. }
  115387. interface VRFrameData {
  115388. readonly leftProjectionMatrix: Float32Array;
  115389. readonly leftViewMatrix: Float32Array;
  115390. readonly pose: VRPose;
  115391. readonly rightProjectionMatrix: Float32Array;
  115392. readonly rightViewMatrix: Float32Array;
  115393. readonly timestamp: number;
  115394. }
  115395. interface VRPose {
  115396. readonly angularAcceleration: Float32Array | null;
  115397. readonly angularVelocity: Float32Array | null;
  115398. readonly linearAcceleration: Float32Array | null;
  115399. readonly linearVelocity: Float32Array | null;
  115400. readonly orientation: Float32Array | null;
  115401. readonly position: Float32Array | null;
  115402. readonly timestamp: number;
  115403. }
  115404. interface VRStageParameters {
  115405. sittingToStandingTransform?: Float32Array;
  115406. sizeX?: number;
  115407. sizeY?: number;
  115408. }
  115409. interface Navigator {
  115410. getVRDisplays(): Promise<VRDisplay[]>;
  115411. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115412. }
  115413. interface Window {
  115414. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115415. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115416. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115417. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115418. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115419. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115420. }
  115421. interface Gamepad {
  115422. readonly displayId: number;
  115423. }
  115424. interface XRDevice {
  115425. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115426. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115427. }
  115428. interface XRSession {
  115429. getInputSources(): Array<any>;
  115430. baseLayer: XRWebGLLayer;
  115431. requestFrameOfReference(type: string): Promise<void>;
  115432. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115433. end(): Promise<void>;
  115434. requestAnimationFrame: Function;
  115435. addEventListener: Function;
  115436. }
  115437. interface XRSessionCreationOptions {
  115438. outputContext?: WebGLRenderingContext | null;
  115439. immersive?: boolean;
  115440. environmentIntegration?: boolean;
  115441. }
  115442. interface XRLayer {
  115443. getViewport: Function;
  115444. framebufferWidth: number;
  115445. framebufferHeight: number;
  115446. }
  115447. interface XRView {
  115448. projectionMatrix: Float32Array;
  115449. }
  115450. interface XRFrame {
  115451. getDevicePose: Function;
  115452. getInputPose: Function;
  115453. views: Array<XRView>;
  115454. baseLayer: XRLayer;
  115455. }
  115456. interface XRFrameOfReference {
  115457. }
  115458. interface XRWebGLLayer extends XRLayer {
  115459. framebuffer: WebGLFramebuffer;
  115460. }
  115461. declare var XRWebGLLayer: {
  115462. prototype: XRWebGLLayer;
  115463. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115464. };